Carp/test/regression.carp
sdilts 67a6eb5d4c Add and update tests for open-file
+ Add file test/system.carp to test open-file
+ Update test/regression.carp with the new interface for IO.read->EOF
2019-11-08 17:20:05 -07:00

49 lines
1.3 KiB
Plaintext

(relative-include "fixture_foo.h")
(load "Test.carp")
(load "Vector.carp")
; this is a test-only module to test module resolution (see #288)
(defmodule Foo
(register init (Fn [] Int) "fooInit")
)
; test whether sumtypes with single cases get classified correctly
(deftype (SumT x)
(SingleC [x]))
; make sure nested lambdas don't break again (issue #342)
(defn nested-lambdas []
(let [f (fn [x] ((fn [y] (+ x y))
1))]
(f 1)))
(use-all Test Vector2 Foo)
(deftest test
(assert-equal test
1
(init)
"test that the right module gets resolved")
(assert-equal test
\\
(String.char-at "\\" 0)
"test that strings get escaped correctly")
(assert-equal test
Int.MAX
@&Int.MAX
"test that the address of Int.MAX can be taken")
(assert-equal test
&(Result.Error System.ENOENT)
&(IO.read->EOF "foobar")
"test that reading from an undefined file works")
(assert-equal test
"(SingleC 1)"
&(str &(SumT.SingleC 1))
"test that sumtypes with single cases work")
(assert-equal test
2
(nested-lambdas)
"test that nested lambdas can use captured values")
)