-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Showing
151 changed files
with
9,067 additions
and
585 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(): u64 { | ||
match (ABC::C(0)) { | ||
ABC::C(x) => x, | ||
ABC::A(x) => x, | ||
ABC::B => 1, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_binder.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
...crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_binder.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(x: ABC<u64>): ABC<u64> { | ||
match (x) { | ||
ABC::C(c) => ABC::C(c), | ||
ABC::A(a) => ABC::A(a), | ||
y => y, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_mut_ref.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
...rates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_mut_ref.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(abc: &mut ABC<u64>, default: &mut u64): &mut u64 { | ||
match (abc) { | ||
ABC::C(x) => x, | ||
ABC::A(x) => x, | ||
ABC::B => default, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_no_drop.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
...rates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_no_drop.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(): u64 { | ||
match (ABC::C(0)) { | ||
ABC::C(x) => x, | ||
ABC::A(x) => x, | ||
ABC::B => 1, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...nal-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_ref.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
...al-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_ref.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(abc: &ABC<u64>, default: &u64): &u64 { | ||
match (abc) { | ||
ABC::C(x) => x, | ||
ABC::A(x) => x, | ||
ABC::B => default, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...l-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_twice.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 2 tasks |
29 changes: 29 additions & 0 deletions
29
...-crates/move/crates/move-compiler-transactional-tests/tests/matching/abc_match_twice.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,29 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(): u64 { | ||
let default = 1; | ||
let x = ABC::C(0); | ||
let y = match (&x) { | ||
ABC::C(x) => x, | ||
ABC::A(x) => x, | ||
ABC::B => &default, | ||
}; | ||
let y = *y; | ||
let z = match (x) { | ||
ABC::C(x) => y + x, | ||
ABC::A(x) => y + x, | ||
ABC::B => y, | ||
}; | ||
z | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...move/crates/move-compiler-transactional-tests/tests/matching/abc_match_value_wildcard.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 2 tasks |
19 changes: 19 additions & 0 deletions
19
...ove/crates/move-compiler-transactional-tests/tests/matching/abc_match_value_wildcard.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,19 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun t0(): u64 { | ||
match (ABC::C(0)) { | ||
ABC::C(x) => x, | ||
_ => 1, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/basic.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 3 tasks |
56 changes: 56 additions & 0 deletions
56
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/basic.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,56 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
|
||
module 0x42::t { | ||
|
||
use std::vector; | ||
use fun std::vector::pop_back as vector.pop_back; | ||
use fun std::vector::push_back as vector.push_back; | ||
use fun std::vector::is_empty as vector.is_empty; | ||
|
||
public enum Exp has drop { | ||
Done, | ||
Add, | ||
Mul, | ||
Num(u64), | ||
} | ||
|
||
const EINVALIDEXP: u64 = 0; | ||
|
||
public fun evaluate(mut expressions: vector<Exp>): u64 { | ||
let mut stack = vector[]; | ||
while (!expressions.is_empty()) { | ||
match (expressions.pop_back()) { | ||
Exp::Done => break, | ||
Exp::Add => { | ||
let e1 = stack.pop_back(); | ||
let e2 = stack.pop_back(); | ||
stack.push_back(e1 + e2); | ||
}, | ||
Exp::Mul => { | ||
let e1 = stack.pop_back(); | ||
let e2 = stack.pop_back(); | ||
stack.push_back(e1 * e2); | ||
}, | ||
Exp::Num(number) => { | ||
stack.push_back(number); | ||
} | ||
} | ||
}; | ||
let result = vector::pop_back(&mut stack); | ||
assert!(expressions.is_empty(), EINVALIDEXP); | ||
assert!(stack.is_empty(), EINVALIDEXP); | ||
result | ||
} | ||
|
||
use fun evaluate as vector.evaluate; | ||
|
||
public fun test() { | ||
let input = vector[Exp::Done, Exp::Add, Exp::Num(5), Exp::Num(5)]; | ||
assert!(input.evaluate() == 10, 0); | ||
} | ||
|
||
} | ||
|
||
//# run 0x42::t::test |
1 change: 1 addition & 0 deletions
1
...l-crates/move/crates/move-compiler-transactional-tests/tests/matching/either_bindings.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 2 tasks |
18 changes: 18 additions & 0 deletions
18
...-crates/move/crates/move-compiler-transactional-tests/tests/matching/either_bindings.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,18 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum Either<L,R> has drop { | ||
Left(L), | ||
Right(R), | ||
} | ||
|
||
fun t0(in: Either<u64, u64>): u64 { | ||
match (in) { | ||
Either::Left(y) => y, | ||
Either::Right(y) => y, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...tes/move/crates/move-compiler-transactional-tests/tests/matching/enum_no_tyargs_match.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 2 tasks |
20 changes: 20 additions & 0 deletions
20
...es/move/crates/move-compiler-transactional-tests/tests/matching/enum_no_tyargs_match.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,20 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum Threes has drop { | ||
One(u64), | ||
Two(u64, u64), | ||
Three(u64, u64, u64) | ||
} | ||
|
||
fun t0(): u64 { | ||
match (Threes::One(0)) { | ||
Threes::Three(x, _, _) => x, | ||
Threes::One(x) => x, | ||
Threes::Two(_, _) => 1, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...l-crates/move/crates/move-compiler-transactional-tests/tests/matching/enum_poly_match.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 2 tasks |
22 changes: 22 additions & 0 deletions
22
...-crates/move/crates/move-compiler-transactional-tests/tests/matching/enum_poly_match.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,22 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum Threes<T> has drop { | ||
Zero, | ||
One(T), | ||
Two(T, T), | ||
Three(T, T, T) | ||
} | ||
|
||
fun t0(): u64 { | ||
match (Threes::One(0)) { | ||
Threes::Three(x, _, _) => x, | ||
Threes::One(x) => x, | ||
Threes::Two(_, _) => 1, | ||
Threes::Zero => 64, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/lit_match.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 3 tasks |
26 changes: 26 additions & 0 deletions
26
external-crates/move/crates/move-compiler-transactional-tests/tests/matching/lit_match.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,26 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<T> has drop { | ||
A(T), | ||
B, | ||
C(T) | ||
} | ||
|
||
fun fib(x: u64): u64 { | ||
match (x) { | ||
0 => 1, | ||
1 => 1, | ||
x => fib(x-1) + fib(x-2), | ||
} | ||
} | ||
|
||
fun test() { | ||
assert!(fib(5) == 8, 0); | ||
} | ||
|
||
} | ||
|
||
//# run 0x42::m::test |
1 change: 1 addition & 0 deletions
1
...l-crates/move/crates/move-compiler-transactional-tests/tests/matching/nested_bindings.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 2 tasks |
27 changes: 27 additions & 0 deletions
27
...-crates/move/crates/move-compiler-transactional-tests/tests/matching/nested_bindings.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,27 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public enum ABC<Q,R> has drop { | ||
A(Q,R), | ||
B, | ||
C(Q,R), | ||
} | ||
|
||
public enum QEither<L,R> has drop { | ||
Left(L), | ||
Right(R), | ||
} | ||
|
||
fun t0(in: ABC<u64, QEither<u64, u64>>): u64 { | ||
match (in) { | ||
ABC::C(x, QEither::Left(y)) => x + y, | ||
ABC::C(x, QEither::Right(y)) => x + y, | ||
ABC::A(b, QEither::Left(d)) => b + d, | ||
ABC::A(c, QEither::Right(e)) => c + e, | ||
ABC::B => 1, | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...crates/move/crates/move-compiler-transactional-tests/tests/matching/option_enum_match.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 2 tasks |
Oops, something went wrong.