Allow empty argument list methods.
- Compile them as calls and definitions. - Use them for call(), clear(), run(), try(), and yield(). - Update the docs.
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
var f = new Fn {}
|
||||
IO.print(f.call) // expect: null
|
||||
IO.print(f.call()) // expect: null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var f = new Fn {
|
||||
// Hi.
|
||||
}
|
||||
IO.print(f.call) // expect: null
|
||||
IO.print(f.call()) // expect: null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
new Fn { IO.print("ok") // expect error
|
||||
}.call // expect error
|
||||
}.call() // expect error
|
||||
|
||||
// The second error is cascaded here. If it starts failing, just remove that
|
||||
// expectation.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
new Fn {|| null } // expect error
|
||||
@@ -1,5 +1,5 @@
|
||||
var f0 = new Fn { 0 }
|
||||
IO.print(f0.call) // expect: 0
|
||||
IO.print(f0.call()) // expect: 0
|
||||
|
||||
var f1 = new Fn {|a| a }
|
||||
IO.print(f1.call(1)) // expect: 1
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Single expression body.
|
||||
new Fn { IO.print("ok") }.call // expect: ok
|
||||
new Fn { IO.print("ok") }.call() // expect: ok
|
||||
|
||||
// Curly body.
|
||||
new Fn {
|
||||
IO.print("ok") // expect: ok
|
||||
}.call
|
||||
}.call()
|
||||
|
||||
// Multiple statements.
|
||||
new Fn {
|
||||
IO.print("1") // expect: 1
|
||||
IO.print("2") // expect: 2
|
||||
}.call
|
||||
}.call()
|
||||
|
||||
// Extra newlines.
|
||||
new Fn {
|
||||
@@ -22,4 +22,4 @@ new Fn {
|
||||
IO.print("2") // expect: 2
|
||||
|
||||
|
||||
}.call
|
||||
}.call()
|
||||
|
||||
Reference in New Issue
Block a user