-
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
231 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; | ||
// TODO: for $f.owner LMOO returns the object we passed in, we get E_INVIND instead. | ||
// We get E_INVIND from the default branch of `get_property()` in `vm/moo_execute.rs' | ||
// Stunt returns E_INVARG. | ||
E_INVIND | ||
; return $g.owner; | ||
$failed_match | ||
; return $h.owner; | ||
$invalid_object | ||
|
||
@programmer | ||
// TODO: these should all fail with E_PERM, but they currently pass | ||
; create($nothing, $nothing); | ||
; create($nothing, $ambiguous_match); | ||
; create($nothing, $failed_match); | ||
; create($nothing, $invalid_object); |
72 changes: 72 additions & 0 deletions
72
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,72 @@ | ||
// 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 | ||
|
||
// TODO: these three should all fail with E_PERM, but they currently pass | ||
& create($ambiguous_match); | ||
& create($failed_match); | ||
& create($invalid_object); | ||
|
||
; 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 | ||
// TODO this three should fail with E_PERM, but currently passes | ||
& create($b, $invalid_object); | ||
& create($b, $wizard_player); | ||
& create($b, $nothing); | ||
|
||
; 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
Oops, something went wrong.