// GorillaScript as of 2013-07-08 | |
macro assert-equals(x, y) | |
@maybe-cache x, #(set-x, x) | |
@maybe-cache y, #(set-y, y) | |
AST | |
if $set-x != $set-y | |
throw new Error("assert-equals failed: " & $x & " != " & $y) | |
macro assert-deep-equals(x, y) | |
@maybe-cache x, #(set-x, x) | |
@maybe-cache y, #(set-y, y) | |
AST | |
if JSON.stringify($set-x) != JSON.stringify($set-y) | |
throw new Error("assert-deep-equals failed: " & JSON.stringify($x, null, 2) & " != " & JSON.stringify($y, null, 2)) | |
class Foo | |
def constructor(@threshold) | |
pass // an empty body crashes the web compiler for me | |
def process(list) | |
list.filter(#(el)@ el > @threshold) | |
let list = [3, 5, 10, 12, 17, 20] | |
let result = Foo(11).process(list) | |
assert-equals JSON.stringify(result), JSON.stringify([12, 17, 20]) | |
alert "ok" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment