Add tests

This commit is contained in:
chriseth 2020-02-06 19:44:14 +01:00
parent 9140bc52c4
commit 2ee748b7f5
11 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,12 @@
{
let x:u256
let y := x
let z:bool
z := y
y := z
}
// ====
// dialect: evmTyped
// ----
// TypeError: (51-52): Assigning a value of type "u256" to a variable of type "bool".
// TypeError: (62-63): Assigning a value of type "bool" to a variable of type "u256".

View File

@ -0,0 +1,7 @@
{
let x:bool
for {} x {} {}
}
// ====
// dialect: evmTyped
// ----

View File

@ -0,0 +1,8 @@
{
let x
for {} x {} {}
}
// ====
// dialect: evmTyped
// ----
// TypeError: (23-24): Expected a value of boolean type "bool" but got "u256"

View File

@ -0,0 +1,8 @@
{
let x
for {} x {} {}
}
// ====
// dialect: ewasm
// ----
// TypeError: (23-24): Expected a value of boolean type "i32" but got "i64"

View File

@ -0,0 +1,8 @@
{
switch 7:i64
case 0:i64 {}
case 2:i64 {}
}
// ====
// dialect: ewasm
// ----

View File

@ -0,0 +1,10 @@
{
switch 7:i32
case 0:i64 {}
case 2:i64 {}
}
// ====
// dialect: ewasm
// ----
// TypeError: (28-33): Expected a value of type "i32" but got "i64"
// TypeError: (46-51): Expected a value of type "i32" but got "i64"

View File

@ -0,0 +1,10 @@
{
switch 7
case true:bool {}
case true:bool {}
}
// ====
// dialect: evmTyped
// ----
// TypeError: (24-33): Expected a value of type "u256" but got "bool"
// TypeError: (46-55): Expected a value of type "u256" but got "bool"

View File

@ -0,0 +1,7 @@
{
let x:i32
if x {}
}
// ====
// dialect: ewasm
// ----

View File

@ -0,0 +1,8 @@
{
let x:i64
if x {}
}
// ====
// dialect: ewasm
// ----
// TypeError: (23-24): Expected a value of boolean type "i32" but got "i64"

View File

@ -0,0 +1,12 @@
{
function f(a:u256, b:u256, c:bool) -> r:bool, t {
r := lt(a, b)
t := bool_to_u256(not(c))
}
let x, y: bool := f(1, 2: u256, true)
}
// ====
// dialect: evmTyped
// ----
// TypeError: (126-127): Assigning value of type "bool" to variable of type "u256.
// TypeError: (129-136): Assigning value of type "u256" to variable of type "bool.

View File

@ -0,0 +1,10 @@
{
function f(a:u256, b:u256, c:bool) -> r:bool, t {
r := lt(a, b)
t := bool_to_u256(not(c))
}
let x: bool, y: u256 := f(1, 2: u256, true)
}
// ====
// dialect: evmTyped
// ----