@@ -8,6 +8,8 @@ using SparseArrays
88using LinearAlgebra
99
1010test_repr (a, b) = @test repr (Base. remove_linenums! (a)) == repr (Base. remove_linenums! (b))
11+ nanmath_st = Code. NameState ()
12+ nanmath_st. rewrites[:nanmath ] = true
1113
1214@testset " Code" begin
1315 @syms a b c d e p q t x (t) y (t) z (t)
@@ -84,11 +86,18 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
8486 end )
8587 @test toexpr (SetArray (true , a, [x (t), AtIndex (9 , b), c])). head == :macrocall
8688
89+ f = GlobalRef (NaNMath, :sin )
8790 test_repr (toexpr (LiteralExpr (:(let x= 1 , y= 2
88- $ (NaNMath. sin (a+ b))
91+ $ (sin (a+ b))
92+ end )), nanmath_st),
93+ :(let x = 1 , y = 2
94+ $ (f)($ (+ )(a, b))
95+ end ))
96+ test_repr (toexpr (LiteralExpr (:(let x= 1 , y= 2
97+ $ (sin (a+ b))
8998 end ))),
9099 :(let x = 1 , y = 2
91- $ (NaNMath . sin)($ (+ )(a, b))
100+ $ (sin)($ (+ )(a, b))
92101 end ))
93102
94103 test_repr (toexpr (MakeArray ([a,b,a+ b], :arr )),
@@ -191,7 +200,7 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
191200 @test f (1 ) == 1
192201 @test f (2 ) == 2
193202
194- f = eval (toexpr (Func ([a, b], [], sqrt (a - b))))
203+ f = eval (toexpr (Func ([a, b], [], sqrt (a - b)), nanmath_st ))
195204 @test isnan (f (0 , 10 ))
196205 @test f (10 , 2 ) ≈ sqrt (8 )
197206 end
0 commit comments