-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
10 changed files
with
235 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Adapted from https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb | ||
// def test_create | ||
|
||
@wizard | ||
; add_property($system, "a", create($nothing), {$wizard_player, "rwc"}); | ||
; add_property($system, "b", create($a), {$wizard_player, "rwc"}); | ||
; add_property($system, "c", create($b, $nothing), {$wizard_player, "rwc"}); | ||
; add_property($system, "d", create($b, $a), {$wizard_player, "rwc"}); | ||
|
||
// test that `parent()' works for single inheritance hierarchies | ||
; return parent($a); | ||
$nothing | ||
; return parent($b); | ||
$a | ||
; return parent($c); | ||
$b | ||
; return parent($c); | ||
$b | ||
|
||
// test that `children()' works for single inheritance hierarchies | ||
; return children($a); | ||
{$b} | ||
; return children($b); | ||
{$c, $d} | ||
; return children($c); | ||
{} | ||
; return children($d); | ||
{} | ||
|
||
// test that create sets the owner correctly | ||
; return $a.owner; | ||
$wizard_player | ||
; return $b.owner; | ||
$wizard_player | ||
; return $c.owner; | ||
$c | ||
; return $d.owner; | ||
$a | ||
|
||
; add_property($system, "e", create($nothing, $nothing), {$wizard_player, "rwc"}); | ||
; add_property($system, "f", create($nothing, $ambiguous_match), {$wizard_player, "rwc"}); | ||
; add_property($system, "g", create($nothing, $failed_match), {$wizard_player, "rwc"}); | ||
; add_property($system, "h", create($nothing, $invalid_object), {$wizard_player, "rwc"}); | ||
|
||
; return $e.owner; | ||
$e | ||
; return $f.owner; | ||
$nothing | ||
; return $g.owner; | ||
$failed_match | ||
; return $h.owner; | ||
$invalid_object | ||
|
||
@programmer | ||
; create($nothing, $nothing); | ||
E_PERM | ||
; create($nothing, $ambiguous_match); | ||
E_PERM | ||
; create($nothing, $failed_match); | ||
E_PERM | ||
; create($nothing, $invalid_object); | ||
E_PERM |
76 changes: 76 additions & 0 deletions
76
crates/kernel/testsuite/moot/objects/test_create_errors.moot
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,76 @@ | ||
// Adapted from https://github.com/toddsundsted/stunt/blob/e83e946/test/test_objects.rb | ||
// def test_create_errors | ||
|
||
@wizard | ||
; create(); | ||
E_ARGS | ||
; return create(1); | ||
E_TYPE | ||
; return create("1"); | ||
E_TYPE | ||
; return create(1, 2); | ||
E_TYPE | ||
; return create($object, "2"); | ||
E_TYPE | ||
|
||
; create($ambiguous_match); | ||
E_PERM | ||
; create($failed_match); | ||
E_PERM | ||
; create($invalid_object); | ||
E_PERM | ||
|
||
; return create({1}); | ||
E_TYPE | ||
; return create({"1"}); | ||
E_TYPE | ||
; return create({$nothing}); | ||
E_TYPE | ||
; return create({$ambiguous_match}); | ||
E_TYPE | ||
; return create({$failed_match}); | ||
E_TYPE | ||
; return create({$invalid_object}); | ||
E_TYPE | ||
|
||
// A variety of tests that check permissions. | ||
|
||
; add_property($system, "a", create($nothing), {$wizard_player, "rwc"}); | ||
; add_property($system, "b", create($a, $a), {$wizard_player, "rwc"}); | ||
; $b.f = 1; | ||
; return $a.owner; | ||
$wizard_player | ||
; return $b.owner; | ||
$a | ||
|
||
@programmer | ||
; create($a); | ||
E_PERM | ||
; create($b, $invalid_object); | ||
E_PERM | ||
; create($b, $wizard_player); | ||
E_PERM | ||
; create($b, $nothing); | ||
E_PERM | ||
|
||
; return valid(create($b)); | ||
1 | ||
|
||
; add_property($system, "c", create($nothing), {$programmer_player, ""}); | ||
; add_property($system, "d", create($b, $programmer_player), {$programmer_player, "rwc"}); | ||
; $d.f = 1; | ||
|
||
; return $c.owner; | ||
$programmer_player | ||
; return $d.owner; | ||
$programmer_player | ||
|
||
@wizard | ||
; return valid(create($a)); | ||
1 | ||
; return valid(create($b, $wizard_player)); | ||
1 | ||
; return valid(create($c, $programmer_player)); | ||
1 | ||
; return valid(create($d)); | ||
1 |
This file was deleted.
Oops, something went wrong.
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
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