aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-18 21:32:43 +0800
committerchriseth <chris@ethereum.org>2018-02-07 05:51:30 +0800
commitf7392cc6983a48ab0d482270912bd5de4042e577 (patch)
tree16ee68691ccb788b4eb6f98ec3fe640f69e7fe60 /test
parent65c31ecaeb66e186a0ab6aa6cb2c44ec1a35a868 (diff)
downloaddexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar.gz
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar.bz2
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar.lz
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar.xz
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.tar.zst
dexon-solidity-f7392cc6983a48ab0d482270912bd5de4042e577.zip
Tests.
Diffstat (limited to 'test')
-rw-r--r--test/libjulia/Simplifier.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/libjulia/Simplifier.cpp b/test/libjulia/Simplifier.cpp
index 83cc7687..dc3a0485 100644
--- a/test/libjulia/Simplifier.cpp
+++ b/test/libjulia/Simplifier.cpp
@@ -63,4 +63,44 @@ BOOST_AUTO_TEST_CASE(constants)
);
}
+BOOST_AUTO_TEST_CASE(invariant)
+{
+ CHECK(
+ "{ let a := mload(sub(7, 7)) let b := sub(a, 0) }",
+ "{ let a := mload(0) let b := a }"
+ );
+}
+
+BOOST_AUTO_TEST_CASE(reversed)
+{
+ CHECK(
+ "{ let a := add(0, mload(0)) }",
+ "{ let a := mload(0) }"
+ );
+}
+
+BOOST_AUTO_TEST_CASE(constant_propagation)
+{
+ CHECK(
+ "{ let a := add(7, sub(mload(0), 7)) }",
+ "{ let a := mload(0) }"
+ );
+}
+
+BOOST_AUTO_TEST_CASE(including_function_calls)
+{
+ CHECK(
+ "{ function f() -> a {} let b := add(7, sub(f(), 7)) }",
+ "{ function f() -> a {} let b := f() }"
+ );
+}
+
+BOOST_AUTO_TEST_CASE(inside_for)
+{
+ CHECK(
+ "{ for { let a := 10 } iszero(eq(a, 0)) { a := add(a, 1) } {} }",
+ "{ for { let a := 10 } iszero(iszero(a)) { a := add(a, 1) } {} }"
+ );
+}
+
BOOST_AUTO_TEST_SUITE_END()