aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-09 03:36:57 +0800
committerGitHub <noreply@github.com>2018-08-09 03:36:57 +0800
commitd634d20b5b0dac3e5caf1741073fa123fdd56ab9 (patch)
treee88008bc8a8e665d32d8ac8c9125595dd90e8a22 /test/libsolidity/syntaxTests
parent551343ae3eb1b3f1575d91a4f7021c0f9529d5bd (diff)
parentb9222808f61e00833f8c11cd196cafb50ec9e1b9 (diff)
downloaddexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar.gz
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar.bz2
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar.lz
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar.xz
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.tar.zst
dexon-solidity-d634d20b5b0dac3e5caf1741073fa123fdd56ab9.zip
Merge pull request #4684 from ethereum/underscores_in_numeric_literals
[BREAKING] Underscores in numeric literals
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol17
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol7
6 files changed, 72 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol
new file mode 100644
index 00000000..d4d3299f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ uint d1 = 654_321;
+ uint d2 = 54_321;
+ uint d3 = 4_321;
+ uint d4 = 5_43_21;
+ uint d5 = 1_2e10;
+ uint d6 = 12e1_0;
+
+ d1; d2; d3; d4; d5; d6;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol
new file mode 100644
index 00000000..8978996d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ uint D1 = 1234_;
+ uint D2 = 12__34;
+ uint D3 = 12_e34;
+ uint D4 = 12e_34;
+ }
+}
+// ----
+// SyntaxError: (56-61): Invalid use of underscores in number literal. No trailing underscores allowed.
+// SyntaxError: (77-83): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed.
+// SyntaxError: (99-105): Invalid use of underscores in number literal. No underscore at the end of the mantissa allowed.
+// SyntaxError: (121-127): Invalid use of underscores in number literal. No underscore in front of exponent allowed.
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol
new file mode 100644
index 00000000..4910ee82
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ fixed f1 = 3.14_15;
+ fixed f2 = 3_1.4_15;
+
+ f1; f2;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol
new file mode 100644
index 00000000..3b91895d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol
@@ -0,0 +1,17 @@
+contract C {
+ function f() public pure {
+ fixed F1 = 3.1415_;
+ fixed F2 = 3__1.4__15;
+ fixed F3 = 1_.2;
+ fixed F4 = 1._2;
+ fixed F5 = 1.2e_12;
+ fixed F6 = 1._;
+ }
+}
+// ----
+// SyntaxError: (57-64): Invalid use of underscores in number literal. No trailing underscores allowed.
+// SyntaxError: (81-91): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed.
+// SyntaxError: (108-112): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.
+// SyntaxError: (129-133): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.
+// SyntaxError: (150-157): Invalid use of underscores in number literal. No underscore in front of exponent allowed.
+// SyntaxError: (174-177): Invalid use of underscores in number literal. No trailing underscores allowed.
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol
new file mode 100644
index 00000000..999a4634
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ uint x1 = 0x8765_4321;
+ uint x2 = 0x765_4321;
+ uint x3 = 0x65_4321;
+ uint x4 = 0x5_4321;
+ uint x5 = 0x123_1234_1234_1234;
+ uint x6 = 0x123456_1234_1234;
+
+ x1; x2; x3; x4; x5; x6;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol
new file mode 100644
index 00000000..a8a488c1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ uint X1 = 0x1234__1234__1234__123;
+ }
+}
+// ----
+// SyntaxError: (56-79): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed.