-
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.
tests/class: Make into class return rules testing test
- Loading branch information
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Tests related to when we can and can't return from classes. | ||
# Again, similar to assignemnt | ||
|
||
class Illegal { | ||
return none | ||
} | ||
|
||
class Illegal2 { | ||
{ | ||
return none | ||
} | ||
} | ||
|
||
class Illegal3 { | ||
{ | ||
return 69 | ||
} | ||
} | ||
|
||
class Legal { | ||
} | ||
|
||
assert Legal() != none | ||
|
||
class LegalExplicitReturn { | ||
a = 69 | ||
a = 420 | ||
return | ||
} | ||
|
||
# TODO There's currently a pretty sizable issue with shadowing and class members which means I can't name this 'a' too. | ||
# A proper solution would be to introduce a 'let' keyword but eeeeh... | ||
# Although if the plan is anyway to use Bob for config files and the variables are already declared in an import, this might even be a good thing. | ||
|
||
b = LegalExplicitReturn() | ||
assert b.a == 420 | ||
|
||
class LegalControlFlowInterruption { | ||
a = 69 | ||
return | ||
a = 420 | ||
} | ||
|
||
b = LegalControlFlowInterruption() | ||
assert b.a == 69 |