aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-15 18:30:54 +0800
committerGitHub <noreply@github.com>2018-08-15 18:30:54 +0800
commitc7d2af2637e061de43cc6c53e12bf35d1ac66387 (patch)
treecd486c80ba40b74e8ea5a688101b879d15ddca69 /test
parentb9752b236b474e384a297fe832cf0efb161e8deb (diff)
parent55e67e41f9356e4953a57d8a15808e1c7d391686 (diff)
downloaddexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar.gz
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar.bz2
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar.lz
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar.xz
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.tar.zst
dexon-solidity-c7d2af2637e061de43cc6c53e12bf35d1ac66387.zip
Merge pull request #4583 from ethereum/nested_array_library_changelog
Bugfix Changelog entry regarding nested arrays returned by library functions
Diffstat (limited to 'test')
-rwxr-xr-xtest/buglistTests.js45
-rw-r--r--test/buglist_test_vectors.md69
2 files changed, 114 insertions, 0 deletions
diff --git a/test/buglistTests.js b/test/buglistTests.js
new file mode 100755
index 00000000..6b7df2f2
--- /dev/null
+++ b/test/buglistTests.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var fs = require('fs')
+var bugs = JSON.parse(fs.readFileSync(__dirname + '/../docs/bugs.json', 'utf8'))
+
+var bugsByName = {}
+for (var i in bugs)
+{
+ if (bugs[i].name in bugsByName)
+ {
+ throw "Duplicate bug name: " + bugs[i].name
+ }
+ bugsByName[bugs[i].name] = bugs[i]
+}
+
+var tests = fs.readFileSync(__dirname + '/buglist_test_vectors.md', 'utf8')
+
+var testVectorParser = /\s*#\s+(\S+)\s+## buggy\n([^#]*)## fine\n([^#]*)/g
+
+var result;
+while ((result = testVectorParser.exec(tests)) !== null)
+{
+ var name = result[1]
+ var buggy = result[2].split('\n--\n')
+ var fine = result[3].split('\n--\n')
+ console.log("Testing " + name + " with " + buggy.length + " buggy and " + fine.length + " fine instances")
+
+ var regex = RegExp(bugsByName[name].check['regex-source'])
+ for (var i in buggy)
+ {
+ if (!regex.exec(buggy[i]))
+ {
+ throw "Bug " + name + ": Buggy source does not match: " + buggy[i]
+ }
+ }
+ for (var i in fine)
+ {
+ if (regex.exec(fine[i]))
+ {
+ throw "Bug " + name + ": Non-buggy source matches: " + fine[i]
+ }
+ }
+}
diff --git a/test/buglist_test_vectors.md b/test/buglist_test_vectors.md
new file mode 100644
index 00000000..ce95403b
--- /dev/null
+++ b/test/buglist_test_vectors.md
@@ -0,0 +1,69 @@
+# NestedArrayFunctionCallDecoder
+
+## buggy
+
+function f() pure returns (uint[2][2]) { }
+
+--
+
+function f() returns (uint[2][2] a) { }
+
+--
+
+function f() returns (uint x, uint[200][2] a) { }
+
+--
+
+function f() returns (uint[200][2] a, uint x) { }
+
+--
+
+function f() returns (uint[200][2] a, uint x);
+
+--
+
+function f() returns (
+ uint
+ [
+ 200
+ ]
+ [2]
+ a, uint x);
+
+--
+
+function f() returns (
+ uint
+ [
+ ContractName.ConstantName
+ ]
+ [2]
+ a, uint x);
+
+## fine
+
+function f() returns (uint[2]) { }
+
+--
+
+function f() public pure returns (uint[2][] a) { }
+
+--
+
+function f() public pure returns (uint[ 2 ] [ ] a) { }
+
+--
+
+function f() public pure returns (uint x, uint[] a) { }
+
+--
+
+function f(uint[2][2]) { }
+
+--
+
+function f() m(uint[2][2]) { }
+
+--
+
+function f() returns (uint, uint) { uint[2][2] memory x; }