Skip to content

Commit

Permalink
more reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmuth committed May 15, 2024
1 parent c2848ed commit bbd8a1f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
29 changes: 18 additions & 11 deletions FrontEnd/LangTest/assign_test.cw
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(module main [] :
(import test)


@pub (defrec type_rec1 :
@doc "this is a comment with \" with quotes \t "
(field i1 s64)
Expand All @@ -19,8 +20,7 @@
(field a3 (array 7 u32))
(field a4 (array 7 u64))
(field a5 (array 7 r32))
(field a6 (array 7 r64))
)
(field a6 (array 7 r64)))


@pub (defrec type_rec2 :
Expand All @@ -38,17 +38,24 @@
(field u6 u64))


(global! ga1 (array 5 s64) undef)
(global! ga1 (array 5 s64) undef)


(global! gr1 type_rec1 undef)


(global! gar1 (array 5 type_rec1) undef)


(global! gr2 type_rec2 undef)


(global! gar2 (array 5 type_rec2) undef)


(fun get_addr [] (ptr! type_rec1) :
(return (&! gr1))
)
(return (&! gr1)))


@cdecl (fun main [(param argc s32) (param argv (ptr (ptr u8)))] s32 :
@doc "a1 u32"
Expand All @@ -61,16 +68,16 @@
(test::AssertEq# (. gr1 i1) 0x8765432187654321_s64)
(+= (. gr1 i1) 0x1)
(test::AssertEq# (. gr1 i1) 0x8765432187654322_s64)
@doc "gr1 u64"
@doc "gr1 u64"
(= (. gr1 i2) 0x1234567812345678)
(test::AssertEq# (. gr1 i2) 0x1234567812345678_u64)
(-= (. gr1 i2) 0x1)
(test::AssertEq# (. gr1 i2) 0x1234567812345677_u64)
@doc "gr1 u64 via pointer"
@doc "gr1 u64 via pointer"
(= (. (^ (get_addr [])) i2) 0x1234567812345678)
(test::AssertEq# (. (^ (get_addr [])) i2) 0x1234567812345678_u64)
(-= (. (^ (get_addr [])) i2) 0x1)
(test::AssertEq# (. (^ (get_addr [])) i2) 0x1234567812345677_u64)
(-= (. (^ (get_addr [])) i2) 0x1)
(test::AssertEq# (. (^ (get_addr [])) i2) 0x1234567812345677_u64)
@doc "gar1 s64"
(= (. (at gar1 3) i1) 0x8765432187654321)
(test::AssertEq# (. (at gar1 3) i1) 0x8765432187654321_s64)
Expand All @@ -79,11 +86,11 @@
(test::AssertEq# (. (. gr2 t3) i1) 0x8765432187654321_s64)
(+= (. (. gr2 t3) i1) 0x1)
(test::AssertEq# (. (. gr2 t3) i1) 0x8765432187654322_s64)
@doc "gr2 u64"
@doc "gr2 u64"
(= (. (. gr2 t3) i2) 0x1234567812345678)
(test::AssertEq# (. (. gr2 t3) i2) 0x1234567812345678_u64)
@doc "test end"
(test::Success#)
(return 0))

)

14 changes: 8 additions & 6 deletions FrontEnd/LangTest/defer_test.cw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
@doc "defer"
@doc "defer"
(module main [] :
(import test)


(global! gIndex uint 0)
(global! gSequence auto (array_val 10 u8 [(index_val 0)]))


(global! gSequence auto (array_val 10 u8 [0]))


(fun store [(param c u8)] void :
(= (at gSequence gIndex) c)
(+= gIndex 1)
)
(+= gIndex 1))


(fun foo [] void :
(defer :
Expand All @@ -25,8 +27,7 @@
(defer :
(shed (store ['d'])))
(shed (store ['c'])))
(shed (store ['f']))
)
(shed (store ['f'])))


@cdecl (fun main [(param argc s32) (param argv (ptr (ptr u8)))] s32 :
Expand All @@ -36,3 +37,4 @@
(test::Success#)
(return 0))
)

20 changes: 11 additions & 9 deletions FrontEnd/LangTest/enum_test.cw
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
(module main [] :
(import test)


@pub (enum enum8 U8 :
(entry e1 7)
(entry e2)
(entry e3 19)
(entry e4))


@pub (enum enum16 U16 :
(entry e1 70)
(entry e2)
(entry e3 190)
(entry e4))


@pub (enum enum32 U32 :
(entry e1 700)
(entry e2)
(entry e3 1900)
(entry e4))


@doc "GLOBAL"
(global! g1 auto enum8:e1)


(global! g2 auto enum16:e2)


(global! g3 auto enum32:e3)


Expand All @@ -37,44 +45,38 @@
(field f8 u64)
(field f9 u64))


(global! gr1 rec1 undef)


@cdecl (fun main [(param argc s32) (param argv (ptr (ptr u8)))] s32 :
@doc "LOCAL"
(let! v1 auto enum8:e2)
(let! v2 auto enum16:e3)
(let! v3 auto enum32:e4)

(test::AssertEq# g1 enum8:e1)
(test::AssertEq# g2 enum16:e2)
(test::AssertEq# g3 enum32:e3)

(= g1 v1)
(= g2 v2)
(= g3 v3)

(test::AssertEq# g1 enum8:e2)
(test::AssertEq# g2 enum16:e3)
(test::AssertEq# g3 enum32:e4)

(= v1 enum8:e3)
(= v2 enum16:e4)
(= v3 enum32:e1)

(test::AssertEq# v1 enum8:e3)
(test::AssertEq# v2 enum16:e4)
(test::AssertEq# v3 enum32:e1)

(= (. gr1 f5) enum8:e3)
(= (. gr1 f6) enum16:e4)
(= (. gr1 f7) enum32:e1)

(test::AssertEq# (. gr1 f5) enum8:e3)
(test::AssertEq# (. gr1 f6) enum16:e4)
(test::AssertEq# (. gr1 f7) enum32:e1)

@doc "test end"
(test::Success#)
(return 0))
)

)
23 changes: 11 additions & 12 deletions FrontEnd/LangTest/expr_uint_test.cw
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@doc "expr"
@doc "expr"
(module main [] :
(import test)


(fun test_u64 [(param a u64) (param b u64)] void :
(test::AssertEq# (+ a b) 0x9999999999999999_u64)
(test::AssertEq# (- a b) 0x7530eca97530eca9_u64)
Expand Down Expand Up @@ -34,8 +35,8 @@
(test::AssertEq# (> a a) false)
(test::AssertEq# (>= a a) true)
(test::AssertEq# (== a a) true)
(test::AssertEq# (!= a a) false)
)
(test::AssertEq# (!= a a) false))


(fun test_u32 [(param a u32) (param b u32)] void :
(test::AssertEq# (+ a b) 0x99999999_u32)
Expand Down Expand Up @@ -72,8 +73,8 @@
(test::AssertEq# (> a a) false)
(test::AssertEq# (>= a a) true)
(test::AssertEq# (== a a) true)
(test::AssertEq# (!= a a) false)
)
(test::AssertEq# (!= a a) false))


(fun test_u16 [(param a u16) (param b u16)] void :
(test::AssertEq# (+ a b) 0x5555_u16)
Expand Down Expand Up @@ -110,8 +111,8 @@
(test::AssertEq# (> a a) false)
(test::AssertEq# (>= a a) true)
(test::AssertEq# (== a a) true)
(test::AssertEq# (!= a a) false)
)
(test::AssertEq# (!= a a) false))


(fun test_u8 [(param a u8) (param b u8)] void :
(test::AssertEq# (+ a b) 0xff_u8)
Expand Down Expand Up @@ -148,18 +149,16 @@
(test::AssertEq# (> a a) false)
(test::AssertEq# (>= a a) true)
(test::AssertEq# (== a a) true)
(test::AssertEq# (!= a a) false)
)
(test::AssertEq# (!= a a) false))


@cdecl (fun main [(param argc s32) (param argv (ptr (ptr u8)))] s32 :
(shed (test_u64 [0x8765432187654321 0x1234567812345678]))
(shed (test_u32 [0x87654321 0x12345678]))
(shed (test_u16 [0x4321 0x1234]))
(shed (test_u8 [0x87 0x78]))

@doc "test end"
(test::Success#)
(return 0))
)


)
1 change: 1 addition & 0 deletions FrontEnd/TestData/linked_list.cw
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@
(test::Success#)
(return 0))
)

0 comments on commit bbd8a1f

Please sign in to comment.