Skip to content

Commit 7fa4b70

Browse files
authored
Merge pull request #493 from savi-lang/add/reflection-into-string
Update `ReflectionOfType` to implement `IntoString` trait.
2 parents 2ff24e5 + d7fb05d commit 7fa4b70

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

core/Reflection.savi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
:let features Array(ReflectionFeatureOfType(A)): []
1515

16+
:is IntoString
17+
:fun into_string_space USize: @string.size
18+
:fun into_string(out String'ref) None: @string.into_string(out)
19+
1620
:class val ReflectionFeatureOfType(A)
1721
:let name String: ""
1822
:let tags Array(String): []

spec/language/semantics/reflection_spec.savi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
:fun run(test MicroTest)
33
test["reflection_of_type.string String"].pass =
44
(reflection_of_type "example").string == "String"
5-
test["reflection_of_type.string String'ref"].pass =
6-
(reflection_of_type String.new).string == "String'ref"
7-
test["reflection_of_type.string Array(U8)"].pass =
8-
(reflection_of_type Array(U8).new).string == "Array(U8)"
5+
test["reflection_of_type string String"].pass =
6+
"\(reflection_of_type "example")" == "String"
7+
test["reflection_of_type string String'ref"].pass =
8+
"\(reflection_of_type String.new)" == "String'ref"
9+
test["reflection_of_type string Array(U8)"].pass =
10+
"\(reflection_of_type Array(U8).new)" == "Array(U8)"
911

1012
test["reflection_of_runtime_type_name U64"].pass =
1113
(reflection_of_runtime_type_name U64[0]) == "U64"

0 commit comments

Comments
 (0)