aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-03 18:52:48 +0800
committerGitHub <noreply@github.com>2018-12-03 18:52:48 +0800
commit4b98946e5a6cbc477ca5c61ca0a0dc8c2d1b27ca (patch)
treebf3b21164feeb37fbb2a48ecef1f13c4c67be7fb /test
parent04d946669e70be680e7897dcbf2d4e3b6747cc22 (diff)
parent1cdcdcee656c080b8c6f9e2631bcc2a3c35fb13b (diff)
downloaddexon-solidity-4b98946e5a6cbc477ca5c61ca0a0dc8c2d1b27ca.tar.gz
dexon-solidity-4b98946e5a6cbc477ca5c61ca0a0dc8c2d1b27ca.tar.zst
dexon-solidity-4b98946e5a6cbc477ca5c61ca0a0dc8c2d1b27ca.zip
Merge pull request #5341 from ethereum/optimizeAssemblyCommandline
Apply the optimize commandline parameter to assembly mode.
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh43
1 files changed, 39 insertions, 4 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 4838d088..fdc9fbe3 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -262,10 +262,45 @@ SOLTMPDIR=$(mktemp -d)
)
rm -rf "$SOLTMPDIR"
-printTask "Testing assemble, yul, strict-assembly..."
-echo '{}' | "$SOLC" - --assemble &>/dev/null
-echo '{}' | "$SOLC" - --yul &>/dev/null
-echo '{}' | "$SOLC" - --strict-assembly &>/dev/null
+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
+ echo '{}' | "$SOLC" - --yul &>/dev/null
+ echo '{}' | "$SOLC" - --strict-assembly &>/dev/null
+
+ # Test options above in conjunction with --optimize.
+ # Using both, --assemble and --optimize should fail.
+ ! echo '{}' | "$SOLC" - --assemble --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"
+)
+
printTask "Testing standard input..."
SOLTMPDIR=$(mktemp -d)