Skip to content

Commit

Permalink
import more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zekun Wang committed Jun 19, 2024
1 parent f26cebf commit 5d5d645
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Diagnostics:
error: invalid assignment
┌─ tests/unused-assignment/v1-commands/mixed_lvalue.move:14:19
14 │ (_, _, _, s.f) = four();
│ ^^^ Invalid assignment syntax. Expected: a local, a field write, or a deconstructing assignment

error: invalid assignment
┌─ tests/unused-assignment/v1-commands/mixed_lvalue.move:15:19
15 │ (_, _, _, *r_ref) = four();
│ ^^^^^^ Invalid assignment syntax. Expected: a local, a field write, or a deconstructing assignment
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module 0x8675309::A {

struct S has drop { f: u64 }

fun four(): (u64, u64, u64, u64) {
(0, 1, 2, 3)
}

public fun mixed() {
let r = 0;
let r_ref = &mut r;
let s = S { f: 0 };

(_, _, _, s.f) = four();
(_, _, _, *r_ref) = four();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Diagnostics:
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:6:21
6 │ if (cond) { r = R{}; };
│ ^^^^^^^

warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:13:29
13 │ if (cond) {} else { r = R{}; };
│ ^^^^^^^

warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:20:24
20 │ while (cond) { r = R{} };
│ ^^^^^^^

warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:27:16
27 │ loop { r = R{} }
│ ^^^^^^^
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module 0x8675309::M {
struct R {}

fun t1(cond: bool) {
let r: R;
if (cond) { r = R{}; };
r = R{};
R{} = r;
}

fun t2(cond: bool) {
let r: R;
if (cond) {} else { r = R{}; };
r = R{};
R{} = r;
}

fun t3(cond: bool) {
let r: R;
while (cond) { r = R{} };
r = R{};
R{} = r;
}

fun t4() {
let r: R;
loop { r = R{} }
}

fun t5<T>(cond: bool, x: T, y: T): (T, T) {
if (cond) { x = y };
(x, y)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Diagnostics:
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_resource.move:5:17
5 │ let r = R{};
│ ^^^

warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r`
┌─ tests/unused-assignment/v1-locals/assign_resource.move:29:17
29 │ let r = R{};
│ ^^^
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module 0x8675309::M {
struct R {}

fun t0() {
let r = R{};
r = R{};
R{} = r;
}

fun t1(cond: bool) {
let r = R{};
if (cond) { r = R{}; };
R{} = r;
}

fun t2(cond: bool) {
let r = R{};
if (cond) {} else { r = R{}; };
R{} = r;
}

fun t3(cond: bool) {
let r = R{};
while (cond) { r = R{} };
R{} = r;
}

fun t4() {
let r = R{};
loop { r = R{}; R {} = r }
}

fun t5<T>(x: T, y: T): T {
x = y;
x
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

Diagnostics:
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:8:13
8 │ let z = y;
│ ^

warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:9:13
9 │ let q = x;
│ ^

warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:17:13
17 │ let z = y;
│ ^

warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:18:13
18 │ let q = x;
│ ^

warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:24:13
24 │ let z = y;
│ ^

warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:25:13
25 │ let q = x;
│ ^

warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:13
30 │ let z = y;
│ ^

warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:13
31 │ let q = x;
│ ^


Diagnostics:
error: use of unassigned local `g`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:6:17
6 │ let r = R { f: 3, g };
│ ^^^^^^^^^^^^^

error: use of unassigned local `y0`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:15:17
15 │ let r = R { f: x0, g: y0 };
│ ^^^^^^^^^^^^^^^^^^

error: use of unassigned local `r`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:23:13
23 │ let R { f: x, g: y } = r;
│ ^^^^^^^^^^^^^^^^

error: use of unassigned local `y`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:17
30 │ let z = y;
│ ^

error: use of unassigned local `x`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:17
31 │ let q = x;
│ ^


Diagnostics:
warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:8:17
8 │ let z = y;
│ ^

warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:9:17
9 │ let q = x;
│ ^

warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:17:17
17 │ let z = y;
│ ^

warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:18:17
18 │ let q = x;
│ ^

warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:24:17
24 │ let z = y;
│ ^

warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:25:17
25 │ let q = x;
│ ^

warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:17
30 │ let z = y;
│ ^

warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q`
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:17
31 │ let q = x;
│ ^
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module 0x876543::M {
struct R { f: u64, g: u64 }

fun main() {
let g: u64;
let r = R { f: 3, g };
let R { f: x, g: y } = r;
let z = y;
let q = x;
}

fun main2() {
let x0: u64 = 0;
let y0: u64;
let r = R { f: x0, g: y0 };
let R { f: x, g: y } = r;
let z = y;
let q = x;
}

fun main3() {
let r: R;
let R { f: x, g: y } = r;
let z = y;
let q = x;
}

fun main4() {
let R { f: x, g: y };
let z = y;
let q = x;
}
}
4 changes: 4 additions & 0 deletions third_party/move/move-compiler-v2/tests/v1.matched
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ move-compiler/tests/move_check/translated_ir_tests/move/commands/continue_outsid
move-compiler/tests/move_check/translated_ir_tests/move/commands/else_assigns_if_doesnt.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/if_assigns_else_doesnt.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/if_assigns_no_else.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_no_else.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/mixed_lvalue.exp move-compiler-v2/tests/unused-assignment/v1-commands/mixed_lvalue.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/move_before_assign.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/move_before_assign.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/no_let_outside_if.exp move-compiler-v2/tests/checking/typing/v1-commands/no_let_outside_if.exp
move-compiler/tests/move_check/translated_ir_tests/move/commands/pop_negative.exp move-compiler-v2/tests/checking/typing/v1-commands/pop_negative.exp
Expand Down Expand Up @@ -206,9 +207,12 @@ move-compiler/tests/move_check/translated_ir_tests/move/generics/instantiation_l
move-compiler/tests/move_check/liveness/mut_inline.exp move-compiler-v2/tests/live-var/mut_inline.exp
move-compiler/tests/move_check/liveness/mut_ref.exp move-compiler-v2/tests/live-var/mut_ref.exp
move-compiler/tests/move_check/liveness/unused_assignment.exp move-compiler-v2/tests/unused-assignment/v1-liveness/unused_assignment.exp
move-compiler/tests/move_check/locals/assign_partial_resource.exp move-compiler-v2/tests/unused-assignment/v1-locals/assign_partial_resource.exp
move-compiler/tests/move_check/locals/assign_resource.exp move-compiler-v2/tests/unused-assignment/v1-locals/assign_resource.exp
move-compiler/tests/move_check/locals/drop_conditional.exp move-compiler-v2/tests/ability-check/v1-locals/drop_conditional.exp
move-compiler/tests/move_check/locals/eliminate_temps.exp move-compiler-v2/tests/reference-safety/v1-locals/eliminate_temps.exp
move-compiler/tests/move_check/locals/reassign_parameter.exp move-compiler-v2/tests/ability-check/v1-locals/reassign_parameter.exp
move-compiler/tests/move_check/locals/struct_use_before_assign.exp move-compiler-v2/tests/unused-assignment/v1-locals/struct_use_before_assign.exp
move-compiler/tests/move_check/locals/unused_copyable.exp move-compiler-v2/tests/unused-assignment/v1-locals/unused_copyable.exp
move-compiler/tests/move_check/locals/unused_resource.exp move-compiler-v2/tests/unused-assignment/v1-locals/unused_resource.exp
move-compiler/tests/move_check/locals/unused_resource_explicit_return.exp move-compiler-v2/tests/unused-assignment/v1-locals/unused_resource_explicit_return.exp
Expand Down
4 changes: 0 additions & 4 deletions third_party/move/move-compiler-v2/tests/v1.unmatched
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ move-compiler/tests/move_check/commands/{
invalid_fallthrough2.move,
invalid_fallthrough3.move,
join_failure.move,
mixed_lvalue.move,
while_move_local.move,
while_move_local_2.move,
}
Expand Down Expand Up @@ -68,9 +67,6 @@ move-compiler/tests/move_check/liveness/{
trailing_semi_loops.move,
}
move-compiler/tests/move_check/locals/{
assign_partial_resource.move,
assign_resource.move,
struct_use_before_assign.move,
use_after_move_if.move,
use_after_move_if_else.move,
use_after_move_loop.move,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static UNIT_PATH_REMAP: Lazy<Vec<(&'static str, &'static str)>> = Lazy::new(|| {
("unit_test/test", "unit_test.unit_test"),
("unused-assignment/v1-locals", "locals"),
("unused-assignment/v1-liveness", "liveness"),
("unused-assignment/v1-commands", "commands"),
("checking-lang-v1/v1-typing", "typing"),
("ability-check/v1-typing", "typing"),
("ability-check/v1-signer", "signer"),
Expand Down

0 comments on commit 5d5d645

Please sign in to comment.