Skip to content

Commit

Permalink
tests/class: Make into class return rules testing test
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Sep 7, 2024
1 parent 9f08593 commit 3c1acff
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/class_return_rules.fl
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

0 comments on commit 3c1acff

Please sign in to comment.