forked from bakpakin/Fennel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for bitops; tweak docstrings a bit.
- Loading branch information
1 parent
c965f85
commit 0ad2691
Showing
5 changed files
with
62 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(local l (require :test.luaunit)) | ||
(local fennel (require :fennel)) | ||
|
||
(fn == [test expected] | ||
(let [opts (if (rawget _G :jit) | ||
{:useBitLib true} | ||
(and (not= _VERSION "Lua 5.1") (not= _VERSION "Lua 5.2")) | ||
{})] | ||
;; skip the test on PUC 5.1 and 5.2 | ||
(when opts | ||
(l.assertEquals (fennel.eval test opts) expected)))) | ||
|
||
(fn test-shifts [] | ||
(== "(lshift 33 2)" 132) | ||
(== "(lshift 1)" 2) | ||
(== "(rshift 33 2)" 8) | ||
(let [(ok? msg) (pcall fennel.compileString "(lshift)")] | ||
(l.assertFalse ok?) | ||
(l.assertStrContains msg "Expected more than 0 arguments"))) | ||
|
||
(fn test-ops [] | ||
(== "(band 22 13)" 4) | ||
(== "(bor 1 2 4 8)" 15) | ||
(== "(bxor 1)" 1) | ||
(== "(band)" 0)) | ||
|
||
{: test-shifts | ||
: test-ops} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters