Skip to content

Commit d7fb05d

Browse files
committed
Update ReflectionOfType to implement IntoString trait.
This allows for easier printing of the `reflection_of_type` macro.
1 parent 2ff24e5 commit d7fb05d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

core/Reflection.savi

+4
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

+6-4
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)