File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,8 @@ function makeconsequent(expr)
163163 else
164164 return Expr (expr. head, map (makeconsequent, expr. args)... )
165165 end
166+ elseif expr=== :(~ )
167+ return :(__MATCHES__)
166168 else
167169 # treat as a literal
168170 return esc (expr)
Original file line number Diff line number Diff line change 8282 @test r_mix ((a + b)) === 2 # 1+1
8383end
8484
85+ @testset " Return the matches dictionary" begin
86+ r = @rule (~ x + (~ y)^ 2 ) => ~
87+ res = r (a + b^ 2 )
88+ @test isa (res, Base. ImmutableDict)
89+ @test res[:x ] === a
90+ @test res[:y ] === b
91+
92+ r2 = @rule (~ x + (~ y)^ (~ m)) => (~ ) where ~ m=== 2
93+ @test isa (r2 (a + b^ 2 ), Base. ImmutableDict)
94+ @test r2 (a + b^ 3 )=== nothing
95+
96+ r3 = @rule (~ x + (~ y)^ (~ m)) => ~ m=== 2 ? (~ ) : ~ x
97+ @test isa (r3 (a + b^ 2 ), Base. ImmutableDict)
98+ @test r3 (a + b^ 3 )=== a
99+ end
100+
85101using SymbolicUtils: @capture
86102
87103@testset " Capture form" begin
You can’t perform that action at this time.
0 commit comments