Skip to content

Commit

Permalink
new desugar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Jul 12, 2023
1 parent f613690 commit ed9643b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/fail-typecheck/repro-duplicated-var.egg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function f (i64) i64)
;; the let's y should fail checking
(rule ((= x 1) (= y x)) ((let y (f 1)) (set (f 0) 0)))
2 changes: 2 additions & 0 deletions tests/repro-constraineq.egg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(rule ((= x 1) (= y x) (= z y)) ())
(run 1)
2 changes: 2 additions & 0 deletions tests/repro-constraineq2.egg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(rule ((= x 1) (= y x)) ())
(run 1)
40 changes: 40 additions & 0 deletions tests/repro-desugar-143.egg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
;; To test on issue #143
(rule ((= x 1) (= y x)) ())
(rule ((= x 1) (= y x) (= z y)) ())

(function f (i64) i64)

(set (f 0) 0)

;; a funky id rule
(rule ((f x) (= x y) (= z y)) ((let a (f z)) (set (f (+ z 1)) (+ a 1))))

(run 20)

(print-table f)
(check (= (f 10) 10))

(datatype Value (Num i64))
(function fib (Value) Value)

;; a funky fibonacci that test on more complex case and user defined datatype
(rule ((= (Num a) (fib (Num x)))
(= (Num b) (fib (Num y)))
(= x1 x)
(= y1 y)
(= a1 a)
(= b1 b)
(= x1 x2)
(= y1 y2)
(= a1 a2)
(= b1 b2)
(= 1 (- x2 y2)))
((let n (+ x 1)) (let sum (+ a1 b2)) (set (fib (Num n)) (Num sum))))

(set (fib (Num 1)) (Num 1))
(set (fib (Num 2)) (Num 1))

(run 20)

(print-table fib)
(check (= (fib (Num 10)) (Num 55)))

0 comments on commit ed9643b

Please sign in to comment.