Skip to content

Commit

Permalink
extracted correctness tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eriksvedang committed Jul 1, 2016
1 parent c600890 commit 0dac8da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
20 changes: 0 additions & 20 deletions examples/project.carp
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,5 @@
;; :c {:x 300}}


(defstruct Blergh [x :int])

(defn x2 [x]
(* x 2))

(defn double-blergh [b]
(Blergh-update-x b x2))

(def x (Blergh 123))
;;(bake x)

(println (str (double-blergh x)))
(println (str (double-blergh x)))
(println (str (double-blergh x)))


(def stuff [1 2 3 4 5])
(defn map-stuff [x] (map inc x))
(bake map-stuff)
(println (str (map-stuff stuff)))
(println (str (map-stuff stuff)))
(println (str (map-stuff stuff)))
1 change: 1 addition & 0 deletions lisp/compiler_tests.carp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(load-lisp (str carp-dir "lisp/test_printing.carp"))
(load-lisp (str carp-dir "lisp/test_baking.carp"))
(load-lisp (str carp-dir "lisp/test_generics.carp"))
(load-lisp (str carp-dir "lisp/test_correctness.carp"))

;; These tests are for manual inspections:
(load-lisp (str carp-dir "lisp/test_stack_trace.carp"))
Expand Down
22 changes: 22 additions & 0 deletions lisp/test_correctness.carp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(tester/set-suite! "correctness")

(deftest test-mutate-global-struct
(do (defstruct Blergh [x :int])
(defn x2 [x]
(* x 2))
(defn double-blergh [b]
(Blergh-update-x b x2))
(def x (Blergh 123))
(assert-eq "(Blergh 246)" (str (double-blergh x)))
(assert-eq "(Blergh 246)" (str (double-blergh x)))
(assert-eq "(Blergh 246)" (str (double-blergh x)))))

(deftest test-mutate-global-array
(do (def stuff [1 2 3 4 5])
(defn map-stuff [x] (map inc x))
(bake map-stuff)
(assert-eq "[1 2 3 4 5]" (str (map-stuff stuff)))
(assert-eq "[1 2 3 4 5]" (str (map-stuff stuff)))
(assert-eq "[1 2 3 4 5]" (str (map-stuff stuff)))))

(tester/run-suite "correctness")

0 comments on commit 0dac8da

Please sign in to comment.