Skip to content

Instantly share code, notes, and snippets.

@pasberth
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save pasberth/11110813 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/11110813 to your computer and use it in GitHub Desktop.
assert = require('chai').assert, (verify = require('./../src/leathershield').verify, describe('type verifier', function () {
return it('verifies a string', function () {
return result = verify({ 'type': 'String' }), (assert.property(result, 'Simple'), assert.equal(result.Simple, 'string'));
});
}))
{"expressions":[{"operator":"=","left":{"name":"assert","type":"Identifier"},"right":{"property":{"name":"assert","type":"Identifier"},"object":{"arguments":[{"value":"chai","type":"Literal"}],"callee":{"name":"require","type":"Identifier"},"type":"CallExpression"},"type":"MemberExpression"},"type":"AssignmentExpression"},{"expressions":[{"operator":"=","left":{"name":"verify","type":"Identifier"},"right":{"property":{"name":"verify","type":"Identifier"},"object":{"arguments":[{"value":"./../src/leathershield","type":"Literal"}],"callee":{"name":"require","type":"Identifier"},"type":"CallExpression"},"type":"MemberExpression"},"type":"AssignmentExpression"},{"arguments":[{"value":"type verifier","type":"Literal"},{"body":{"body":[{"argument":{"arguments":[{"value":"verifies a string","type":"Literal"},{"body":{"body":[{"argument":{"expressions":[{"operator":"=","left":{"name":"result","type":"Identifier"},"right":{"arguments":[{"type":"ObjectExpression","properties":[{"kind":"init","value":{"value":"String","type":"Literal"},"key":{"value":"type","type":"Literal"},"type":"Property"}]}],"callee":{"name":"verify","type":"Identifier"},"type":"CallExpression"},"type":"AssignmentExpression"},{"expressions":[{"arguments":[{"name":"result","type":"Identifier"},{"value":"Simple","type":"Literal"}],"callee":{"property":{"name":"property","type":"Identifier"},"object":{"name":"assert","type":"Identifier"},"type":"MemberExpression"},"type":"CallExpression"},{"arguments":[{"property":{"name":"Simple","type":"Identifier"},"object":{"name":"result","type":"Identifier"},"type":"MemberExpression"},{"value":"string","type":"Literal"}],"callee":{"property":{"name":"equal","type":"Identifier"},"object":{"name":"assert","type":"Identifier"},"type":"MemberExpression"},"type":"CallExpression"}],"type":"SequenceExpression"}],"type":"SequenceExpression"},"type":"ReturnStatement"}],"type":"BlockStatement"},"params":[],"type":"FunctionExpression"}],"callee":{"name":"it","type":"Identifier"},"type":"CallExpression"},"type":"ReturnStatement"}],"type":"BlockStatement"},"params":[],"type":"FunctionExpression"}],"callee":{"name":"describe","type":"Identifier"},"type":"CallExpression"}],"type":"SequenceExpression"}],"type":"SequenceExpression"}
assert := (require "chai").assert;
verify := (require "./../src/leathershield").verify;
describe "type verifier" by
it "verifies a string" as (
result := verify(`"type" of "String");
assert.property(result, "Simple");
assert.equal(result.Simple, "string"))
Token "."
Token ";"
Token ","
Token "^"
Token "`"
Token "("
Token ")"
Notation "$a ; $b" := "@SEQUENCE $a $b"
level 0 right associativity
Notation "$a . $b" := "@MEMBER $a $b"
level 2000 left associativity
Notation "$a : $b" := "@ASCRIBE $a $b"
level 1800 no associativity
Notation "type $a = $b" := "@TYPE-SYNONYM $a $b"
level 20 no associativity
Notation "$a := $b" := "@ASSIGN $a $b"
level 20 right associativity
Notation "if $a then $b else $c" := "@CONDITIONAL $a $b $c"
level 20 right associativity
Notation "match $a" := "@MATCH $a"
level 30 left associativity
Notation "$a case $b -> $c" := "@CASE $a $b $c"
level 30 left associativity
Notation "^ $a -> $b" := "@LAMBDA $a $b"
level 40 right associativity
Notation "$a | $b" := "@EITHER-TYPE $a $b"
level 40 right associativity
Notation "unit" := "@UNIT"
level 3000 no associativity
Notation "$a , $b" := "@ORDERED-PAIR $a $b"
level 50 right associativity
Notation "$a & $b" := "@UNORDERED-PAIR $a $b"
level 50 right associativity
Notation "` $a of $b" := "@VARIANT $a $b"
level 60 right associativity
Notation "simple $a" := "@SIMPLE-TYPE $a"
level 70 right associativity
Notation "$a @or $b" := "@OR $a $b"
level 200 right associativity
Notation "$a @and $b" := "@AND $a $b"
level 300 right associativity
Notation "@not $a" := "@NOT $a"
level 400 right associativity
Notation "$a @add $b" := "@ADD $a $b"
level 600 left associativity
Notation "$a @sub $b" := "@SUB $a $b"
level 600 left associativity
Notation "$a @mul $b" := "@MUL $a $b"
level 700 left associativity
Notation "$a @div $b" := "@DIV $a $b"
level 700 left associativity
Notation "($a)" := "$a"
level 2000 no associativity
Notation "begin $a end" := "$a"
level 2000 no associativity
Notation "$a $b" := "$a $b"
level 1900 left associativity
Notation "$a <| $b" := "$a $b"
level 100 right associativity
Notation "$a |> $b" := "$b $a"
level 100 left associativity
Notation "! $a" := "not $a"
level 400 right associativity
Notation "$a && $b" := "and($a, $b)"
level 300 right associativity
Notation "$a || $b" := "or($a, $b)"
level 200 right associativity
Notation "$a + $b" := "addition($a, $b)"
level 600 left associativity
Notation "$a - $b" := "subtraction($a, $b)"
level 600 left associativity
Notation "$a * $b" := "multiplication($a, $b)"
level 700 left associativity
Notation "$a / $b" := "division($a, $b)"
level 700 left associativity
Notation "describe $a by $b" := "describe($a, (^ unit -> $b))"
level 20 right associativity
Notation "it $a as $b" := "it($a, (^ unit -> $b))"
level 25 no associativity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment