@@ -64,14 +64,35 @@ function test_repr(x::String)
64
64
x2 = eval (Meta. parse (repr (x1)))
65
65
x3 = eval (Meta. parse (repr (x2)))
66
66
if ! (x1 == x2 == x3)
67
- error (string (
67
+ # error(string(
68
+ print (string (
68
69
" repr test failed:" ,
69
70
" \n original: " , x,
71
+ " \n\n preparsed: " , x1, " \n " , sprint (dump, x1),
70
72
" \n\n parsed: " , x2, " \n " , sprint (dump, x2),
71
73
" \n\n reparsed: " , x3, " \n " , sprint (dump, x3)
72
74
))
73
75
end
74
76
@test x1 == x2 == x3
77
+
78
+ x4 = Base. remove_linenums! (Meta. parse (x))
79
+ x5 = eval (Base. remove_linenums! (Meta. parse (repr (x4))))
80
+ x6 = eval (Base. remove_linenums! (Meta. parse (repr (x5))))
81
+ if ! (x4 == x5 == x6)
82
+ error (string (
83
+ " repr test without line numbers failed:" ,
84
+ " \n original: " , x,
85
+ " \n\n preparsed: " , x4, " \n " , sprint (dump, x4),
86
+ " \n\n parsed: " , x5, " \n " , sprint (dump, x5),
87
+ " \n\n reparsed: " , x6, " \n " , sprint (dump, x6)
88
+ ))
89
+ end
90
+ @test x4 == x5 == x6
91
+
92
+ @test Base. remove_linenums! (x1) ==
93
+ Base. remove_linenums! (x2) ==
94
+ Base. remove_linenums! (x3) ==
95
+ x4 == x5 == x6
75
96
end
76
97
77
98
# primitive types
@@ -849,7 +870,9 @@ end""")) ==
849
870
end""" ))) ==
850
871
"""
851
872
:(macro m(a, b)
852
- :(\$ a + \$ b)
873
+ quote
874
+ \$ a + \$ b
875
+ end
853
876
end)"""
854
877
@test repr (Meta. parse (
855
878
""" macro m(a, b)
@@ -922,25 +945,30 @@ end"""
922
945
923
946
# nested quotes and blocks
924
947
@test_repr " Expr(:quote, Expr(:block, :a, :b))"
925
- # @test_repr repr(Expr(:quote, Expr(:block, :a, :b)))
926
948
@test_repr repr (Expr (:quote , Expr (:block , LineNumberNode (0 , :none ), :a , LineNumberNode (0 , :none ), :b )))
927
949
@test repr (Expr (:quote , Expr (:block , :a , :b ))) ==
928
950
" :(quote
929
951
a
930
952
b
931
953
end)"
932
954
@test_repr " Expr(:quote, Expr(:block, :a))"
933
- @test_repr repr (Expr (:quote , Expr (:block , :a )))
934
- @test repr (Expr (:quote , Expr (:block , :a ))) == " :(:a)"
955
+ @test_repr repr (Expr (:quote , Expr (:block , LineNumberNode (0 , :none ), :a )))
956
+ @test repr (Expr (:quote , Expr (:block , :a ))) ==
957
+ " :(quote
958
+ a
959
+ end)"
935
960
@test_repr " Expr(:quote, Expr(:block, :(a + b)))"
936
- @test_repr repr (Expr (:quote , Expr (:block , :(a + b))))
937
- @test repr (Expr (:quote , Expr (:block , :(a + b)))) == " :(:(a + b))"
961
+ @test_repr repr (Expr (:quote , Expr (:block , LineNumberNode (0 , :none ), :(a + b))))
962
+ @test repr (Expr (:quote , Expr (:block , :(a + b)))) ==
963
+ " :(quote
964
+ a + b
965
+ end)"
938
966
939
967
# QuoteNode + quotes and unquotes
940
968
@test_repr " QuoteNode(\$ x)"
941
969
@test_repr " QuoteNode(\$\$ x)"
942
970
@test_repr " :(QuoteNode(\$ x))"
943
- @test_repr " :(:(QuoteNode(\$\$ x))"
971
+ @test_repr " :(:(QuoteNode(\$\$ x))) "
944
972
@test repr (QuoteNode (Expr (:$ , :x ))) == " :(\$ (QuoteNode(:(\$ (Expr(:\$ , :x))))))"
945
973
@test repr (QuoteNode (Expr (:quote , Expr (:$ , :x )))) == " :(\$ (QuoteNode(:(:(\$ x)))))"
946
974
@test repr (Expr (:quote , QuoteNode (Expr (:$ , :x )))) == " :(:(\$ (QuoteNode(:(\$ (Expr(:\$ , :x)))))))"
0 commit comments