aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-11-29 22:56:51 +0800
committerchriseth <chris@ethereum.org>2018-12-01 06:39:05 +0800
commit1cdcdcee656c080b8c6f9e2631bcc2a3c35fb13b (patch)
tree3666bb1aba17840496a40df8764406e874020f32 /test
parent0d1b9c3b1bbfcc4ca61d35049f1c3624681dbb13 (diff)
downloaddexon-solidity-1cdcdcee656c080b8c6f9e2631bcc2a3c35fb13b.tar.gz
dexon-solidity-1cdcdcee656c080b8c6f9e2631bcc2a3c35fb13b.tar.zst
dexon-solidity-1cdcdcee656c080b8c6f9e2631bcc2a3c35fb13b.zip
Improves assembly output commandline tests.
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 9dfbe409..fdc9fbe3 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -262,6 +262,25 @@ SOLTMPDIR=$(mktemp -d)
)
rm -rf "$SOLTMPDIR"
+test_solc_assembly_output() {
+ local input="${1}"
+ local expected="${2}"
+ local solc_args="${3}"
+
+ local expected_object="object \"object\" { code "${expected}" }"
+
+ output=$(echo "${input}" | "$SOLC" - ${solc_args} 2>/dev/null)
+ empty=$(echo $output | sed -ne '/'"${expected_object}"'/p')
+ if [ -z "$empty" ]
+ then
+ printError "Incorrect assembly output. Expected: "
+ echo -e ${expected}
+ printError "with arguments ${solc_args}, but got:"
+ echo "${output}"
+ exit 1
+ fi
+}
+
printTask "Testing assemble, yul, strict-assembly and optimize..."
(
echo '{}' | "$SOLC" - --assemble &>/dev/null
@@ -271,8 +290,15 @@ printTask "Testing assemble, yul, strict-assembly and optimize..."
# Test options above in conjunction with --optimize.
# Using both, --assemble and --optimize should fail.
! echo '{}' | "$SOLC" - --assemble --optimize &>/dev/null
- echo '{}' | "$SOLC" - --yul --optimize &>/dev/null
- echo '{}' | "$SOLC" - --strict-assembly --optimize &>/dev/null
+
+ # Test yul and strict assembly output
+ # Non-empty code results in non-empty binary representation with optimizations turned off,
+ # while it results in empty binary representation with optimizations turned on.
+ test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ let x:u256 := 0:u256 }" "--yul"
+ test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ }" "--yul --optimize"
+
+ test_solc_assembly_output "{ let x := 0 }" "{ let x := 0 }" "--strict-assembly"
+ test_solc_assembly_output "{ let x := 0 }" "{ }" "--strict-assembly --optimize"
)