mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-20 09:57:49 +03:00
67a6eb5d4c
+ Add file test/system.carp to test open-file + Update test/regression.carp with the new interface for IO.read->EOF
49 lines
1.3 KiB
Plaintext
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")
|
|
)
|