aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbenjaminion <ben@edginet.org>2017-07-01 21:19:41 +0800
committerbenjaminion <ben@edginet.org>2017-07-09 02:55:41 +0800
commite3c58eada6e7309ddbb7a460e0cd81e92dbd8c57 (patch)
treec0276f49be7884fd54ee935089db047acf76a8d8 /test
parentf129372245d1b4fd4ff6425e9f7cbe701247cdc1 (diff)
downloaddexon-solidity-e3c58eada6e7309ddbb7a460e0cd81e92dbd8c57.tar.gz
dexon-solidity-e3c58eada6e7309ddbb7a460e0cd81e92dbd8c57.tar.zst
dexon-solidity-e3c58eada6e7309ddbb7a460e0cd81e92dbd8c57.zip
Test cases for for and while loops.
Diffstat (limited to 'test')
-rw-r--r--test/liblll/EndToEndTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp
index f3bfb438..7f4dd91a 100644
--- a/test/liblll/EndToEndTest.cpp
+++ b/test/liblll/EndToEndTest.cpp
@@ -387,6 +387,37 @@ BOOST_AUTO_TEST_CASE(assembly_codecopy)
BOOST_CHECK(callFallback() == encodeArgs(string("abcdef")));
}
+BOOST_AUTO_TEST_CASE(for_loop)
+{
+ char const* sourceCode = R"(
+ (returnlll
+ (seq
+ (for
+ { (set 'i 1) (set 'j 1) } ; INIT
+ (<= @i 10) ; PRED
+ [i]:(+ @i 1) ; POST
+ [j]:(* @j @i)) ; BODY
+ (return j 0x20)))
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callFallback() == encodeArgs(u256(3628800))); // 10!
+}
+
+BOOST_AUTO_TEST_CASE(while_loop)
+{
+ char const* sourceCode = R"(
+ (returnlll
+ (seq
+ ;; Euclid's GCD algorithm
+ (set 'a 1071)
+ (set 'b 462)
+ (while @b
+ [a]:(raw @b [b]:(mod @a @b)))
+ (return a 0x20)))
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callFallback() == encodeArgs(u256(21))); // GCD(1071,462)
+}
BOOST_AUTO_TEST_CASE(keccak256_32bytes)
{