-
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.
## Description Closes #6077 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
- Loading branch information
1 parent
0fa1b9a
commit 7b07216
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; | ||
|