Created
July 7, 2013 19:08
-
-
Save andreyvit/5944549 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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