From 2c5985de06b4ad35eaa77f3869e280440100c9cd Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 21 Aug 2017 12:08:29 +0200 Subject: Be more strict about number literals in assembly. --- test/libjulia/Parser.cpp | 8 ++++++++ test/libsolidity/InlineAssembly.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'test') diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index dd6f3d94..e1bf5a3a 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -214,6 +214,14 @@ BOOST_AUTO_TEST_CASE(invalid_types) CHECK_ERROR("{ function f(a:invalid) {} }", TypeError, "\"invalid\" is not a valid type (user defined types are not yet supported)."); } +BOOST_AUTO_TEST_CASE(number_literals) +{ + BOOST_CHECK(successParse("{ let x:u256 := 1:u256 }")); + CHECK_ERROR("{ let x:u256 := .1:u256 }", ParserError, "Invalid number literal."); + CHECK_ERROR("{ let x:u256 := 1e5:u256 }", ParserError, "Invalid number literal."); + CHECK_ERROR("{ let x:u256 := 67.235:u256 }", ParserError, "Invalid number literal."); +} + BOOST_AUTO_TEST_CASE(builtin_types) { BOOST_CHECK(successParse("{ let x:bool := true:bool }")); diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 4bf4eb48..8e1c304a 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -339,6 +339,14 @@ BOOST_AUTO_TEST_CASE(blocks) BOOST_CHECK(successParse("{ let x := 7 { let y := 3 } { let z := 2 } }")); } +BOOST_AUTO_TEST_CASE(number_literals) +{ + BOOST_CHECK(successParse("{ let x := 1 }")); + CHECK_PARSE_ERROR("{ let x := .1 }", ParserError, "Invalid number literal."); + CHECK_PARSE_ERROR("{ let x := 1e5 }", ParserError, "Invalid number literal."); + CHECK_PARSE_ERROR("{ let x := 67.235 }", ParserError, "Invalid number literal."); +} + BOOST_AUTO_TEST_CASE(function_definitions) { BOOST_CHECK(successParse("{ function f() { } function g(a) -> x { } }")); -- cgit