-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce2de40
commit 7cfdf3a
Showing
14 changed files
with
663 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
third_party/move/move-compiler-v2/tests/checking/typing/index_err.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Diagnostics: | ||
warning: unused alias | ||
┌─ tests/checking/typing/index_err.move:9:19 | ||
│ | ||
9 │ use 0x42::test; | ||
│ ^^^^ Unused 'use' of alias 'test'. Consider removing it | ||
|
||
error: unexpected token | ||
┌─ tests/checking/typing/index_err.move:10:17 | ||
│ | ||
10 │ assert!((test::R[@0x1]).value == true, 0); | ||
│ ^^^^^^^^^^^^^^^ resource indexing using `_[_]` needs to be paired with `&` or `&mut` | ||
|
||
error: unexpected token | ||
┌─ tests/checking/typing/index_err.move:14:9 | ||
│ | ||
14 │ Test[@0x1]; | ||
│ ^^^^^^^^^^ index notation `_[_]` expects a resource or vector | ||
|
||
error: unexpected token | ||
┌─ tests/checking/typing/index_err.move:18:10 | ||
│ | ||
18 │ &Test[@0x1]; | ||
│ ^^^^^^^^^^ index notation `_[_]` expects a resource or vector |
21 changes: 21 additions & 0 deletions
21
third_party/move/move-compiler-v2/tests/checking/typing/index_err.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module 0x42::test { | ||
|
||
struct R has key, drop { value: bool } | ||
|
||
spec schema Test { | ||
} | ||
|
||
fun test_no_ref_for_resource() acquires R { | ||
use 0x42::test; | ||
assert!((test::R[@0x1]).value == true, 0); | ||
} | ||
|
||
fun test_no_schema() { | ||
Test[@0x1]; | ||
} | ||
|
||
fun test_no_schema_ref() { | ||
&Test[@0x1]; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/checking/typing/index_err_2.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Diagnostics: | ||
error: cannot pass `&X<integer>` to a function which expects argument of type `&vector<_>` | ||
┌─ tests/checking/typing/index_err_2.move:11:17 | ||
│ | ||
11 │ assert!(x[0].value == 2, 0); | ||
│ ^^^^ |
14 changes: 14 additions & 0 deletions
14
third_party/move/move-compiler-v2/tests/checking/typing/index_err_2.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module 0x42::test { | ||
|
||
struct X<M> has copy, drop, store { | ||
value: M | ||
} | ||
|
||
fun test_vector() { | ||
let x = X { | ||
value: 2 | ||
}; | ||
assert!(x[0].value == 2, 0); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/index.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
processed 14 tasks |
162 changes: 162 additions & 0 deletions
162
third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/index.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
//# publish | ||
module 0x42::test { | ||
|
||
struct R has key, drop { value: bool } | ||
|
||
const CONSTANT_VEC: vector<u8> = vector[1, 2, 3]; | ||
|
||
fun init(s: &signer) { | ||
move_to(s, R{value: true}); | ||
} | ||
|
||
fun test_resource_1() acquires R { | ||
use 0x42::test; | ||
assert!((&test::R[@0x1]).value == true, 0); | ||
} | ||
|
||
fun test_resource_2() acquires R { | ||
let x = &mut 0x42::test::R[@0x1]; | ||
x.value = false; | ||
assert!((&R[@0x1]).value == false, 1); | ||
} | ||
|
||
struct X<M> has copy, drop, store { | ||
value: M | ||
} | ||
struct Y<T> has key, drop { | ||
field: T | ||
} | ||
|
||
fun init_2(s: &signer) { | ||
let x = X { | ||
value: true | ||
}; | ||
let y = Y { | ||
field: x | ||
}; | ||
move_to(s, y); | ||
} | ||
|
||
fun test_resource_3() acquires Y { | ||
use 0x42::test; | ||
assert!((&test::Y<X<bool>>[@0x1]).field.value == true, 0); | ||
} | ||
|
||
fun test_resource_4() acquires Y { | ||
let addr = @0x1; | ||
let y = &mut 0x42::test ::Y<X<bool>> [addr]; | ||
y.field.value = false; | ||
spec { | ||
assert Y<X<bool>>[addr].field.value == false; | ||
}; | ||
assert!((&Y<X<bool>>[addr]) .field.value == false, 1); | ||
} | ||
|
||
fun test_vector() { | ||
let x = X { | ||
value: 2 | ||
}; | ||
let v = vector[x, x]; | ||
assert!(v[0].value == 2, 0); | ||
} | ||
|
||
fun test_vector_borrow() { | ||
let x1 = X { | ||
value: true | ||
}; | ||
let x2 = X { | ||
value: false | ||
}; | ||
let y1 = Y { | ||
field: x1 | ||
}; | ||
let y2 = Y { | ||
field: x2 | ||
}; | ||
let v = vector[y1, y2]; | ||
assert!((&v[0]).field.value == true, 0); | ||
assert!((&v[1]).field.value == false, 0); | ||
} | ||
|
||
fun test_vector_borrow_mut() { | ||
let x1 = X { | ||
value: true | ||
}; | ||
let x2 = X { | ||
value: false | ||
}; | ||
let y1 = Y { | ||
field: x1 | ||
}; | ||
let y2 = Y { | ||
field: x2 | ||
}; | ||
let v = vector[y1, y2]; | ||
assert!((&v[0]).field.value == true, 0); | ||
assert!((&v[1]).field.value == false, 0); | ||
(&mut v[0]).field.value = false; | ||
(&mut v[1]).field.value = true; | ||
assert!((&v[0]).field.value == false, 0); | ||
assert!((&v[1]).field.value == true, 0); | ||
} | ||
|
||
fun test_vector_const() { | ||
assert!(CONSTANT_VEC[0] == 1, 0); | ||
} | ||
|
||
struct M has drop, copy { | ||
vec: vector<u8>, | ||
} | ||
|
||
fun test_vector_in_struct() { | ||
let x = M { | ||
vec: vector[1, 2, 3] | ||
}; | ||
let v = vector[x, x]; | ||
assert!(v[0].vec == vector[1,2,3], 0); | ||
} | ||
|
||
fun test_vector_in_struct_2() { | ||
let x = M { | ||
vec: vector[1, 2, 3] | ||
}; | ||
let v = vector[x, x]; | ||
assert!(v[0].vec[0] == 1, 0); | ||
} | ||
|
||
fun test_vector_in_struct_3() { | ||
let x = M { | ||
vec: vector[1, 2, 3] | ||
}; | ||
let v = vector[x, x]; | ||
let y = &(v[0].vec)[2]; | ||
assert!(*y == 3, 0); | ||
} | ||
|
||
} | ||
|
||
//# run --verbose --signers 0x1 -- 0x42::test::init | ||
|
||
//# run --verbose -- 0x42::test::test_resource_1 | ||
|
||
//# run --verbose -- 0x42::test::test_resource_2 | ||
|
||
//# run --verbose -- 0x42::test::test_vector | ||
|
||
//# run --verbose -- 0x42::test::test_vector_borrow | ||
|
||
//# run --verbose -- 0x42::test::test_vector_borrow_mut | ||
|
||
//# run --verbose --signers 0x1 -- 0x42::test::init_2 | ||
|
||
//# run --verbose -- 0x42::test::test_resource_3 | ||
|
||
//# run --verbose -- 0x42::test::test_resource_4 | ||
|
||
//# run --verbose -- 0x42::test::test_vector_const | ||
|
||
//# run --verbose -- 0x42::test::test_vector_in_struct | ||
|
||
//# run --verbose -- 0x42::test::test_vector_in_struct_2 | ||
|
||
//# run --verbose -- 0x42::test::test_vector_in_struct_3 |
Oops, something went wrong.