Add failing tests
This commit is contained in:
parent
0e154f96fa
commit
be7133dec7
@ -1194,6 +1194,66 @@ failing_contracts() ->
|
||||
<<?Pos(13,20)
|
||||
"Found a hole of type `'a`">>
|
||||
])
|
||||
, ?TYPE_ERROR(toplevel_constants_contract_as_namespace,
|
||||
[<<?Pos(5,13)
|
||||
"Invalid use of the contract constant `G.const`.\n"
|
||||
"Toplevel contract constants can only be used in the contracts where they are defined.">>,
|
||||
<<?Pos(10,11)
|
||||
"Record type `G` does not have field `const`">>,
|
||||
<<?Pos(10,11)
|
||||
"Unbound field const">>,
|
||||
<<?Pos(11,11)
|
||||
"Record type `G` does not have field `const`">>,
|
||||
<<?Pos(11,11)
|
||||
"Unbound field const">>
|
||||
])
|
||||
, ?TYPE_ERROR(toplevel_constants_cycles,
|
||||
[<<?Pos(2,21)
|
||||
"Unbound variable `selfcycle`">>,
|
||||
<<?Pos(4,5)
|
||||
"Mutual recursion detected between the constants\n"
|
||||
" - `cycle1` at line 4, column 5\n"
|
||||
" - `cycle2` at line 5, column 5\n"
|
||||
" - `cycle3` at line 6, column 5">>
|
||||
])
|
||||
, ?TYPE_ERROR(toplevel_constants_in_interface,
|
||||
[<<?Pos(2,10)
|
||||
"The name of the compile-time constant cannot have pattern matching nor type">>,
|
||||
<<?Pos(3,5)
|
||||
"Cannot define toplevel constants inside a contract interface">>,
|
||||
<<?Pos(4,5)
|
||||
"Cannot define toplevel constants inside a contract interface">>
|
||||
])
|
||||
, ?TYPE_ERROR(toplevel_constants_invalid_expr,
|
||||
[<<?Pos(10,9)
|
||||
"Invalid expression in the definition of the constant `c01`">>,
|
||||
<<?Pos(11,9)
|
||||
"Invalid expression in the definition of the constant `c02`">>,
|
||||
<<?Pos(12,9)
|
||||
"Invalid expression in the definition of the constant `c03`">>,
|
||||
<<?Pos(13,9)
|
||||
"Invalid expression in the definition of the constant `c04`">>,
|
||||
<<?Pos(14,9)
|
||||
"Invalid expression in the definition of the constant `c05`">>,
|
||||
<<?Pos(17,9)
|
||||
"Invalid expression in the definition of the constant `c07`">>,
|
||||
<<?Pos(18,9)
|
||||
"Invalid expression in the definition of the constant `c08`">>,
|
||||
<<?Pos(19,9)
|
||||
"Invalid expression in the definition of the constant `c09`">>,
|
||||
<<?Pos(20,9)
|
||||
"Invalid expression in the definition of the constant `c10`">>,
|
||||
<<?Pos(21,9)
|
||||
"Invalid expression in the definition of the constant `c11`">>
|
||||
])
|
||||
, ?TYPE_ERROR(toplevel_constants_invalid_id,
|
||||
[<<?Pos(2,9)
|
||||
"The name of the compile-time constant cannot have pattern matching nor type">>,
|
||||
<<?Pos(3,9)
|
||||
"The name of the compile-time constant cannot have pattern matching nor type">>,
|
||||
<<?Pos(4,9)
|
||||
"The name of the compile-time constant cannot have pattern matching nor type">>
|
||||
])
|
||||
].
|
||||
|
||||
validation_test_() ->
|
||||
|
11
test/contracts/toplevel_constants_contract_as_namespace.aes
Normal file
11
test/contracts/toplevel_constants_contract_as_namespace.aes
Normal file
@ -0,0 +1,11 @@
|
||||
contract G =
|
||||
let const = 1
|
||||
|
||||
main contract C =
|
||||
let c = G.const
|
||||
|
||||
stateful entrypoint f() =
|
||||
let g = Chain.create() : G
|
||||
|
||||
g.const
|
||||
g.const()
|
6
test/contracts/toplevel_constants_cycles.aes
Normal file
6
test/contracts/toplevel_constants_cycles.aes
Normal file
@ -0,0 +1,6 @@
|
||||
contract C =
|
||||
let selfcycle = selfcycle
|
||||
|
||||
let cycle1 = cycle2
|
||||
let cycle2 = cycle3
|
||||
let cycle3 = cycle1
|
7
test/contracts/toplevel_constants_in_interface.aes
Normal file
7
test/contracts/toplevel_constants_in_interface.aes
Normal file
@ -0,0 +1,7 @@
|
||||
contract interface I =
|
||||
let (x::y::_) = [1,2,3]
|
||||
let c = 10
|
||||
let d = 10
|
||||
|
||||
contract C =
|
||||
entrypoint init() = ()
|
21
test/contracts/toplevel_constants_invalid_expr.aes
Normal file
21
test/contracts/toplevel_constants_invalid_expr.aes
Normal file
@ -0,0 +1,21 @@
|
||||
main contract C =
|
||||
record account = { name : string,
|
||||
balance : int }
|
||||
|
||||
let one = 1
|
||||
let opt = Some(5)
|
||||
let acc = { name = "str", balance = 100000 }
|
||||
let mpp = {["foo"] = 19, ["bar"] = 42}
|
||||
|
||||
let c01 = [x | x <- [1,2,3,4,5]]
|
||||
let c02 = [x + k | x <- [1,2,3,4,5], let k = x*x]
|
||||
let c03 = [x + y | x <- [1,2,3,4,5], let k = x*x, if (k > 5), y <- [k, k+1, k+2]]
|
||||
let c04 = if (one > 2) 3 else 4
|
||||
let c05 = switch (opt)
|
||||
Some(x) => x
|
||||
None => 2
|
||||
let c07 = acc{ balance = one }
|
||||
let c08 = mpp["foo"]
|
||||
let c09 = mpp["non" = 10]
|
||||
let c10 = mpp{["foo"] = 20}
|
||||
let c11 = (x) => x + 1
|
4
test/contracts/toplevel_constants_invalid_id.aes
Normal file
4
test/contracts/toplevel_constants_invalid_id.aes
Normal file
@ -0,0 +1,4 @@
|
||||
contract C =
|
||||
let x::_ = [1,2,3,4]
|
||||
let y::(p = z::_) = [1,2,3,4]
|
||||
let t : int = 1
|
Loading…
x
Reference in New Issue
Block a user