-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update JSON Cadence tests to load from external snippets
- Loading branch information
1 parent
7bd366a
commit e8122ac
Showing
11 changed files
with
122 additions
and
151 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
3 changes: 3 additions & 0 deletions
3
sdk/src/intTest/resources/cadence/json_cadence/decode_array.cdc
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,3 @@ | ||
pub fun main(): [UInt64] { | ||
return [1,3,4,5] | ||
} |
3 changes: 3 additions & 0 deletions
3
sdk/src/intTest/resources/cadence/json_cadence/decode_boolean.cdc
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,3 @@ | ||
pub fun main(): Bool { | ||
return true | ||
} |
31 changes: 31 additions & 0 deletions
31
sdk/src/intTest/resources/cadence/json_cadence/decode_complex_dict.cdc
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,31 @@ | ||
pub struct StorageInfo { | ||
pub let capacity: UInt64 | ||
pub let used: UInt64 | ||
pub let available: UInt64 | ||
pub let foo: Foo | ||
|
||
init(capacity: UInt64, used: UInt64, available: UInt64, foo: Foo) { | ||
self.capacity = capacity | ||
self.used = used | ||
self.available = available | ||
self.foo = foo | ||
} | ||
} | ||
|
||
pub struct Foo { | ||
pub let bar: Int | ||
|
||
init(bar: Int) { | ||
self.bar = bar | ||
} | ||
} | ||
|
||
pub fun main(addr: Address): {String: [StorageInfo]} { | ||
let acct = getAccount(addr) | ||
|
||
let foo = Foo(bar: 1) | ||
return {"test": [StorageInfo(capacity: acct.storageCapacity, | ||
used: acct.storageUsed, | ||
available: acct.storageCapacity - acct.storageUsed, | ||
foo: foo)]} | ||
} |
9 changes: 9 additions & 0 deletions
9
sdk/src/intTest/resources/cadence/json_cadence/decode_enum.cdc
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,9 @@ | ||
pub enum Color: UInt8 { | ||
pub case red | ||
pub case green | ||
pub case blue | ||
} | ||
|
||
pub fun main() : Color { | ||
return Color.red | ||
} |
3 changes: 3 additions & 0 deletions
3
sdk/src/intTest/resources/cadence/json_cadence/decode_optional.cdc
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,3 @@ | ||
pub fun main(): Bool? { | ||
return nil | ||
} |
3 changes: 3 additions & 0 deletions
3
sdk/src/intTest/resources/cadence/json_cadence/decode_optional_2.cdc
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,3 @@ | ||
pub fun main(): Bool? { | ||
return true | ||
} |
6 changes: 6 additions & 0 deletions
6
sdk/src/intTest/resources/cadence/json_cadence/decode_reference.cdc
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,6 @@ | ||
pub let hello = "Hello" | ||
pub let helloRef: &String = &hello as &String | ||
|
||
pub fun main(): &String { | ||
return helloRef | ||
} |
12 changes: 12 additions & 0 deletions
12
sdk/src/intTest/resources/cadence/json_cadence/decode_resource.cdc
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,12 @@ | ||
pub resource SomeResource { | ||
pub var value: Int | ||
|
||
init(value: Int) { | ||
self.value = value | ||
} | ||
} | ||
|
||
pub fun main(): @SomeResource { | ||
let newResource <- create SomeResource(value: 20) | ||
return <-newResource | ||
} |
16 changes: 16 additions & 0 deletions
16
sdk/src/intTest/resources/cadence/json_cadence/decode_struct.cdc
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,16 @@ | ||
pub struct StorageInfo { | ||
pub let capacity: Int | ||
pub let used: Int | ||
pub let available: Int | ||
|
||
init(capacity: Int, used: Int, available: Int) { | ||
self.capacity = capacity | ||
self.used = used | ||
self.available = available | ||
} | ||
} | ||
|
||
pub fun main(addr: Address): [StorageInfo] { | ||
let acct = getAccount(addr) | ||
return [StorageInfo(capacity: 1, used: 2, available: 3)] | ||
} |
3 changes: 3 additions & 0 deletions
3
sdk/src/intTest/resources/cadence/json_cadence/decode_ufix64.cdc
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,3 @@ | ||
pub fun main(): UFix64 { | ||
return 0.789111 | ||
} |