@@ -20,9 +20,6 @@ nanmath_st.rewrites[:nanmath] = true
20
20
@test toexpr (a* b* c* d* e) == :($ (* )($ (* )($ (* )($ (* )(a, b), c), d), e))
21
21
@test toexpr (a+ b+ c+ d+ e) == :($ (+ )($ (+ )($ (+ )($ (+ )(a, b), c), d), e))
22
22
@test toexpr (a+ b) == :($ (+ )(a, b))
23
- @test toexpr (a^ b) == :($ (^ )(a, b))
24
- @test toexpr (a^ 2 ) == :($ (^ )(a, 2 ))
25
- @test toexpr (a^- 2 ) == :($ (/ )(1 , $ (^ )(a, 2 )))
26
23
@test toexpr (x (t)+ y (t)) == :($ (+ )(x (t), y (t)))
27
24
@test toexpr (x (t)+ y (t)+ x (t+ 1 )) == :($ (+ )($ (+ )(x (t), y (t)), x ($ (+ )(1 , t))))
28
25
s = LazyState ()
@@ -87,8 +84,35 @@ nanmath_st.rewrites[:nanmath] = true
87
84
end )
88
85
@test toexpr (SetArray (true , a, [x (t), AtIndex (9 , b), c])). head == :macrocall
89
86
87
+ for fname in (:sin , :cos , :tan , :asin , :acos , :acosh , :atanh , :log , :log2 , :log10 , :log1p , :sqrt )
88
+ f = getproperty (Base, fname)
89
+ @test toexpr (f (a)) == :($ f (a))
90
+ @test toexpr (f (a), nanmath_st) == :($ (GlobalRef (NaNMath, fname))(a))
90
91
92
+ nanmath_f = getproperty (NaNMath, fname)
93
+ @test toexpr (nanmath_f (a)) == :($ nanmath_f (a))
94
+ @test toexpr (nanmath_f (a), nanmath_st) == :($ nanmath_f (a))
95
+ end
96
+
97
+ @test toexpr (a^ b) == :($ (^ )(a, b))
98
+ @test toexpr (a^ b, nanmath_st) == :($ (NaNMath. pow)(a, b))
91
99
@test toexpr (NaNMath. pow (a, b)) == :($ (NaNMath. pow)(a, b))
100
+ @test toexpr (NaNMath. pow (a, b), nanmath_st) == :($ (NaNMath. pow)(a, b))
101
+
102
+ @test toexpr (a^ 2 ) == :($ (^ )(a, 2 ))
103
+ @test toexpr (a^ 2 , nanmath_st) == :($ (NaNMath. pow)(a, 2 ))
104
+ @test toexpr (NaNMath. pow (a, 2 )) == :($ (NaNMath. pow)(a, 2 ))
105
+ @test toexpr (NaNMath. pow (a, 2 ), nanmath_st) == :($ (NaNMath. pow)(a, 2 ))
106
+
107
+ @test toexpr (a^- 1 ) == :($ (/ )(1 , a))
108
+ @test toexpr (a^- 1 , nanmath_st) == :($ (/ )(1 , a))
109
+ @test toexpr (NaNMath. pow (a, - 1 )) == :($ (NaNMath. pow)(a, - 1 ))
110
+ @test toexpr (NaNMath. pow (a, - 1 ), nanmath_st) == :($ (NaNMath. pow)(a, - 1 ))
111
+
112
+ @test toexpr (a^- 2 ) == :($ (/ )(1 , $ (^ )(a, 2 )))
113
+ @test toexpr (a^- 2 , nanmath_st) == :($ (/ )(1 , $ (NaNMath. pow)(a, 2 )))
114
+ @test toexpr (NaNMath. pow (a, - 2 )) == :($ (NaNMath. pow)(a, - 2 ))
115
+ @test toexpr (NaNMath. pow (a, - 2 ), nanmath_st) == :($ (NaNMath. pow)(a, - 2 ))
92
116
93
117
f = GlobalRef (NaNMath, :sin )
94
118
test_repr (toexpr (LiteralExpr (:(let x= 1 , y= 2
0 commit comments