-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(code-samples): 📝 Turn code samples into snippets for "Testin…
…g" directory
- Loading branch information
Showing
8 changed files
with
98 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use "pony_test" | ||
use "pony_check" | ||
|
||
actor Main is TestList | ||
new create(env: Env) => | ||
PonyTest(env, this) | ||
|
||
fun tag tests(test: PonyTest) => | ||
test(Property1UnitTest[String](_MyFirstProperty)) |
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 @@ | ||
class _ListReverseProperties is UnitTest | ||
fun name(): String => "list/properties" | ||
|
||
fun apply(h: TestHelper) ? => | ||
let gen1 = Generators.seq_of[USize, Array[USize]](Generators.usize()) | ||
PonyCheck.for_all[Array[USize]](gen1, h)({ | ||
(arg1: Array[USize], ph: PropertyHelper) => | ||
ph.assert_array_eq[USize](arg1, arg1.reverse().reverse()) | ||
}) | ||
let gen2 = Generators.seq_of[USize, Array[USize]](1, Generators.usize()) | ||
PonyCheck.for_all[Array[USize]](gen2, h)({ | ||
(arg1: Array[USize], ph: PropertyHelper) => | ||
ph.assert_array_eq[USize](arg1, arg1.reverse()) | ||
}) |
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 @@ | ||
use "pony_check" | ||
use "collections" | ||
|
||
class _ListReverseProperty is Property1[Array[USize]] | ||
fun name(): String => "list/reverse" | ||
|
||
fun gen(): Generator[Array[USize]] => | ||
Generators.seq_of[USize, Array[USize]](Generators.usize()) | ||
|
||
fun property(arg1: Array[USize], ph: PropertyHelper) => | ||
ph.assert_array_eq[USize](arg1, arg1.reverse().reverse()) | ||
|
||
class _ListReverseOneProperty is Property1[Array[USize]] | ||
fun name(): String => "list/reverse/one" | ||
|
||
fun gen(): Generator[Array[USize]] => | ||
Generators.seq_of[USize, Array[USize]](Generators.usize() where min = 1, max = 1) | ||
|
||
fun property(arg1: Array[USize], ph: PropertyHelper) => | ||
ph.assert_array_eq[USize](arg1, arg1.reverse()) |
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,11 @@ | ||
use "pony_test" | ||
|
||
class _MyFirstProperty is Property1[String] | ||
fun name(): String => | ||
"my_first_property" | ||
|
||
fun gen(): Generator[String] => | ||
Generators.ascii() | ||
|
||
fun property(arg1: String, ph: PropertyHelper) => | ||
ph.assert_eq[String](arg1, arg1) |
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 @@ | ||
use "pony_test" | ||
use foo = "foo" | ||
use bar = "bar" | ||
|
||
actor Main is TestList | ||
new create(env: Env) => | ||
PonyTest(env, this) | ||
|
||
new make() => | ||
None | ||
|
||
fun tag tests(test: PonyTest) => | ||
foo.Main.make().tests(test) | ||
bar.Main.make().tests(test) |
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,24 @@ | ||
use "pony_test" | ||
|
||
actor Main is TestList | ||
new create(env: Env) => | ||
PonyTest(env, this) | ||
|
||
new make() => | ||
None | ||
|
||
fun tag tests(test: PonyTest) => | ||
test(_TestAdd) | ||
test(_TestSub) | ||
|
||
class iso _TestAdd is UnitTest | ||
fun name(): String => "addition" | ||
|
||
fun apply(h: TestHelper) => | ||
h.assert_eq[U32](4, 2 + 2) | ||
|
||
class iso _TestSub is UnitTest | ||
fun name(): String => "subtraction" | ||
|
||
fun apply(h: TestHelper) => | ||
h.assert_eq[U32](2, 4 - 2) |
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