forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Eq for identity (FuelLabs#2028)
* Added Eq for identity
- Loading branch information
Showing
7 changed files
with
92 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
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
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/identity_eq/.gitignore
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,2 @@ | ||
out | ||
target |
14 changes: 14 additions & 0 deletions
14
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/identity_eq/Forc.lock
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 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-E7BBED1900347958' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'identity_eq' | ||
source = 'root' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-E7BBED1900347958' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/identity_eq/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "identity_eq" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
14 changes: 14 additions & 0 deletions
14
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/identity_eq/json_abi_oracle.json
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 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"outputs": [ | ||
{ | ||
"components": null, | ||
"name": "", | ||
"type": "bool" | ||
} | ||
], | ||
"type": "function" | ||
} | ||
] |
43 changes: 43 additions & 0 deletions
43
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/identity_eq/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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
script; | ||
|
||
use std::{address::Address, assert::assert, contract_id::ContractId, identity::*}; | ||
|
||
fn main() -> bool { | ||
let b1 = 0x0000000000000000000000000000000000000000000000000000000000000001; | ||
let b2 = 0x0000000000000000000000000000000000000000000000000000000000000002; | ||
|
||
let address1 = Identity::Address(~Address::from(b1)); | ||
let address2 = Identity::Address(~Address::from(b2)); | ||
let contract1 = Identity::ContractId(~ContractId::from(b1)); | ||
let contract2 = Identity::ContractId(~ContractId::from(b2)); | ||
|
||
// Eq is True | ||
assert(address1 == address1); | ||
assert(contract1 == contract1); | ||
|
||
// Eq is False | ||
assert(!(address1 == address2)); | ||
assert(!(address2 == address1)); | ||
|
||
assert(!(contract1 == contract2)); | ||
assert(!(contract2 == contract1)); | ||
|
||
assert(!(address1 == contract1)); | ||
assert(!(contract1 == address1)); | ||
|
||
// Neq is True | ||
assert(address1 != address2); | ||
assert(address2 != address1); | ||
|
||
assert(contract1 != contract2); | ||
assert(contract2 != contract1); | ||
|
||
assert(address1 != contract1); | ||
assert(contract1 != address1); | ||
|
||
// Neq is False | ||
assert(!(address1 != address1)); | ||
assert(!(contract1 != contract1)); | ||
|
||
true | ||
} |