Skip to content

Instantly share code, notes, and snippets.

@andreyvit
Created July 7, 2013 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreyvit/5944549 to your computer and use it in GitHub Desktop.
Save andreyvit/5944549 to your computer and use it in GitHub Desktop.
// 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