-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
e30497c
commit 9a46b8e
Showing
3 changed files
with
130 additions
and
0 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
114 changes: 114 additions & 0 deletions
114
test/src/in_language_tests/test_programs/result_inline_tests/src/eq.sw
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,114 @@ | ||
library; | ||
|
||
#[test] | ||
fn test_eq_u64_u64() { | ||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Ok(0); | ||
assert_eq(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(1); | ||
let b: Result<u64, u64> = Ok(1); | ||
assert_eq(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(42); | ||
let b: Result<u64, u64> = Ok(42); | ||
assert_eq(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(u64::max()); | ||
let b: Result<u64, u64> = Ok(u64::max()); | ||
assert_eq(a, b); | ||
} | ||
|
||
#[test] | ||
fn test_neq_u64_u64() { | ||
// Ok | ||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Ok(1); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Ok(42); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Ok(u64::max()); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(1); | ||
let b: Result<u64, u64> = Ok(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(42); | ||
let b: Result<u64, u64> = Ok(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(u64::max()); | ||
let b: Result<u64, u64> = Ok(0); | ||
assert_ne(a, b); | ||
|
||
// Err | ||
let a: Result<u64, u64> = Err(0); | ||
let b: Result<u64, u64> = Err(1); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Err(0); | ||
let b: Result<u64, u64> = Err(42); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Err(0); | ||
let b: Result<u64, u64> = Err(u64::max()); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Err(1); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Err(42); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Err(u64::max()); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
// Ok-Err | ||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(1); | ||
let b: Result<u64, u64> = Err(1); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(42); | ||
let b: Result<u64, u64> = Err(42); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(u64::max()); | ||
let b: Result<u64, u64> = Err(u64::max()); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Err(1); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Err(42); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(0); | ||
let b: Result<u64, u64> = Err(u64::max()); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(1); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(42); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
|
||
let a: Result<u64, u64> = Ok(u64::max()); | ||
let b: Result<u64, u64> = Err(0); | ||
assert_ne(a, b); | ||
} |
2 changes: 2 additions & 0 deletions
2
test/src/in_language_tests/test_programs/result_inline_tests/src/main.sw
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
library; | ||
|
||
mod eq; | ||
|
||
#[test] | ||
fn result_is_ok() { | ||
use std::bytes::Bytes; | ||
|