Skip to content

Commit

Permalink
adds more tests for flexarray etc. (#60)
Browse files Browse the repository at this point in the history
* adds more tests for flexarray etc.

* improve tests

* adds `nifcache/` to .gitignore
  • Loading branch information
ringabout authored Sep 12, 2024
1 parent a4852cf commit e3d6794
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
nimcache/
nimblecache/
htmldocs/
*.exe
*.exe
nifcache/
39 changes: 36 additions & 3 deletions tests/nifc/hello.expected.idx.nif
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,40 @@
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv printf.c +48)
(kv f.1 +24)
(kv main.c +60))
(kv foo.c +36)
(kv foo2.c +85)
(kv x.c +32)
(kv MyObject.ptr.flexarray +105)
(kv a1 +47)
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv MyObject.flexarray +49)
(kv a1 +43)
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv MyObject.ptr +46)
(kv a1 +37)
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv MyObject.aptr +40)
(kv a1 +38)
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv MyObject.ptr.object +41)
(kv a1 +44)
(kv a2 +27)
(kv a3 +31)
(kv a4 +25)
(kv MyObject.my.sequence +44)
(kv len +46)
(kv p +26)
(kv MyObject.sequence.base +54)
(kv cap +49)
(kv data +28)
(kv main.c +47)
(kv x.c +42))
)
69 changes: 67 additions & 2 deletions tests/nifc/hello.nif
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,76 @@
)
)

(proc :foo.c . (void) . (stmts
(call printf.c "foo %s" "abc")
))

(nodecl (proc :foo2.c . (void) . (stmts
(var :x.c . (i +32 .) +12)
(call printf.c "foo %s" "abc")
(call printf.c "foo %d" x.c)
)))

(type :MyObject.ptr.flexarray .
(object . (fld :a1 . (i +32 atomic))
(fld :a2 . (i +64 atomic))
(fld :a3 . (bool .))
(fld :a4 . (ptr MyObject.flexarray))
)
)

(type :MyObject.flexarray .
(object . (fld :a1 . (i +32 atomic))
(fld :a2 . (i +64 atomic))
(fld :a3 . (bool .))
(fld :a4 . (flexarray (i +64 .)))
)
)

(type :MyObject.ptr .
(object . (fld :a1 . (i +32 atomic))
(fld :a2 . (i +64 atomic))
(fld :a3 . (bool .))
(fld :a4 . (ptr (i +64 .)))
)
)

(type :MyObject.aptr .
(object . (fld :a1 . (i +32 atomic))
(fld :a2 . (i +64 atomic))
(fld :a3 . (bool .))
(fld :a4 . (aptr (i +64 .)))
)
)

(type :MyObject.ptr.object .
(object . (fld :a1 . (i +32 atomic))
(fld :a2 . (i +64 atomic))
(fld :a3 . (bool .))
(fld :a4 . (ptr MyObject3.m .))
)
)


(type :MyObject.my.sequence .
(object .
(fld :len . (i -1 .))
(fld :p . (ptr MyObject.sequence.base .))
)
)

(type :MyObject.sequence.base .
(object .
(fld :cap . (i -1 .))
(fld :data . (flexarray (i +64 .)))
))

(nodecl (proc :printf.c (params (param :f.1 . (ptr FILE.c))) (void) (pragmas (varargs)) .))
(proc :main.c . (i -1 +90) . (stmts
(proc :main.c . (i -1 atomic) . (stmts
(var :x.c . (i +32 .) +12)
(call printf.c "hello %s" "abc")
(call printf.c "hello %d" (suf +12 "i64"))
(call printf.c "hello %d" x.c)
(call foo.c)
(ret +0)
))
)
4 changes: 3 additions & 1 deletion tests/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ proc testNifc(overwrite: bool) =
let t1 = "tests/nifc/selectany/t1.nif"
let t2 = "tests/nifc/selectany/t2.nif"
let t3 = "tests/nifc/selectany/t3.nif"
exec ("src" / "nifc" / "nifc").addFileExt(ExeExt) & " c" & " " & t1 & " " & t2 & " " & t3
exec ("src" / "nifc" / "nifc").addFileExt(ExeExt) & " c " & t1 & " " & t2 & " " & t3
let hello = "tests/nifc/hello.nif"
exec ("src" / "nifc" / "nifc").addFileExt(ExeExt) & " c " & hello

testNifc(overwrite)

0 comments on commit e3d6794

Please sign in to comment.