aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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"
)