{"commit":"a2b79c23de99087eb8c81e048b518a5f81375057","subject":"reverted failing tests","message":"reverted failing tests\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/hashSpec.pogo","new_file":"test\/hashSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\nrequire 'chai'.should()\n\nshouldOutput = script.shouldOutput\nshouldThrow = script.shouldThrow\n\ndescribe 'hashes'\n describe 'evaluation'\n it \"a `true` hash entry does not need it's value specified\"\n 'print {one}' shouldOutput '{ one: true }'\n \n it 'a hash can have multiple entries, delimited by commas'\n \"print {color 'red', size 'large'}\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'a hash can have multiple entries, delimited by new lines'\n \"print {\n color 'red'\n size 'large'\n }\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'hash entries can be written with an equals \"=\" operator'\n \"print {color = 'red', size = 'large'}\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'can define a hash as a statement'\n \"{color = print 'red', size = print 'large'}\n print 'done'\" shouldOutput \"'red'\n 'large'\n 'done'\"\n \n context \"when it doesn't contain hash entries\"\n it 'when it contains a method call, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n console.log ('aaahh!')\n }\"\n }.should.throw r\/cannot be a hash entry\/\n\n it 'when it contains a function call, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n x (1, 23, 3)\n }\"\n }.should.throw r\/cannot be a hash entry\/\n\n it 'when it contains a colon, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n x: 8\n }\"\n }.should.throw r\/Parse error\/\n","old_contents":"script = require '.\/scriptAssertions'\nrequire 'chai'.should()\n\nshouldOutput = script.shouldOutput\nshouldThrow = script.shouldThrow\n\ndescribe 'hashes'\n describe 'evaluation'\n it \"a `true` hash entry does not need it's value specified\"\n 'print {one}' shouldOutput '{ one: true }'\n \n it 'a hash can have multiple entries, delimited by commas'\n \"print {color 'red', size 'large'}\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'a hash can have multiple entries, delimited by new lines'\n \"print {\n color 'red'\n size 'large'\n }\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'hash entries can be written with an equals \"=\" operator'\n \"print {color = 'red', size = 'large'}\" shouldOutput \"{ color: 'red', size: 'large' }\"\n \n it 'can define a hash as a statement'\n \"{color = print 'red', size = print 'large'}\n print 'done'\" shouldOutput \"'red'\n 'large'\n 'done'\"\n \n it 'can define methods for strings'\n \"obj = {'a' () = 'a'}\n print (obj.a ())\" shouldOutput \"'a'\"\n \n it 'can define properties for numbers'\n \"obj = {9 = 9}\n print (obj.(9))\" shouldOutput \"'a'\"\n \n context \"when it doesn't contain hash entries\"\n it 'when it contains a method call, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n console.log ('aaahh!')\n }\"\n }.should.throw r\/cannot be a hash entry\/\n\n it 'when it contains a function call, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n x (1, 23, 3)\n }\"\n }.should.throw r\/cannot be a hash entry\/\n\n it 'when it contains a colon, it should throw a parsing exception'\n @{\n script.evaluate script \"print {\n x: 8\n }\"\n }.should.throw r\/Parse error\/\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"7dcfdf5d0cf6d4937fc1cd417c54206faa872b30","subject":"extending timeout of debug test, seems to take a bit longer on travis","message":"extending timeout of debug test, seems to take a bit longer on travis\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/shell\/pogoSpec.pogo","new_file":"test\/shell\/pogoSpec.pogo","new_contents":"path = require 'path'\nfs = require 'fs'\nscript = require '.\/pogoAssertions'\nwith args should output = script.with args should output\nchild process = require 'child_process'\nnet = require 'net'\n\ndescribe 'pogo command'\n it \"`process.argv` contains 'pogo', the name of the\n script executed, and the arguments from the command line\" @(done)\n \n 'console.log (process.argv)' with args ['one', 'two'] should output \"[ 'pogo',\n '#(path.resolve '343111c34d666435dd7e88265c816cbfdbe68cd3.pogo')',\n 'one',\n 'two' ]\" (done)\n\n it \"`__filename` should be the name of the script\" @(done)\n 'console.log (__filename)' with args [] should output (path.resolve \"5be55a44c52f14d048d19c020fd913199ae2e61c.pogo\") (done)\n\n it \"`__dirname` should be the name of the script\" @(done)\n 'console.log (__dirname)' with args [] should output (path.resolve \".\") (done)\n \n it \"runs script files even if they don't use the .pogo extension\" @(done)\n 'console.log \"hi\"' with args [] should output 'hi' (script filename: 'ascript', done)\n \n it \"script can take same switches as pogo script, like --compile\" @(done)\n 'console.log (process.argv)' with args ['--compile'] should output \"[ 'pogo',\n '#(path.resolve '343111c34d666435dd7e88265c816cbfdbe68cd3.pogo')',\n '--compile' ]\" (done)\n\nwrite file (filename, content, done) =\n fs.write file (\"#(__dirname)\/#(filename)\", content, done)\n\nexpand pogo command (command) =\n if (r\/^pogo( |$)\/.test (command))\n pogo = __dirname + \"\/..\/..\/bin\/pogo\"\n\n command.replace r\/^pogo\/ (pogo)\n else\n command\n \nspawn (command, args, done) =\n process = child process.spawn (expand pogo command (command), args, {cwd = __dirname, custom fds = [0, 1, 2]})\n done (nil, process)\n\nrun (command, callback) =\n expanded command = expand pogo command (command)\n child process.exec (expanded command, {cwd = __dirname}) @(error, stdout, stderr)\n callback (error, {stdout = stdout, stderr = stderr})\n\ndescribe 'pogo --compile'\n after each\n fs.unlink! \"#(__dirname)\/toCompile.pogo\"\n fs.unlink! \"#(__dirname)\/toCompile.js\"\n\n it 'can compile a script'\n write file! \"toCompile.pogo\" \"console.log 'hi'\"\n pogo output = run! \"pogo -c toCompile.pogo\"\n pogo output.stdout.should.equal ''\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"hi\\n\"\n node output.stderr.should.equal ''\n\n(n)ms = n\n(n)s = n * 1000\n\nwait (milliseconds, do something) =\n set timeout (do something, milliseconds)\n\nunlink! (file) =\n try\n fs.unlink! (file)\n catch (error)\n if (error.code != 'ENOENT')\n throw (error)\n\n \/\/ bug #6, remove this\n nil\n\ndescribe 'pogo --help'\n it 'prints out help'\n pogo output = run! \"pogo --help\"\n\n pogo output.stdout.should.match r\/usage:\/\n pogo output.stdout.should.match r\/--compile\/\n pogo output.stdout.should.match r\/--watch\/\n\ndescribe 'pogo --compile --if-stale'\n before each\n unlink! \"#(__dirname)\/toCompile.pogo\"\n unlink! \"#(__dirname)\/toCompile.js\"\n\n after each\n unlink! \"#(__dirname)\/toCompile.pogo\"\n unlink! \"#(__dirname)\/toCompile.js\"\n\n it 'compiles a pogo script if the js is missing'\n write file! \"toCompile.pogo\" \"console.log 'hi'\"\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"hi\\n\"\n node output.stderr.should.equal ''\n\n it 'compiles a pogo script if the js is out of date'\n write file! \"toCompile.js\" \"console.log('old')\"\n wait! (1s)\n write file! \"toCompile.pogo\" \"console.log 'new'\"\n\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"new\\n\"\n node output.stderr.should.equal ''\n\n it \"doesn't recompile the js if it the pogo is older\"\n write file! \"toCompile.pogo\" \"console.log 'pogo'\"\n wait! (1s)\n write file! \"toCompile.js\" \"console.log('js')\"\n\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal ''\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"js\\n\"\n node output.stderr.should.equal ''\n\ndescribe 'debugging'\n describe '--debug'\n this.timeout 3000\n\n it 'starts remote debugging'\n write file! \"toDebug.pogo\" \"console.log 'bug!'\"\n pogo output = run! 'pogo --debug toDebug.pogo'\n pogo output.stderr.should.equal \"debugger listening on port 5858\\n\"\n pogo output.stdout.should.equal \"bug!\\n\"\n\ndescribe '`pogo` (interactive)'\n util = require 'util'\n\n pogo session () =\n pogo = child process.spawn (expand pogo command 'pogo', []) {\n cwd = __dirname\n stdio = 'pipe'\n }\n\n handle result = nil\n current output = ''\n first prompt = true\n\n pogo.stdout.on 'data' @(data)\n out = data.to string ()\n current output := current output + out\n if (r\/^> $\/m.test (current output))\n command output = current output.replace (r\/\\n?> $\/, '')\n current output := ''\n if (first prompt)\n first prompt := false\n else\n handle result (command output)\n\n pogo.stderr.on 'data' @(data)\n console.log 'error'\n console.log (data.to string ())\n\n {\n issue (command) and expect (result, done) =\n handle result (actual result) :=\n actual result.should.equal (result)\n done ()\n\n pogo.stdin.write \"#(command)\\n\"\n\n exit (done) =\n pogo.on 'exit' @(code)\n done (nil, code)\n\n pogo.stdin.end ()\n }\n\n it 'evaluates a simple line of pogoscript'\n pogo = pogo session ()\n pogo.issue '8' and expect! '8'\n pogo.exit!\n\n it 'variables are shared among different lines'\n pogo = pogo session ()\n pogo.issue 'a = 8' and expect! '8'\n pogo.issue 'a' and expect! '8'\n pogo.exit!\n","old_contents":"path = require 'path'\nfs = require 'fs'\nscript = require '.\/pogoAssertions'\nwith args should output = script.with args should output\nchild process = require 'child_process'\nnet = require 'net'\n\ndescribe 'pogo command'\n it \"`process.argv` contains 'pogo', the name of the\n script executed, and the arguments from the command line\" @(done)\n \n 'console.log (process.argv)' with args ['one', 'two'] should output \"[ 'pogo',\n '#(path.resolve '343111c34d666435dd7e88265c816cbfdbe68cd3.pogo')',\n 'one',\n 'two' ]\" (done)\n\n it \"`__filename` should be the name of the script\" @(done)\n 'console.log (__filename)' with args [] should output (path.resolve \"5be55a44c52f14d048d19c020fd913199ae2e61c.pogo\") (done)\n\n it \"`__dirname` should be the name of the script\" @(done)\n 'console.log (__dirname)' with args [] should output (path.resolve \".\") (done)\n \n it \"runs script files even if they don't use the .pogo extension\" @(done)\n 'console.log \"hi\"' with args [] should output 'hi' (script filename: 'ascript', done)\n \n it \"script can take same switches as pogo script, like --compile\" @(done)\n 'console.log (process.argv)' with args ['--compile'] should output \"[ 'pogo',\n '#(path.resolve '343111c34d666435dd7e88265c816cbfdbe68cd3.pogo')',\n '--compile' ]\" (done)\n\nwrite file (filename, content, done) =\n fs.write file (\"#(__dirname)\/#(filename)\", content, done)\n\nexpand pogo command (command) =\n if (r\/^pogo( |$)\/.test (command))\n pogo = __dirname + \"\/..\/..\/bin\/pogo\"\n\n command.replace r\/^pogo\/ (pogo)\n else\n command\n \nspawn (command, args, done) =\n process = child process.spawn (expand pogo command (command), args, {cwd = __dirname, custom fds = [0, 1, 2]})\n done (nil, process)\n\nrun (command, callback) =\n expanded command = expand pogo command (command)\n child process.exec (expanded command, {cwd = __dirname}) @(error, stdout, stderr)\n callback (error, {stdout = stdout, stderr = stderr})\n\ndescribe 'pogo --compile'\n after each\n fs.unlink! \"#(__dirname)\/toCompile.pogo\"\n fs.unlink! \"#(__dirname)\/toCompile.js\"\n\n it 'can compile a script'\n write file! \"toCompile.pogo\" \"console.log 'hi'\"\n pogo output = run! \"pogo -c toCompile.pogo\"\n pogo output.stdout.should.equal ''\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"hi\\n\"\n node output.stderr.should.equal ''\n\n(n)ms = n\n(n)s = n * 1000\n\nwait (milliseconds, do something) =\n set timeout (do something, milliseconds)\n\nunlink! (file) =\n try\n fs.unlink! (file)\n catch (error)\n if (error.code != 'ENOENT')\n throw (error)\n\n \/\/ bug #6, remove this\n nil\n\ndescribe 'pogo --help'\n it 'prints out help'\n pogo output = run! \"pogo --help\"\n\n pogo output.stdout.should.match r\/usage:\/\n pogo output.stdout.should.match r\/--compile\/\n pogo output.stdout.should.match r\/--watch\/\n\ndescribe 'pogo --compile --if-stale'\n before each\n unlink! \"#(__dirname)\/toCompile.pogo\"\n unlink! \"#(__dirname)\/toCompile.js\"\n\n after each\n unlink! \"#(__dirname)\/toCompile.pogo\"\n unlink! \"#(__dirname)\/toCompile.js\"\n\n it 'compiles a pogo script if the js is missing'\n write file! \"toCompile.pogo\" \"console.log 'hi'\"\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"hi\\n\"\n node output.stderr.should.equal ''\n\n it 'compiles a pogo script if the js is out of date'\n write file! \"toCompile.js\" \"console.log('old')\"\n wait! (1s)\n write file! \"toCompile.pogo\" \"console.log 'new'\"\n\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"new\\n\"\n node output.stderr.should.equal ''\n\n it \"doesn't recompile the js if it the pogo is older\"\n write file! \"toCompile.pogo\" \"console.log 'pogo'\"\n wait! (1s)\n write file! \"toCompile.js\" \"console.log('js')\"\n\n pogo output = run! \"pogo -cs toCompile.pogo\"\n pogo output.stdout.should.equal ''\n pogo output.stderr.should.equal ''\n\n node output = run! \"node toCompile.js\"\n node output.stdout.should.equal \"js\\n\"\n node output.stderr.should.equal ''\n\ndescribe 'debugging'\n describe '--debug'\n it 'starts remote debugging'\n write file! \"toDebug.pogo\" \"console.log 'bug!'\"\n pogo output = run! 'pogo --debug toDebug.pogo'\n pogo output.stderr.should.equal \"debugger listening on port 5858\\n\"\n pogo output.stdout.should.equal \"bug!\\n\"\n\ndescribe '`pogo` (interactive)'\n util = require 'util'\n\n pogo session () =\n pogo = child process.spawn (expand pogo command 'pogo', []) {\n cwd = __dirname\n stdio = 'pipe'\n }\n\n handle result = nil\n current output = ''\n first prompt = true\n\n pogo.stdout.on 'data' @(data)\n out = data.to string ()\n current output := current output + out\n if (r\/^> $\/m.test (current output))\n command output = current output.replace (r\/\\n?> $\/, '')\n current output := ''\n if (first prompt)\n first prompt := false\n else\n handle result (command output)\n\n pogo.stderr.on 'data' @(data)\n console.log 'error'\n console.log (data.to string ())\n\n {\n issue (command) and expect (result, done) =\n handle result (actual result) :=\n actual result.should.equal (result)\n done ()\n\n pogo.stdin.write \"#(command)\\n\"\n\n exit (done) =\n pogo.on 'exit' @(code)\n done (nil, code)\n\n pogo.stdin.end ()\n }\n\n it 'evaluates a simple line of pogoscript'\n pogo = pogo session ()\n pogo.issue '8' and expect! '8'\n pogo.exit!\n\n it 'variables are shared among different lines'\n pogo = pogo session ()\n pogo.issue 'a = 8' and expect! '8'\n pogo.issue 'a' and expect! '8'\n pogo.exit!\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"02a8b0a613dcf17bfbd06617fc355a878a1e3329","subject":"test for preserving variables in nested scopes","message":"test for preserving variables in nested scopes\n","repos":"featurist\/dslify","old_file":"test\/dslify_test.pogo","new_file":"test\/dslify_test.pogo","new_contents":"dslify = require '..\/index'\nescodegen = require 'escodegen'\nesprima = require 'esprima'\n\n(actual) rewrites as (expected) =\n normalise (dslify.transform (actual)).should.equal (normalise(expected))\n\nnormalise (fn) =\n parsed = esprima.parse \"(#(fn.to string()))\".body.0\n escodegen.generate (parsed).replace \"function anonymous(\" \"function (\"\n\ndescribe 'dslify'\n\n it 'rewrites a function so that global variables become DSL accessors'\n dsl = {\n scream (word) = \"#(word)!!\"\n nice word = \"unicorns\"\n }\n scream it () =\n scream (nice word)\n\n transformed = dslify.transform(scream it)\n transformed(dsl).should.equal \"unicorns!!\"\n\n it 'preserves any existing function parameters'\n dsl = {\n scream (word1, word2) = \"#(word1)!! #(word2)!!\"\n }\n scream them (a, b) =\n scream (a, b)\n\n transformed = dslify.transform(scream them)\n transformed(dsl, \"lasers\", \"sharks\").should.equal \"lasers!! sharks!!\"\n\n it 'rewrites a function with global variables bound to a new _dsl argument'\n @{\n x + y\n } rewrites as @(_dsl)\n _dsl.x + _dsl.y\n\n it 'allows overriding the _dsl argument name'\n multiply (a, b) = a * b * c\n transformed = dslify.transform(multiply, dsl name: \"xx\")\n expected (xx, a, b) = a * b * xx.c\n normalise (transformed).should.equal (normalise(expected))\n\n it 'prepends the _dsl argument to any existing arguments'\n @(a, b) @{\n a + b + x\n } rewrites as @(_dsl, a, b) @{\n a + b + _dsl.x\n }\n\n it 'preserves property accessors'\n @{\n window.foo.bar\n } rewrites as @(_dsl)\n _dsl.window.foo.bar\n\n it 'preserves property literals'\n @{\n foo { a = 1, b = 2 }\n } rewrites as @(_dsl)\n _dsl.foo { a = 1, b = 2 }\n\n it 'preserves variables declared in the outermost scope'\n @{\n foo = 1\n bar { a = foo }\n } rewrites as @(_dsl)\n foo = 1\n _dsl.bar { a = foo }\n\n it 'preserves variables declared in nested scopes'\n @{\n foo\n bar = 1\n { a = bar }\n } rewrites as @(_dsl)\n _dsl.foo\n bar = 1\n { a = bar }\n\n it 'preserves nested function parameters'\n fn (x) =\n foo (a, b) @(c, d)\n x.bar(baz(a, b, c, d))\n bar (c) @(x)\n c + x\n\n (fn) rewrites as @(_dsl, x)\n _dsl.foo (_dsl.a, _dsl.b) @(c, d)\n x.bar(_dsl.baz(_dsl.a, _dsl.b, c, d))\n _dsl.bar (c) @(x)\n c + x\n","old_contents":"dslify = require '..\/index'\nescodegen = require 'escodegen'\nesprima = require 'esprima'\n\n(actual) rewrites as (expected) =\n normalise (dslify.transform (actual)).should.equal (normalise(expected))\n\nnormalise (fn) =\n parsed = esprima.parse \"(#(fn.to string()))\".body.0\n escodegen.generate (parsed).replace \"function anonymous(\" \"function (\"\n\ndescribe 'dslify'\n\n it 'rewrites a function so that global variables become DSL accessors'\n dsl = {\n scream (word) = \"#(word)!!\"\n nice word = \"unicorns\"\n }\n scream it () =\n scream (nice word)\n\n transformed = dslify.transform(scream it)\n transformed(dsl).should.equal \"unicorns!!\"\n\n it 'preserves any existing function parameters'\n dsl = {\n scream (word1, word2) = \"#(word1)!! #(word2)!!\"\n }\n scream them (a, b) =\n scream (a, b)\n\n transformed = dslify.transform(scream them)\n transformed(dsl, \"lasers\", \"sharks\").should.equal \"lasers!! sharks!!\"\n\n it 'rewrites a function with global variables bound to a new _dsl argument'\n @{\n x + y\n } rewrites as @(_dsl)\n _dsl.x + _dsl.y\n\n it 'allows overriding the _dsl argument name'\n multiply (a, b) = a * b * c\n transformed = dslify.transform(multiply, dsl name: \"xx\")\n expected (xx, a, b) = a * b * xx.c\n normalise (transformed).should.equal (normalise(expected))\n\n it 'prepends the _dsl argument to any existing arguments'\n @(a, b) @{\n a + b + x\n } rewrites as @(_dsl, a, b) @{\n a + b + _dsl.x\n }\n\n it 'preserves property accessors'\n @{\n window.foo.bar\n } rewrites as @(_dsl)\n _dsl.window.foo.bar\n\n it 'preserves property literals'\n @{\n foo { a = 1, b = 2 }\n } rewrites as @(_dsl)\n _dsl.foo { a = 1, b = 2 }\n\n it 'preserves variables declared in the outermost scope'\n @{\n foo = 1\n bar { a = foo }\n } rewrites as @(_dsl)\n foo = 1\n _dsl.bar { a = foo }\n\n it 'preserves nested function parameters'\n fn (x) =\n foo (a, b) @(c, d)\n x.bar(baz(a, b, c, d))\n bar (c) @(x)\n c + x\n\n (fn) rewrites as @(_dsl, x)\n _dsl.foo (_dsl.a, _dsl.b) @(c, d)\n x.bar(_dsl.baz(_dsl.a, _dsl.b, c, d))\n _dsl.bar (c) @(x)\n c + x\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"18f21e1605231b48924cc32da67a4c8ef7ca4d78","subject":"fixed broken for each in versions","message":"fixed broken for each in versions\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"lib\/versions.pogo","new_file":"lib\/versions.pogo","new_contents":"_ = require 'underscore'\n\nexports.(a) is less than (b) =\n parse version (v) =\n if (v.0 == 'v')\n v := v.substring (1)\n\n v.split '.'\n\n compare (v1, v2) =\n if (v1 > v2)\n 1\n else if (v2 > v1)\n -1\n else\n 0\n\n for each @(version numbers) in (_.zip (parse version (a), parse version (b)))\n comparison = compare (version numbers.0, version numbers.1)\n\n if (comparison)\n return (comparison < 0)\n \n false\n","old_contents":"_ = require 'underscore'\n\nexports.(a) is less than (b) =\n parse version (v) =\n if (v.0 == 'v')\n v := v.substring (1)\n\n v.split '.'\n\n compare (v1, v2) =\n if (v1 > v2)\n 1\n else if (v2 > v1)\n -1\n else\n 0\n\n for each @(version numbers) in (_.zip (parse version (a), parse version (b))) @(version number)\n comparison = compare (version numbers.0, version numbers.1)\n\n if (comparison)\n return (comparison < 0)\n \n false\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"80cf9e5b2b9d390d405be90dcbf8e40ae22726cd","subject":"improved when example","message":"improved when example\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"examples\/when.pogo","new_file":"examples\/when.pogo","new_contents":"is (expected) (action) =\n action if (actual) matched =\n if (expected == actual)\n action\n\notherwise (action) =\n action if (actual) matched =\n action\n\nwhen (actual, cases, ...) =\n for each @(action if matched) in (cases)\n action = action if (actual) matched\n if (action)\n return (action ())\n\nprint (args, ...) = console.log (args, ...)\n\nx = 2\n\nwhen (x) (\n is 0\n print \"x is zero\"\n\n is 1\n print \"x is one\"\n\n otherwise\n print \"x is not zero or one\"\n)\n","old_contents":"is (expected) (action) =\n action if (actual) matched =\n if (expected == actual)\n action\n\notherwise (action) =\n action if (actual) matched =\n action\n\nwhen (actual, cases) =\n for each @(action if matched) in (cases)\n action = action if (actual) matched\n if (action)\n return (action ())\n\nprint (args, ...) = console.log (args, ...)\n\nx = 2\n\nwhen (x) [\n is 0\n print \"x is zero\"\n\n is 1\n print \"x is one\"\n\n otherwise\n print \"x is not zero or one\"\n]\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"f9da8321dfd3612f620ce31311cda178530cea29","subject":"if bug","message":"if bug\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/ifSpec.pogo","new_file":"test\/ifSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\n\nshouldOutput = script.shouldOutput\n\ndescribe 'if'\n describe 'evaluation'\n it \"returns the body\"\n 'print (\n if (true)\n \"true\"\n else\n \"false\"\n )' shouldOutput \"'true'\"\n\n describe 'promises'\n context 'when there no else clause'\n it 'resolves promises when in the then clause'\n 'result = if (true)\n p ()!\n \"result\"\n \n print (result)' shouldOutput \"'result'\"\n\n context 'when there is an else clause'\n it 'resolves promises when in the else clause'\n 'result = if (false)\n p ()!\n print \"then\"\n else\n p()!\n print \"else\"\n \"result\"\n \n print (result)' shouldOutput \"'else'\n 'result'\"\n\n context 'when there are if else and else clauses'\n it 'resolves promises when in the else clause'\n 'result = if (false)\n p ()!\n print \"then\"\n else if (true)\n p()!\n print \"else if\"\n \"result\"\n else\n p()!\n print \"else\"\n \n print (result)' shouldOutput \"'else if'\n 'result'\"\n\n describe 'executing only enough conditions to find a true one'\n it 'only executes the first one'\n 'condition (n, c) =\n p()!\n print \"condition: #(n)\"\n c\n\n result = if (condition (1, true)!)\n p ()!\n 1\n else if (condition (2, true)!)\n p()!\n 2\n else\n 3\n \n print (result)' shouldOutput \"'condition: 1'\n 1\"\n\n it 'executes the first and second'\n 'condition (n, c) =\n p()!\n print \"condition: #(n)\"\n c\n\n result = if (condition (1, false)!)\n p ()!\n 1\n else if (condition (2, true)!)\n p()!\n 2\n else\n 3\n \n print (result)' shouldOutput \"'condition: 1'\n 'condition: 2'\n 2\"\n","old_contents":"script = require '.\/scriptAssertions'\n\nshouldOutput = script.shouldOutput\n\ndescribe 'if'\n describe 'evaluation'\n it \"returns the body\"\n 'print (\n if (true)\n \"true\"\n else\n \"false\"\n )' shouldOutput \"'true'\"\n\n describe 'promises'\n context 'when there no else clause'\n it 'resolves promises when in the then clause'\n 'result = if (true)\n p ()!\n \"result\"\n \n print (result)' shouldOutput \"'result'\"\n\n context 'when there is an else clause'\n it 'resolves promises when in the else clause'\n 'result = if (false)\n p ()!\n print \"then\"\n else\n p()!\n print \"else\"\n \"result\"\n \n print (result)' shouldOutput \"'else'\n 'result'\"\n\n context 'when there are if else and else clauses'\n it 'resolves promises when in the else clause'\n 'result = if (false)\n p ()!\n print \"then\"\n else if (true)\n p()!\n print \"else if\"\n \"result\"\n else\n p()!\n print \"else\"\n \n print (result)' shouldOutput \"'else if'\n 'result'\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"2b7ed3ef607cc083f9cb3ef6e383a659f4d5e04a","subject":"rename","message":"rename\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/commandLine.pogo","new_file":"src\/bootstrap\/commandLine.pogo","new_contents":"fs = require 'fs'\npreparser = require '.\/preparser'\nms = require '..\/lib\/memorystream'\nparse = require '.\/parser': parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\n\npreparse = preparser: create file parser!\n\ngenerate code @term =\n memory stream = new (ms: MemoryStream)\n term: generate java script (memory stream)\n memory stream: to string?\n\nbeautify @code =\n ast = uglify: parser: parse @code\n uglify: uglify: gen_code @ast, beautify\n\nexports: compile file @filename, ugly =\n js = js from pogo file @filename\n if (not @ugly)\n js = beautify @js\n \n js filename = js filename from pogo filename @filename\n fs: write file sync (js filename) @js\n\nexports: preparse file @filename =\n contents = fs: read file sync @filename 'utf-8'\n preparsed pogo = preparse @contents\n console: log (preparsed pogo)\n\njs filename from pogo filename @pogo =\n pogo: replace (new (RegExp '\\.pogo$')) '' + '.js'\n\nexports: run file @filename =\n js = js from pogo file @filename\n \n module: filename = fs: realpath sync @filename\n process: argv: 1 = module: filename\n module: _compile @js @filename\n\njs from pogo file @filename =\n contents = fs: read file sync @filename 'utf-8'\n p = preparse @contents\n term = parse @p\n \n if (errors: has errors?)\n errors: print errors (source location printer, filename @filename, source @contents)\n process: exit 1\n else\n generate code @term\n\nsource location printer, filename, source =\n object =>\n :lines in range @range =\n lines = source: split (new (RegExp '\\n'))\n lines: slice (range:from - 1) (range:to)\n\n :print lines in range, prefix '', from, to =\n for each ?line in (:lines in range, from @from, to @to)\n process:stderr:write (prefix + line + '\\n')\n\n :print location @location =\n process:stderr:write (filename + ':' + location: first line + '\\n')\n \n if (location: first line == location: last line)\n :print lines in range, from (location: first line), to (location: last line)\n spaces = :' ' times (location: first column)\n markers = :'^' times (location: last column - location:first column)\n process:stderr:write (spaces + markers + '\\n')\n else\n :print lines in range, prefix '> ', from (location: first line), to (location: last line)\n\n :@s times @n =\n strings = []\n for {i = 0} {i < n} {i = i + 1}\n strings: push @s\n\n strings: join ''\n\nrequire: extensions: '.pogo' = ?module ?filename\n content = js from pogo file @filename\n module: _compile @content @filename\n","old_contents":"fs = require 'fs'\npreparser = require '.\/preparser'\nms = require '..\/lib\/memorystream'\nparse = require '.\/parser': parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\n\npreparse = preparser: create file parser!\n\ngenerate code @term =\n memory stream = new (ms: MemoryStream)\n term: generate java script (memory stream)\n memory stream: to string?\n\nbeautify @code =\n ast = uglify: parser: parse @code\n uglify: uglify: gen_code @ast, beautify\n\nexports: compile file @filename, ugly =\n js = js from pogo file @filename\n if (not @ugly)\n js = beautify @js\n \n js filename = js filename from pogo filename @filename\n fs: write file sync (js filename) @js\n\nexports: preparse file @filename =\n contents = fs: read file sync @filename 'utf-8'\n preparsed pogo = preparse @contents\n console: log (preparsed pogo)\n\njs filename from pogo filename @pogo =\n pogo: replace (new (RegExp '\\.pogo$')) '' + '.js'\n\nexports: run file @filename =\n js = js from pogo file @filename\n \n module: filename = fs: realpath sync @filename\n process: argv: 1 = module: filename\n module: _compile @js @filename\n\njs from pogo file @filename =\n contents = fs: read file sync @filename 'utf-8'\n p = preparse @contents\n term = parse @p\n \n if (errors: has errors?)\n errors: print errors (source location printer, filename @filename, source @contents)\n process: exit 1\n else\n generate code @term\n\nsource location printer, filename, source =\n object =>\n :lines in range @range =\n lines = source: split (new (RegExp '\\n'))\n lines: slice (range:from - 1) (range:to)\n\n :print lines in range, prefix '', from, to =\n for each ?line in (:lines in range, from @from, to @to)\n process:stderr:write (prefix + line + '\\n')\n\n :print location @location =\n process:stderr:write (filename + ':' + location: first line + '\\n')\n \n if (location: first line == location: last line)\n :print lines in range, from (location: first line), to (location: last line)\n spaces = :duplicate string ' ' (location: first column) times\n markers = :duplicate string '^' (location: last column - location:first column) times\n process:stderr:write (spaces + markers + '\\n')\n else\n :print lines in range, prefix '> ', from (location: first line), to (location: last line)\n\n :duplicate string @s @n times =\n strings = []\n for {i = 0} {i < n} {i = i + 1}\n strings: push @s\n\n strings: join ''\n\nrequire: extensions: '.pogo' = ?module ?filename\n content = js from pogo file @filename\n module: _compile @content @filename\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"ba6f0e98c28f28c50cfb081aa630408a11eff71b","subject":"fixed failing test for async function in parser","message":"fixed failing test for async function in parser\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/parserSpec.pogo","new_file":"test\/parserSpec.pogo","new_contents":"require '.\/assertions'\n\nparser = require '..\/src\/bootstrap\/parser'\nrequire '.\/parserAssertions'\n\ndescribe 'parser'\n describe 'terminals'\n it 'integer'\n (expression '5') should contain fields {\n integer 5\n }\n\n it 'float'\n (expression '5.6') should contain fields {\n float 5.6\n }\n\n describe 'variables'\n it 'simple'\n (expression 'total weight') should contain fields {\n variable ['total', 'weight']\n }\n\n it 'can use $ as a variable'\n (expression '$') should contain fields {\n variable ['$']\n }\n \n describe 'strings'\n it 'simple string'\n (expression '''a string''') should contain fields {\n is string\n string 'a string'\n }\n \n it 'string with single quotes'\n (expression '''''''alright!'''' he said''') should contain fields {\n is string\n string '''alright!'' he said'\n }\n \n it 'string with backslash'\n (expression \"'one \\\\ two'\") should contain fields {\n is string\n string \"one \\\\ two\"\n }\n \n it 'multiline string'\n (expression \" 'one\\n two'\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'multiline double-quote string'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'two multiline string in function'\n (expression \"x 'one\\n two' y \\\"three\\n four\\\"\") should contain fields {\n is function call\n function {variable ['x', 'y']}\n function arguments [\n {string \"one\\ntwo\"}\n {string \"three\\nfour\"}\n ]\n }\n\n describe 'interpolated strings'\n it 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n it 'empty'\n (expression '\"\"') should contain fields {\n is string\n string ''\n }\n\n it 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with newline escape and indentation should not remove indentation'\n (expression ' \"one\\n two\"') should contain fields {\n string \"one\\n two\"\n }\n\n it 'with indentation'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with single variable expression'\n (expression '\"a boat #(boat length) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['boat', 'length']}\n {string ' meters in length'}\n ]\n }\n\n it 'with hash # character at end'\n (expression '\"this is a hash: #\"') should contain fields {\n is string\n string 'this is a hash: #'\n }\n\n it 'with hash # character in middle'\n (expression '\"this is a hash: #, ok?\"') should contain fields {\n is string\n string 'this is a hash: #, ok?'\n }\n\n it 'with escaped #'\n (expression '\"a boat \\#(boat length) meters in length\"') should contain fields {\n is string\n string 'a boat #(boat length) meters in length'\n }\n\n it 'with complex expression'\n (expression '\"a boat #(lookup boat length from (boat database)) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n function {variable ['lookup', 'boat', 'length', 'from']}\n function arguments [{variable ['boat', 'database']}]\n }\n {string ' meters in length'}\n ]\n }\n \n it 'in block'\n (expression \"abc =\\n \\\"\\#(stuff)\\\"\") should contain fields {\n is definition\n target {\n is variable\n variable ['abc']\n }\n source {\n is scope\n statements [{\n is variable\n variable ['stuff']\n }]\n }\n }\n\n it 'with inner interpolation'\n (expression '\"a boat #(\"#(boat length) meters\") in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n is interpolated string\n components [\n {variable ['boat', 'length']}\n {string ' meters'}\n ]\n }\n {string ' in length'}\n ]\n }\n\n describe 'sub expressions'\n it 'single expression'\n (expression '(x)') should contain fields {variable ['x']}\n \n describe 'lists'\n it 'empty'\n (expression '[]') should contain fields {\n is list\n items []\n }\n \n it 'one item'\n (expression '[1]') should contain fields {\n is list\n items [{integer 1}]\n }\n \n it 'two items'\n (expression '[1, 2]') should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n it 'two items separated by newlines'\n (expression \"[\\n 1\\n 2\\n]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n describe 'hashes'\n it 'empty hash'\n (expression '{}') should contain fields {\n is hash\n entries []\n }\n \n it 'hash with one entry'\n (expression '{port 1234}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n it 'hash with two entries'\n (expression '{port 1234, ip address ''1.1.1.1''}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n {\n field ['ip', 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with two entries on different lines'\n (expression \"{port = 1234\\nip address = '1.1.1.1'}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['ip', 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with string with assignment'\n (expression \"{'port' = 1234}\") should contain fields {\n is hash\n entries [\n {\n field {string 'port'}\n value {integer 1234}\n }\n ]\n }\n \n it 'values can be specified on a new line'\n (expression \"{\n height =\n 80\n }\") should contain fields {\n is hash\n entries [\n {\n field ['height']\n value {\n is scope\n statements [{integer 80}]\n }\n }\n ]\n }\n \n it 'should allow methods to be defined, redefining self'\n (expression '{say hi to (name, greeting: nil) = print (name)}') should contain fields {\n is hash\n entries [\n {\n field ['say', 'hi', 'to']\n value {\n is block\n redefines self\n\n body {\n statements [{\n is function call\n\n function {variable ['print']}\n }]\n }\n\n parameters [{variable ['name']}]\n\n optional parameters [{\n is hash entry\n field ['greeting']\n }]\n }\n }\n ]\n }\n \n it 'hash with true entry'\n (expression '{port 1234, readonly}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['readonly']\n value (undefined)\n }\n ]\n }\n\n describe 'function calls'\n it 'function call'\n (expression 'touch (file)') should contain fields {\n function {variable ['touch']}\n function arguments [{variable ['file']}]\n }\n\n it 'function call with two arguments in parens'\n (expression 'f (a, b)') should contain fields {\n function {variable ['f']}\n function arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'two expressions'\n (expression '(x, y)') should contain fields {\n is function call\n function {variable ['x']}\n function arguments [\n {variable ['y']}\n ]\n }\n\n it 'function call with splat argument'\n (expression 'touch (files) ...') should contain fields {\n function {variable ['touch']}\n function arguments [\n {variable ['files']}\n {is splat}\n ]\n }\n\n it 'function call with no argument'\n (expression 'delete everything ()') should contain fields {\n function {variable ['delete', 'everything']}\n function arguments []\n }\n\n it 'async function call with no arguments'\n (expression 'delete everything!') should contain fields {\n is statements\n statements [\n {\n is definition\n target { is variable, name ['async', 'result'] }\n source {\n function {variable ['delete', 'everything']}\n function arguments []\n }\n }\n { is variable, name ['async', 'result'] }\n ]\n }\n\n it 'function call with block with parameters'\n (expression \"with file (file) @(stream)\\n stream\") should contain fields {\n function {variable ['with', 'file']}\n function arguments [\n {variable ['file']}\n {\n body {statements [{variable ['stream']}]}\n parameters [{variable ['stream']}]\n }\n ]\n }\n\n it 'function call with block with long parameters'\n (expression \"open database @(database connection)\\n database connection\") should contain fields {\n function {variable ['open', 'database']}\n function arguments [\n {\n parameters [\n {variable ['database', 'connection']}\n ]\n body {statements [{variable ['database', 'connection']}]}\n }\n ]\n }\n\n it 'function call with two blocks with parameters'\n (expression 'name @(x) @{x} @ (y) @ {y}') should contain fields {\n function {variable ['name']}\n function arguments [\n {\n body {statements [{variable ['x']}]}\n parameters [{variable ['x']}]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{variable ['y']}]\n }\n ]\n }\n\n it 'function call with two optional arguments'\n (expression 'name (a, port: 34, server: s)') should contain fields {\n function {variable ['name']}\n function arguments [\n {variable ['a']}\n ]\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n {\n field ['server']\n value {variable ['s']}\n }\n ]\n }\n \n describe 'object operations'\n it 'method call'\n (expression 'object.method (argument)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments [{variable ['argument']}]\n }\n \n it 'method call with optional arguments'\n (expression 'object.method (argument, view: view)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments [{variable ['argument']}]\n optional arguments [\n {field ['view'], value {variable ['view']}}\n ]\n }\n \n it 'field reference'\n (expression 'object.field') should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'field reference with newline'\n (expression \"object.\\nfield\") should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'indexer'\n (expression 'object.(x)') should contain fields {\n is indexer\n object {variable ['object']}\n indexer {variable ['x']}\n }\n \n it 'parses no argument method with ()'\n (expression 'object.method()') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n \n it 'parses no argument method with () and field'\n (expression 'object.method().field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n \n it 'parses no argument method with ! and field'\n (expression 'object.method! . field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n \n it 'parses no argument method with ! and field'\n (expression 'object.method!.field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n\n describe 'blocks'\n it 'empty block'\n (expression '@{}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements []}\n }\n \n it 'block'\n (expression '@{x, y}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements [\n {variable ['x']}\n {variable ['y']}\n ]}\n }\n\n it 'block with parameter'\n (expression \"@(x)\\n x, y\") should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (false)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n it 'block in parens'\n (expression \"(one\\n two\\n)\") should contain fields {\n is function call\n function {variable ['one']}\n function arguments [\n {\n is block\n body {\n statements [\n {variable ['two']}\n ]\n }\n }\n ]\n }\n\n it 'block with parameter, redefining self'\n (expression '@(x) => @{x, y}') should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (true)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n describe 'statements'\n it 'can be separated by commas (,)'\n (statements 'a, b') should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'can be separated by unix new lines'\n (statements \"a\\nb\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'can be separated by windows new lines'\n (statements \"a\\r\\nb\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'windows indentation'\n (statements \"app (stuff) =\\r\n ok\\r\n \\r\n url (path) =\\r\n ok\") should contain fields {\n statements [\n {is definition}\n {is definition}\n ]\n }\n\n describe 'operators'\n it 'should be lower precedence than object operation'\n (expression 'o.m 2 +- o.x') should contain fields {\n is method call\n object {\n is method call\n object {variable ['o']}\n name ['m']\n method arguments [{integer 2}]\n }\n \n name ['+-']\n method arguments [\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n ]\n }\n \n it 'parses backslash'\n (expression \"2 +\\\\+ 1\") should contain fields {\n is method call\n object {integer 2}\n \n name [\"+\\\\+\"]\n method arguments [\n {integer 1}\n ]\n }\n \n it 'unary operators should be higher precedence than binary operators'\n (expression 'a && ! b') should contain fields {\n is operator\n operator '&&'\n \n operator arguments [\n {variable ['a']}\n {\n is operator\n operator '!'\n operator arguments [{variable ['b']}]\n }\n ]\n }\n \n it 'can have newlines immediately after operator'\n (expression \"a &&\\nb\") should contain fields {\n is operator\n operator '&&'\n \n operator arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n describe 'assignment'\n it 'assignment'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n describe 'function definition'\n it 'function with one parameter'\n (expression 'func (x) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'function with one parameter, and one optional parameter'\n (expression 'func (x, port: 80) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n optional parameters [{field ['port'], value {integer 80}}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'field assignment'\n (expression 'o.x = y') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n\n source {variable ['y']}\n }\n\n it 'index assignment'\n (expression 'o.(x) = y') should contain fields {\n is definition\n target {\n is indexer\n object {variable ['o']}\n indexer {variable ['x']}\n }\n\n source {variable ['y']}\n }\n\n it 'assignment from field'\n (expression 'x = y.z') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is field reference\n object {\n variable ['y']\n }\n\n name ['z']\n }\n }\n\n it 'assignment of command'\n (expression 'x! = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'definition of function with no arguments, using empty parens \"()\"'\n (expression 'x () = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'assignment from method call'\n (expression 'x = y.z (a)') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n method arguments [{variable ['a']}]\n }\n }\n\n it 'field assignment from method call'\n (expression 'i.x = y.z (a)') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['i']}\n name ['x']\n }\n\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n method arguments [{variable ['a']}]\n }\n }\n \n describe 'regexps'\n it 'simple'\n (expression 'r\/abc\/') should contain fields {\n is reg exp\n pattern 'abc'\n }\n\n it 'with options'\n (expression 'r\/abc\/img') should contain fields {\n is reg exp\n pattern 'abc'\n options 'img'\n }\n\n it 'with escaped back ticks'\n (expression 'r\/abc\\\/def\\\/ghi\/') should contain fields {\n is reg exp\n pattern 'abc\/def\/ghi'\n }\n\n it 'with various escapes'\n (expression 'r\/abc\\\/def\\nghi\\\/jkl\/') should contain fields {\n is reg exp\n pattern 'abc\/def\\nghi\/jkl'\n }\n\n it 'with newline'\n (expression \"a = r\/abc\\n def\/\") should contain fields {\n is definition\n target {\n is variable\n variable ['a']\n }\n source {\n is reg exp\n pattern \"abc\\\\ndef\"\n }\n }\n \n describe 'comments'\n it 'should not treat comment-like syntax as comments in strings'\n (statements \"get 'http:\/\/pogoscript.org\/'\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['get']}\n function arguments [\n {string 'http:\/\/pogoscript.org\/'}\n ]\n }]\n }\n \n describe 'should allow one-line C++ style comments, as in: \/\/ this is a comment'\n it 'when at the end of a line'\n (statements \"a \/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n it 'when before an indented block'\n (statements \"a \/\/ this is a comment\\n b\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['a']}\n function arguments [{\n is block\n body {\n statements [\n {variable ['b']}\n ]\n }\n }]\n }]\n }\n\n it 'when at end of file'\n (statements \"a \/\/ this is a comment\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n describe 'should allow multi-line C style comments, as in: \/* this is a comment *\/'\n it 'when on one line'\n (statements \"a \/* comment *\/ b\") should contain fields {\n statements [\n {variable ['a', 'b']}\n ]\n }\n\n it 'when there are two'\n (statements \"a \/* comment *\/ b \/* another comment *\/ c\") should contain fields {\n statements [\n {variable ['a', 'b', 'c']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/* comment *\/\\nb\\n\/* another comment *\/\\nc\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n {variable ['c']}\n ]\n }\n\n it 'when it contains a * character'\n (statements \"a \/* sh*t *\/ b\") should contain fields {\n statements [\n {variable ['a', 'b']}\n ]\n }\n\n it 'when it covers two lines'\n (statements \"a \/* line one\\nline two *\/ b\") should contain fields {\n statements [{\n is variable\n variable ['a', 'b']\n }]\n }\n\n it 'when it is terminated by the end of file'\n (statements \"a \/* comment to eof\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when it extends to the end of the file'\n (statements \"a \/* comment to end *\/\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when it extends to the end of the file followed by newline'\n (statements \"a \/* comment to end *\/\\n\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'lexer'\n tokens = parser.lex 'a (b)'\n (tokens) should contain fields [\n ['identifier', 'a']\n ['(']\n ['identifier', 'b']\n [')']\n ['eof']\n ]\n\n it 'ignores hash bang #!, at the beginning of the file'\n (statements '#! \/usr\/bin\/env pogo\n a\n b') should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n","old_contents":"require '.\/assertions'\n\nparser = require '..\/src\/bootstrap\/parser'\nrequire '.\/parserAssertions'\n\ndescribe 'parser'\n describe 'terminals'\n it 'integer'\n (expression '5') should contain fields {\n integer 5\n }\n\n it 'float'\n (expression '5.6') should contain fields {\n float 5.6\n }\n\n describe 'variables'\n it 'simple'\n (expression 'total weight') should contain fields {\n variable ['total', 'weight']\n }\n\n it 'can use $ as a variable'\n (expression '$') should contain fields {\n variable ['$']\n }\n \n describe 'strings'\n it 'simple string'\n (expression '''a string''') should contain fields {\n is string\n string 'a string'\n }\n \n it 'string with single quotes'\n (expression '''''''alright!'''' he said''') should contain fields {\n is string\n string '''alright!'' he said'\n }\n \n it 'string with backslash'\n (expression \"'one \\\\ two'\") should contain fields {\n is string\n string \"one \\\\ two\"\n }\n \n it 'multiline string'\n (expression \" 'one\\n two'\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'multiline double-quote string'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'two multiline string in function'\n (expression \"x 'one\\n two' y \\\"three\\n four\\\"\") should contain fields {\n is function call\n function {variable ['x', 'y']}\n function arguments [\n {string \"one\\ntwo\"}\n {string \"three\\nfour\"}\n ]\n }\n\n describe 'interpolated strings'\n it 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n it 'empty'\n (expression '\"\"') should contain fields {\n is string\n string ''\n }\n\n it 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with newline escape and indentation should not remove indentation'\n (expression ' \"one\\n two\"') should contain fields {\n string \"one\\n two\"\n }\n\n it 'with indentation'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with single variable expression'\n (expression '\"a boat #(boat length) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['boat', 'length']}\n {string ' meters in length'}\n ]\n }\n\n it 'with hash # character at end'\n (expression '\"this is a hash: #\"') should contain fields {\n is string\n string 'this is a hash: #'\n }\n\n it 'with hash # character in middle'\n (expression '\"this is a hash: #, ok?\"') should contain fields {\n is string\n string 'this is a hash: #, ok?'\n }\n\n it 'with escaped #'\n (expression '\"a boat \\#(boat length) meters in length\"') should contain fields {\n is string\n string 'a boat #(boat length) meters in length'\n }\n\n it 'with complex expression'\n (expression '\"a boat #(lookup boat length from (boat database)) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n function {variable ['lookup', 'boat', 'length', 'from']}\n function arguments [{variable ['boat', 'database']}]\n }\n {string ' meters in length'}\n ]\n }\n \n it 'in block'\n (expression \"abc =\\n \\\"\\#(stuff)\\\"\") should contain fields {\n is definition\n target {\n is variable\n variable ['abc']\n }\n source {\n is scope\n statements [{\n is variable\n variable ['stuff']\n }]\n }\n }\n\n it 'with inner interpolation'\n (expression '\"a boat #(\"#(boat length) meters\") in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n is interpolated string\n components [\n {variable ['boat', 'length']}\n {string ' meters'}\n ]\n }\n {string ' in length'}\n ]\n }\n\n describe 'sub expressions'\n it 'single expression'\n (expression '(x)') should contain fields {variable ['x']}\n \n describe 'lists'\n it 'empty'\n (expression '[]') should contain fields {\n is list\n items []\n }\n \n it 'one item'\n (expression '[1]') should contain fields {\n is list\n items [{integer 1}]\n }\n \n it 'two items'\n (expression '[1, 2]') should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n it 'two items separated by newlines'\n (expression \"[\\n 1\\n 2\\n]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n describe 'hashes'\n it 'empty hash'\n (expression '{}') should contain fields {\n is hash\n entries []\n }\n \n it 'hash with one entry'\n (expression '{port 1234}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n it 'hash with two entries'\n (expression '{port 1234, ip address ''1.1.1.1''}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n {\n field ['ip', 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with two entries on different lines'\n (expression \"{port = 1234\\nip address = '1.1.1.1'}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['ip', 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with string with assignment'\n (expression \"{'port' = 1234}\") should contain fields {\n is hash\n entries [\n {\n field {string 'port'}\n value {integer 1234}\n }\n ]\n }\n \n it 'values can be specified on a new line'\n (expression \"{\n height =\n 80\n }\") should contain fields {\n is hash\n entries [\n {\n field ['height']\n value {\n is scope\n statements [{integer 80}]\n }\n }\n ]\n }\n \n it 'should allow methods to be defined, redefining self'\n (expression '{say hi to (name, greeting: nil) = print (name)}') should contain fields {\n is hash\n entries [\n {\n field ['say', 'hi', 'to']\n value {\n is block\n redefines self\n\n body {\n statements [{\n is function call\n\n function {variable ['print']}\n }]\n }\n\n parameters [{variable ['name']}]\n\n optional parameters [{\n is hash entry\n field ['greeting']\n }]\n }\n }\n ]\n }\n \n it 'hash with true entry'\n (expression '{port 1234, readonly}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['readonly']\n value (undefined)\n }\n ]\n }\n\n describe 'function calls'\n it 'function call'\n (expression 'touch (file)') should contain fields {\n function {variable ['touch']}\n function arguments [{variable ['file']}]\n }\n\n it 'function call with two arguments in parens'\n (expression 'f (a, b)') should contain fields {\n function {variable ['f']}\n function arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'two expressions'\n (expression '(x, y)') should contain fields {\n is function call\n function {variable ['x']}\n function arguments [\n {variable ['y']}\n ]\n }\n\n it 'function call with splat argument'\n (expression 'touch (files) ...') should contain fields {\n function {variable ['touch']}\n function arguments [\n {variable ['files']}\n {is splat}\n ]\n }\n\n it 'function call with no argument'\n (expression 'delete everything!') should contain fields {\n function {variable ['delete', 'everything']}\n function arguments []\n }\n\n it 'function call with no argument using empty parens'\n (expression 'delete everything ()') should contain fields {\n function {variable ['delete', 'everything']}\n function arguments []\n }\n\n it 'function call with block with parameters'\n (expression \"with file (file) @(stream)\\n stream\") should contain fields {\n function {variable ['with', 'file']}\n function arguments [\n {variable ['file']}\n {\n body {statements [{variable ['stream']}]}\n parameters [{variable ['stream']}]\n }\n ]\n }\n\n it 'function call with block with long parameters'\n (expression \"open database @(database connection)\\n database connection\") should contain fields {\n function {variable ['open', 'database']}\n function arguments [\n {\n parameters [\n {variable ['database', 'connection']}\n ]\n body {statements [{variable ['database', 'connection']}]}\n }\n ]\n }\n\n it 'function call with two blocks with parameters'\n (expression 'name @(x) @{x} @ (y) @ {y}') should contain fields {\n function {variable ['name']}\n function arguments [\n {\n body {statements [{variable ['x']}]}\n parameters [{variable ['x']}]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{variable ['y']}]\n }\n ]\n }\n\n it 'function call with two optional arguments'\n (expression 'name (a, port: 34, server: s)') should contain fields {\n function {variable ['name']}\n function arguments [\n {variable ['a']}\n ]\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n {\n field ['server']\n value {variable ['s']}\n }\n ]\n }\n \n describe 'object operations'\n it 'method call'\n (expression 'object.method (argument)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments [{variable ['argument']}]\n }\n \n it 'method call with optional arguments'\n (expression 'object.method (argument, view: view)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments [{variable ['argument']}]\n optional arguments [\n {field ['view'], value {variable ['view']}}\n ]\n }\n \n it 'field reference'\n (expression 'object.field') should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'field reference with newline'\n (expression \"object.\\nfield\") should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'indexer'\n (expression 'object.(x)') should contain fields {\n is indexer\n object {variable ['object']}\n indexer {variable ['x']}\n }\n \n it 'parses no argument method with ()'\n (expression 'object.method()') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n \n it 'parses no argument method with () and field'\n (expression 'object.method().field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n \n it 'parses no argument method with ! and field'\n (expression 'object.method! . field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n \n it 'parses no argument method with ! and field'\n (expression 'object.method!.field') should contain fields {\n is field reference\n object {\n is method call\n object {variable ['object']}\n name ['method']\n method arguments []\n }\n name ['field']\n }\n\n describe 'blocks'\n it 'empty block'\n (expression '@{}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements []}\n }\n \n it 'block'\n (expression '@{x, y}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements [\n {variable ['x']}\n {variable ['y']}\n ]}\n }\n\n it 'block with parameter'\n (expression \"@(x)\\n x, y\") should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (false)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n it 'block in parens'\n (expression \"(one\\n two\\n)\") should contain fields {\n is function call\n function {variable ['one']}\n function arguments [\n {\n is block\n body {\n statements [\n {variable ['two']}\n ]\n }\n }\n ]\n }\n\n it 'block with parameter, redefining self'\n (expression '@(x) => @{x, y}') should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (true)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n describe 'statements'\n it 'can be separated by commas (,)'\n (statements 'a, b') should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'can be separated by unix new lines'\n (statements \"a\\nb\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'can be separated by windows new lines'\n (statements \"a\\r\\nb\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n it 'windows indentation'\n (statements \"app (stuff) =\\r\n ok\\r\n \\r\n url (path) =\\r\n ok\") should contain fields {\n statements [\n {is definition}\n {is definition}\n ]\n }\n\n describe 'operators'\n it 'should be lower precedence than object operation'\n (expression 'o.m 2 +- o.x') should contain fields {\n is method call\n object {\n is method call\n object {variable ['o']}\n name ['m']\n method arguments [{integer 2}]\n }\n \n name ['+-']\n method arguments [\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n ]\n }\n \n it 'parses backslash'\n (expression \"2 +\\\\+ 1\") should contain fields {\n is method call\n object {integer 2}\n \n name [\"+\\\\+\"]\n method arguments [\n {integer 1}\n ]\n }\n \n it 'unary operators should be higher precedence than binary operators'\n (expression 'a && ! b') should contain fields {\n is operator\n operator '&&'\n \n operator arguments [\n {variable ['a']}\n {\n is operator\n operator '!'\n operator arguments [{variable ['b']}]\n }\n ]\n }\n \n it 'can have newlines immediately after operator'\n (expression \"a &&\\nb\") should contain fields {\n is operator\n operator '&&'\n \n operator arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n describe 'assignment'\n it 'assignment'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n describe 'function definition'\n it 'function with one parameter'\n (expression 'func (x) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'function with one parameter, and one optional parameter'\n (expression 'func (x, port: 80) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n optional parameters [{field ['port'], value {integer 80}}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'field assignment'\n (expression 'o.x = y') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n\n source {variable ['y']}\n }\n\n it 'index assignment'\n (expression 'o.(x) = y') should contain fields {\n is definition\n target {\n is indexer\n object {variable ['o']}\n indexer {variable ['x']}\n }\n\n source {variable ['y']}\n }\n\n it 'assignment from field'\n (expression 'x = y.z') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is field reference\n object {\n variable ['y']\n }\n\n name ['z']\n }\n }\n\n it 'assignment of command'\n (expression 'x! = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'definition of function with no arguments, using empty parens \"()\"'\n (expression 'x () = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'assignment from method call'\n (expression 'x = y.z (a)') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n method arguments [{variable ['a']}]\n }\n }\n\n it 'field assignment from method call'\n (expression 'i.x = y.z (a)') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['i']}\n name ['x']\n }\n\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n method arguments [{variable ['a']}]\n }\n }\n \n describe 'regexps'\n it 'simple'\n (expression 'r\/abc\/') should contain fields {\n is reg exp\n pattern 'abc'\n }\n\n it 'with options'\n (expression 'r\/abc\/img') should contain fields {\n is reg exp\n pattern 'abc'\n options 'img'\n }\n\n it 'with escaped back ticks'\n (expression 'r\/abc\\\/def\\\/ghi\/') should contain fields {\n is reg exp\n pattern 'abc\/def\/ghi'\n }\n\n it 'with various escapes'\n (expression 'r\/abc\\\/def\\nghi\\\/jkl\/') should contain fields {\n is reg exp\n pattern 'abc\/def\\nghi\/jkl'\n }\n\n it 'with newline'\n (expression \"a = r\/abc\\n def\/\") should contain fields {\n is definition\n target {\n is variable\n variable ['a']\n }\n source {\n is reg exp\n pattern \"abc\\\\ndef\"\n }\n }\n \n describe 'comments'\n it 'should not treat comment-like syntax as comments in strings'\n (statements \"get 'http:\/\/pogoscript.org\/'\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['get']}\n function arguments [\n {string 'http:\/\/pogoscript.org\/'}\n ]\n }]\n }\n \n describe 'should allow one-line C++ style comments, as in: \/\/ this is a comment'\n it 'when at the end of a line'\n (statements \"a \/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n it 'when before an indented block'\n (statements \"a \/\/ this is a comment\\n b\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['a']}\n function arguments [{\n is block\n body {\n statements [\n {variable ['b']}\n ]\n }\n }]\n }]\n }\n\n it 'when at end of file'\n (statements \"a \/\/ this is a comment\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n describe 'should allow multi-line C style comments, as in: \/* this is a comment *\/'\n it 'when on one line'\n (statements \"a \/* comment *\/ b\") should contain fields {\n statements [\n {variable ['a', 'b']}\n ]\n }\n\n it 'when there are two'\n (statements \"a \/* comment *\/ b \/* another comment *\/ c\") should contain fields {\n statements [\n {variable ['a', 'b', 'c']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/* comment *\/\\nb\\n\/* another comment *\/\\nc\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n {variable ['c']}\n ]\n }\n\n it 'when it contains a * character'\n (statements \"a \/* sh*t *\/ b\") should contain fields {\n statements [\n {variable ['a', 'b']}\n ]\n }\n\n it 'when it covers two lines'\n (statements \"a \/* line one\\nline two *\/ b\") should contain fields {\n statements [{\n is variable\n variable ['a', 'b']\n }]\n }\n\n it 'when it is terminated by the end of file'\n (statements \"a \/* comment to eof\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when it extends to the end of the file'\n (statements \"a \/* comment to end *\/\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when it extends to the end of the file followed by newline'\n (statements \"a \/* comment to end *\/\\n\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'lexer'\n tokens = parser.lex 'a (b)'\n (tokens) should contain fields [\n ['identifier', 'a']\n ['(']\n ['identifier', 'b']\n [')']\n ['eof']\n ]\n\n it 'ignores hash bang #!, at the beginning of the file'\n (statements '#! \/usr\/bin\/env pogo\n a\n b') should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"5cf01a92282e40610a543ab1776700428cddaa8d","subject":"better output for server.pogo","message":"better output for server.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/server.pogo","new_file":"src\/samples\/server.pogo","new_contents":"http = require 'http'\n\nafter @time @block =\n set timeout @block @time\n \n@n seconds =\n n * 1000\n\n@n minutes =\n (@n * 60) seconds\n\nserver = http : create server #req #res\n res : write \"stuff\\n\"\n \n after (0.05 minutes)\n res : write \"stuff after 0.05 minutes\\n\"\n\n after (0.5 seconds)\n res : end \"stuff after 0.5 seconds\\n\"\n\nport = 8000\nserver : listen @port\nconsole: log \"run > curl localhost:@port\"","old_contents":"http = require 'http'\n\nafter @time @block =\n set timeout @block @time\n \n@n seconds =\n n * 1000\n\n@n minutes =\n (@n * 60) seconds\n\nserver = http : create server #req #res\n res : write \"stuff\\n\"\n \n after (0.2 minutes)\n res : write \"stuff\\n\"\n\n after (0.5 seconds)\n res : end \"hello world\\n\"\n\nserver : listen 8000","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"d847b8bc5f98cdde22fc8fa463b3053a6abcf1ed","subject":"formatting","message":"formatting\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"lib\/forIn.pogo","new_file":"lib\/forIn.pogo","new_contents":"module.exports (terms) = terms.term {\n constructor (iterator, collection, stmts) =\n self.is for in = true\n self.iterator = iterator\n self.collection = collection\n self.statements = stmts\n \n generate java script (buffer, scope) =\n buffer.write ('for(var ')\n self.iterator.generate java script (buffer, scope)\n buffer.write (' in ')\n self.collection.generate java script (buffer, scope)\n buffer.write ('){')\n\n self.cg.sub expression (\n self.cg.function call (\n self.cg.block (\n [self.iterator]\n self.statements\n return last statement: false\n )\n [self.iterator]\n )\n ).generate java script statement (buffer, scope)\n\n buffer.write ('}')\n\n generate java script statement (args, ...) = self.generate java script (args, ...)\n generate java script return (args, ...) = self.generate java script (args, ...)\n \n definitions (scope) =\n defs = []\n index name = self.iterator.definition name (scope)\n if (indexName)\n defs.push (indexName)\n\n defs.concat (self.statements.definitions (scope))\n}\n","old_contents":"module.exports (terms) = terms.term {\n constructor (iterator, collection, stmts) =\n self.is for in = true\n self.iterator = iterator\n self.collection = collection\n self.statements = stmts\n \n generate java script (buffer, scope) =\n buffer.write('for(var ')\n self.iterator.generate java script(buffer, scope)\n buffer.write(' in ')\n self.collection.generate java script(buffer, scope)\n buffer.write('){')\n\n self.cg.sub expression(\n self.cg.function call(\n self.cg.block(\n [self.iterator]\n self.statements\n return last statement: false\n )\n [self.iterator]\n )\n ).generate java script statement(buffer, scope)\n\n buffer.write('}')\n\n generate java script statement (args, ...) = self.generate java script (args, ...)\n generate java script return (args, ...) = self.generate java script (args, ...)\n \n definitions (scope) =\n defs = []\n index name = self.iterator.definition name(scope)\n if (indexName)\n defs.push(indexName)\n\n defs.concat(self.statements.definitions(scope))\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"0a5c547a6ada40fe4899fe7f4fbb2b42431d52ab","subject":"new regexp syntax for commandLine.pogo","message":"new regexp syntax for commandLine.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/commandLine.pogo","new_file":"src\/bootstrap\/commandLine.pogo","new_contents":"fs = require 'fs'\nms = require '..\/lib\/memorystream'\nparser = require '.\/parser'\nparse = parser.parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\n_ = require 'underscore'\nreadline = require 'readline'\nutil = require 'util'\nModule = require 'module'\npath = require 'path'\n\ngenerate code (term) =\n memory stream = new (ms.MemoryStream)\n term.generate java script (memory stream)\n memory stream.to string ()\n\nbeautify (code) =\n ast = uglify.parser.parse (code)\n uglify.uglify.gen_code (ast, beautify: true)\n\nexports.compile file = compile file (filename, ugly: false) =\n js = compile from file (filename, ugly: ugly)\n\n js filename = js filename from pogo filename (filename)\n fs.write file sync (js filename, js)\n\nwhen (filename) changes (act) =\n fs.watch file (filename) {persistent, interval 500} @(prev, curr)\n if ((curr.size == prev.size) && (curr.mtime.get time () == prev.mtime.get time ()))\n return\n \n act ()\n\nexports.watch file (filename, options) =\n compile () =\n console.log \"compiling #(filename) => #(js filename from pogo filename (filename))\"\n compile file (filename, options)\n\n compile ()\n\n when (filename) changes\n compile ()\n\nexports.lex file (filename) =\n source = fs.read file sync (filename) 'utf-8'\n tokens = parser.lex (source)\n\n for each @(token) in (tokens)\n text = (token.1 && \"'#(token.1)'\") || ''\n console.log \"<#(token.0)> #(text)\"\n\njs filename from pogo filename (pogo) =\n pogo.replace r\/\\.pogo$\/ '' + '.js'\n\nexports.run file (filename) in module (module) =\n js = compile from file (filename)\n module._compile (js, filename)\n\nexports.run main (filename) =\n full filename = fs.realpath sync (filename)\n \n process.argv.shift ()\n process.argv.0 = 'pogo'\n process.argv.1 = full filename\n \n module = new (Module (full filename, null))\n process.main module = module\n module.id = '.'\n module.filename = full filename\n module.paths = Module._node module paths (path.dirname (full filename))\n exports.run file (full filename) in module (module)\n module.loaded = true\n\nexports.compile (pogo, filename: nil, in scope: true, ugly: false, global: false, return result: false) =\n module term = parse (pogo)\n module term.in scope = in scope\n module term.global = global\n module term.return result = return result\n\n code = generate code (module term)\n\n if (!ugly)\n code = beautify (code)\n\n if (errors.has errors ())\n errors.print errors (source location printer (filename: filename, source: pogo))\n process.exit 1\n else\n code\n\nexports.evaluate (pogo, definitions: {}, global: false) =\n js = exports.compile (pogo, ugly: true, in scope: !global, global: global, return result: global)\n definition names = _.keys (definitions)\n \n parameters = definition names.join ','\n \n run script = new (Function (parameters, js))\n \n definition values = _.map (definition names) @(name)\n definitions.(name)\n \n run script.apply (undefined) (definition values)\n\nexports.repl () =\n interface = readline.create interface (process.stdin, process.stdout)\n prompt = '\u03bb '\n\n interface.set prompt (prompt, prompt.length)\n interface.prompt ()\n\n interface.on 'line' @(line)\n evalute repl line (line)\n interface.prompt ()\n\n interface.on 'close'\n process.stdout.write \"\\n\"\n process.exit 0\n\nevalute repl line (line) =\n try\n result = exports.evaluate (line, global: true)\n console.log ' =>' (util.inspect (result, undefined, undefined, true))\n catch @(ex)\n console.log (ex.message)\n\ncompile from file (filename, ugly: false) =\n contents = fs.read file sync (filename) 'utf-8'\n exports.compile (contents, filename: filename, ugly: ugly)\n \nsource location printer (filename: nil, source: nil) =\n object =>\n self.lines in range (range) =\n lines = source.split r\/\\n\/\n lines.slice (range.from - 1) (range.to)\n\n self.print lines in range (prefix: '', from: nil, to: nil) =\n for each @(line) in (self.lines in range (from: from, to: to))\n process.stderr.write (prefix + line + \"\\n\")\n\n self.print location (location) =\n process.stderr.write (filename + ':' + location.first line + \"\\n\")\n\n if (location.first line == location.last line)\n self.print lines in range (from: location.first line, to: location.last line)\n spaces = self.' ' times (location.first column)\n markers = self.'^' times (location.last column - location.first column)\n process.stderr.write (spaces + markers + \"\\n\")\n else\n self.print lines in range (prefix: '> ', from: location.first line, to: location.last line)\n\n self.(s) times (n) =\n strings = []\n for (i = 0, i < n, i = i + 1)\n strings.push (s)\n\n strings.join ''\n\nrequire.extensions.'.pogo' (module, filename) =\n exports.run file (filename) in module (module)\n","old_contents":"fs = require 'fs'\nms = require '..\/lib\/memorystream'\nparser = require '.\/parser'\nparse = parser.parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\n_ = require 'underscore'\nreadline = require 'readline'\nutil = require 'util'\nModule = require 'module'\npath = require 'path'\n\ngenerate code (term) =\n memory stream = new (ms.MemoryStream)\n term.generate java script (memory stream)\n memory stream.to string ()\n\nbeautify (code) =\n ast = uglify.parser.parse (code)\n uglify.uglify.gen_code (ast, beautify: true)\n\nexports.compile file = compile file (filename, ugly: false) =\n js = compile from file (filename, ugly: ugly)\n\n js filename = js filename from pogo filename (filename)\n fs.write file sync (js filename, js)\n\nwhen (filename) changes (act) =\n fs.watch file (filename) {persistent, interval 500} @(prev, curr)\n if ((curr.size == prev.size) && (curr.mtime.get time () == prev.mtime.get time ()))\n return\n \n act ()\n\nexports.watch file (filename, options) =\n compile () =\n console.log \"compiling #(filename) => #(js filename from pogo filename (filename))\"\n compile file (filename, options)\n\n compile ()\n\n when (filename) changes\n compile ()\n\nexports.lex file (filename) =\n source = fs.read file sync (filename) 'utf-8'\n tokens = parser.lex (source)\n\n for each @(token) in (tokens)\n text = (token.1 && \"'#(token.1)'\") || ''\n console.log \"<#(token.0)> #(text)\"\n\njs filename from pogo filename (pogo) =\n pogo.replace `\\.pogo$` '' + '.js'\n\nexports.run file (filename) in module (module) =\n js = compile from file (filename)\n module._compile (js, filename)\n\nexports.run main (filename) =\n full filename = fs.realpath sync (filename)\n \n process.argv.shift ()\n process.argv.0 = 'pogo'\n process.argv.1 = full filename\n \n module = new (Module (full filename, null))\n process.main module = module\n module.id = '.'\n module.filename = full filename\n module.paths = Module._node module paths (path.dirname (full filename))\n exports.run file (full filename) in module (module)\n module.loaded = true\n\nexports.compile (pogo, filename: nil, in scope: true, ugly: false, global: false, return result: false) =\n module term = parse (pogo)\n module term.in scope = in scope\n module term.global = global\n module term.return result = return result\n\n code = generate code (module term)\n\n if (!ugly)\n code = beautify (code)\n\n if (errors.has errors ())\n errors.print errors (source location printer (filename: filename, source: pogo))\n process.exit 1\n else\n code\n\nexports.evaluate (pogo, definitions: {}, global: false) =\n js = exports.compile (pogo, ugly: true, in scope: !global, global: global, return result: global)\n definition names = _.keys (definitions)\n \n parameters = definition names.join ','\n \n run script = new (Function (parameters, js))\n \n definition values = _.map (definition names) @(name)\n definitions.(name)\n \n run script.apply (undefined) (definition values)\n\nexports.repl () =\n interface = readline.create interface (process.stdin, process.stdout)\n prompt = '\u03bb '\n\n interface.set prompt (prompt, prompt.length)\n interface.prompt ()\n\n interface.on 'line' @(line)\n evalute repl line (line)\n interface.prompt ()\n\n interface.on 'close'\n process.stdout.write \"\\n\"\n process.exit 0\n\nevalute repl line (line) =\n try\n result = exports.evaluate (line, global: true)\n console.log ' =>' (util.inspect (result, undefined, undefined, true))\n catch @(ex)\n console.log (ex.message)\n\ncompile from file (filename, ugly: false) =\n contents = fs.read file sync (filename) 'utf-8'\n exports.compile (contents, filename: filename, ugly: ugly)\n \nsource location printer (filename: nil, source: nil) =\n object =>\n self.lines in range (range) =\n lines = source.split `\\n`\n lines.slice (range.from - 1) (range.to)\n\n self.print lines in range (prefix: '', from: nil, to: nil) =\n for each @(line) in (self.lines in range (from: from, to: to))\n process.stderr.write (prefix + line + \"\\n\")\n\n self.print location (location) =\n process.stderr.write (filename + ':' + location.first line + \"\\n\")\n\n if (location.first line == location.last line)\n self.print lines in range; from (location.first line); to (location.last line)\n spaces = self.' ' times (location.first column)\n markers = self.'^' times (location.last column - location.first column)\n process.stderr.write (spaces + markers + \"\\n\")\n else\n self.print lines in range; prefix '> '; from (location.first line); to (location.last line)\n\n self.(s) times (n) =\n strings = []\n for (i = 0, i < n, i = i + 1)\n strings.push (s)\n\n strings.join ''\n\nrequire.extensions.'.pogo' (module, filename) =\n exports.run file (filename) in module (module)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"bc280f1406a510daeb7e000115ea32aed00831f6","subject":"fixed typo","message":"fixed typo\n","repos":"featurist\/pogo-examples","old_file":"examples\/options.pogo","new_file":"examples\/options.pogo","new_contents":"connect to (port: 3306, host: \"127.0.0.1\") =\n console.log \"connecting to #(host):#(port)\"\n","old_contents":"connect to (port: 3306, host: \"127.0.0.1\") =\n console.log \"connecting to #(host):#(part)\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6d0c2664ca3ae45e130a619abc49102c9121f688","subject":"fix cli args bug","message":"fix cli args bug\n","repos":"featurist\/ringleader","old_file":"src\/cli\/cli.pogo","new_file":"src\/cli\/cli.pogo","new_contents":"default port = 1337\n\n(arg) as port =\n parse int(arg) || default port\n\n(arg) as host =\n if ((arg) is a url) @{ arg } else @{ \"http:\/\/127.0.0.1:#(arg)\" }\n\n(arg) is a url =\n arg.to string().index of (\"http\") == 0\n\ncli = {\n \n server (args) =\n port = (args.shift()) as port\n require '.\/cli_server'.run server(port)\n \n agent (args) =\n host = (args.shift()) as host\n require '.\/cli_agent'.run agent(host)\n \n enqueue (args) =\n host = (args.shift()) as host\n require '.\/cli_enqueue'.enqueue(host, args)\n}\n\nexports.run (args) =\n service = args.shift()\n cli.(service).call(self, args)\n","old_contents":"default port = 1337\n\nexports.run (args) =\n service = args.shift()\n port = parse int(args.shift()) || default port\n host = if (port.to string().index of \"http\" != 0) @{ \"http:\/\/127.0.0.1:#(port)\" } else @{ port }\n\n if (service == 'server')\n require '.\/cli_server'.run server(port)\n\n if (service == 'agent')\n require '.\/cli_agent'.run agent(host)\n\n if (service == 'enqueue')\n require '.\/cli_enqueue'.enqueue(host, args)","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6550d84dae748dad69beb286dd16a4a79c99ce91","subject":"beer bottles submission, prints proper lyrics","message":"beer bottles submission, prints proper lyrics\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/beers.pogo","new_file":"src\/samples\/beers.pogo","new_contents":"sing (n) bottles of beer on the wall =\n if (n > 0)\n console.log \"#((n) bottles) of beer on the wall, #((n) bottles) of beer.\n Take one down and pass it around, #((n - 1) bottles) of beer on the wall.\"\n sing (n - 1) bottles of beer on the wall\n else if (n == 0)\n console.log \"No more bottles of beer on the wall, no more bottles of beer.\n Go to the store and buy some more, 99 bottles of beer on the wall.\"\n\n(n) bottles =\n if (n == 0)\n \"no more bottles\"\n else if (n == 1)\n \"1 bottle\"\n else\n \"#(n) bottles\"\n\nsing 99 bottles of beer on the wall\n","old_contents":"sing (n) bottles of beer on the wall =\n if (n > 0)\n console.log ((n) bottles of beer on the wall)\n sing (n - 1) bottles of beer on the wall\n\n(n) bottles of beer on the wall =\n \"#((n) bottles) of beer on the wall, #((n) bottles) of beer on the wall\n take one down, pass it around, #((n - 1) bottles) of beer on the wall.\"\n\n(n) bottles =\n if (n == 0)\n \"no bottles\"\n else if (n == 1)\n \"1 bottle\"\n else\n \"#(n) bottles\"\n\nsing 99 bottles of beer on the wall\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"de55e5559826f6e8a5fc015ecb99d296f6c509b7","subject":"improved sample for with expression","message":"improved sample for with expression\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/with.pogo","new_file":"src\/samples\/with.pogo","new_contents":"things = {}\n\nmerge (traits) into (thing) =\n for each @(trait) in (traits)\n for @(attr) in (trait) @ { thing.(attr) = trait.(attr) }\n\nspec = {\n\n describe (thing) as (traits) = merge (traits) into (things.(thing) = {})\n\n made of (stuff) = { material = stuff }\n \n solid material = { breakable = false }\n \n (direction) orientation = { orientation = direction }\n \n}\n\n\nwith (spec)\n \n describe 'wall' as [\n \n made of (solid material)\n \n 'vertical' orientation\n \n ]\n \n\nconsole.log (things)\n\n\/\/ { wall: { material: { breakable: false }, orientation: 'vertical' } }","old_contents":"things = []\n\nspecification = {\n\n describe (thing) as (attributes) = things.push [thing, attributes]\n\n made of (stuff) = { material = stuff }\n \n solid material = { breakable = false }\n \n (name) orientation = { orientation = name }\n \n}\n\n\nwith (specification)\n \n describe 'wall' as [\n \n made of (solid material)\n \n 'vertical' orientation\n \n ]\n ","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"3e11af1a7123821c3aea825d0b8ee41ade717d26","subject":"extending prototype test","message":"extending prototype test\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/prototypeSpec.pogo","new_file":"test\/prototypeSpec.pogo","new_contents":"require 'chai'.should()\n\ndescribe 'prototypes'\n it 'can create a prototype'\n a = {\n base = 'base'\n overridden = 'a'\n }\n\n p = prototype (a)\n\n b = p {\n overridden = 'b'\n derived = 'derived'\n }\n\n b.base.should.equal 'base'\n b.overridden.should.equal 'b'\n b.derived.should.equal 'derived'\n Object.getPrototypeOf(b).should.equal(a)\n\n it 'properties are shared between derived objects'\n array = [1, 2, 3]\n\n a = prototype {\n array = array\n }\n\n b = a()\n c = a()\n\n b.array.should.equal (array)\n c.array.should.equal (array)\n b.should.not.equal (c)\n\n it 'prototype can extend another prototype'\n array = [1, 2, 3]\n\n a = prototype {\n a = true\n name = 'a'\n }\n\n b = prototypeExtending (a) {\n b = true\n name = 'b'\n }\n\n objectA = a()\n objectB = b()\n\n objectA.a.should.equal (true)\n objectA.name.should.equal 'a'\n (objectA :: a).should.equal(true)\n\n objectB.a.should.equal (true)\n objectB.b.should.equal (true)\n objectB.name.should.equal 'b'\n (objectB :: a).should.equal(true)\n (objectB :: b).should.equal(true)\n\n it 'a prototype can be extended after creation'\n a = prototype {\n a = 'a'\n }\n\n a.prototype.b = 'b'\n\n c = a {\n c = 'c'\n }\n\n c.a.should.equal 'a'\n c.b.should.equal 'b'\n c.c.should.equal 'c'\n\n it 'prototype is a function'\n (prototype :: Function).should.equal (true)\n\n it 'prototypeExtending is a function'\n (prototypeExtending :: Function).should.equal (true)\n","old_contents":"require 'chai'.should()\n\ndescribe 'prototypes'\n it 'can create a prototype'\n a = {\n base = 'base'\n overridden = 'a'\n }\n\n p = prototype (a)\n\n b = p {\n overridden = 'b'\n derived = 'derived'\n }\n\n b.base.should.equal 'base'\n b.overridden.should.equal 'b'\n b.derived.should.equal 'derived'\n Object.getPrototypeOf(b).should.equal(a)\n\n it 'properties are shared between derived objects'\n array = [1, 2, 3]\n\n a = prototype {\n array = array\n }\n\n b = a()\n c = a()\n\n b.array.should.equal (array)\n c.array.should.equal (array)\n b.should.not.equal (c)\n\n it 'prototype can extend another prototype'\n array = [1, 2, 3]\n\n a = prototype {\n a = true\n name = 'a'\n }\n\n b = prototypeExtending (a) {\n b = true\n name = 'b'\n }\n\n objectA = a()\n objectB = b()\n\n objectA.a.should.equal (true)\n objectA.name.should.equal 'a'\n (objectA :: a).should.equal(true)\n\n objectB.a.should.equal (true)\n objectB.b.should.equal (true)\n objectB.name.should.equal 'b'\n (objectB :: a).should.equal(true)\n (objectB :: b).should.equal(true)\n\n it 'prototype is a function'\n (prototype :: Function).should.equal (true)\n\n it 'prototypeExtending is a function'\n (prototypeExtending :: Function).should.equal (true)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"a9c5ecb60e20978498d1fc01a7d206a1c98ee619","subject":"better output for mongodb.pogo","message":"better output for mongodb.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/mongodb.pogo","new_file":"src\/samples\/mongodb.pogo","new_contents":"mongodb = require 'mongodb'\nassert = require 'assert'\n\nserver (address: '127.0.0.1', port: 27017) =\n new (mongodb.Server (address, port))\n\ndb (name: nil, svr: server()) =\n new (mongodb.Db (name, svr))\n\ntest db = db (name: 'test')\n\ntest (err, collection) =\n collection.remove\n console.log \"inserting\" {a 2}\n collection.insert {a 2} @(err, docs)\n collection.count @(err, count)\n console.log \"document count: #(count)\"\n\n console.log \"searching\"\n collection.find().to array @(err, results)\n console.log \"found #(results.length) documents\"\n console.log \"document:\" (results.0)\n\n test db.close()\n\ntest db.open\n test db.collection 'test_insert' (test)\n","old_contents":"mongodb = require 'mongodb'\nassert = require 'assert'\n\nserver (address: '127.0.0.1', port: 27017) =\n new (mongodb.Server (address, port))\n\ndb (name: nil, server: server()) =\n new (mongodb.Db (name, server))\n\ntest db = db (name: 'test')\n\ntest (err, collection) =\n collection.remove\n collection.insert {a 2} @(err, docs)\n collection.count @(err, count)\n console.log (count)\n\n collection.find().to array @(err, results)\n console.log (results.length)\n console.log (results.0.a)\n\n test db.close()\n\ntest db.open\n test db.collection 'test_insert' (test)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"4203abb4846515f117bf56cf376a63da55e1e88a","subject":"updated continuation example","message":"updated continuation example\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"examples\/continuations.pogo","new_file":"examples\/continuations.pogo","new_contents":"current continuation! () =\n cont () =\n continuation (nil, cont)\n\n continuation (nil, cont)\n\nn = 0\n\ncont = current continuation!\n\nconsole.log (n)\n++n\n\nif (n < 10)\n cont ()\n","old_contents":"current continuation (callback) =\n continuation () =\n callback (nil, continuation)\n\n callback (nil, continuation)\n\nn = 0\n\ncont = current continuation!\n\nconsole.log (n)\n++n\n\nif (n < 10)\n cont ()\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"93d3257ea403a8bc1ba533730f626f7b99ba25ad","subject":"formatting","message":"formatting\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/grammar.pogo","new_file":"src\/bootstrap\/grammar.pogo","new_contents":"identifier pattern = '[a-zA-Z_$][a-zA-Z_$0-9]*'\ncomment pattern = '(\/\\*([^*](\\*[^\/]|))*(\\*\/|$)|\/\/[^\\n]*)'\n\nexports: grammar = {\n lex {\n start conditions {interpolated_string, interpolated_string_terminal}\n\n rules [\n [' +', '\/* ignore whitespace *\/']\n ['\\s*$', 'return yy.eof();']\n ['\\s*((\/\\*([^*](\\*[^\/]|))*(\\*\/|$)|\/\/[^\\n]*)\\s*)+', 'var indentation = yy.indentation(yytext); if (indentation) { return indentation; }']\n ['\\(\\s*', 'yy.setIndentation(yytext); if (yy.terms.interpolation.interpolating()) {yy.terms.interpolation.openBracket()} return \"(\";']\n ['\\s*\\)', 'if (yy.terms.interpolation.interpolating()) {yy.terms.interpolation.closeBracket(); if (yy.terms.interpolation.finishedInterpolation()) {this.popState(); this.popState(); yy.terms.interpolation.stopInterpolation()}} return yy.unsetIndentation('')'');']\n ['{\\s*', 'yy.setIndentation(yytext); return ''{'';']\n ['\\s*}', 'return yy.unsetIndentation(''}'');']\n ['\\[\\s*', 'yy.setIndentation(yytext); return ''['';']\n ['\\s*\\]', 'return yy.unsetIndentation('']'')']\n ['(\\n *)*\\n *', 'return yy.indentation(yytext);']\n ['[0-9]+\\.[0-9]+', 'return ''float'';']\n ['[0-9]+', 'return ''integer'';']\n ['([:;=,?!.@~#%^&*+<>\/?\\\\|-])+', 'return yy.terms.lexOperator(yytext);']\n [identifier pattern, 'return ''identifier'';']\n ['$', 'return ''eof'';']\n ['''([^'']*'''')*[^'']*''', 'return ''string'';']\n ['`([^\\\\]*\\\\`)*[^`]*`(img|mgi|gim|igm|gmi|mig|im|ig|gm|mg|mi|gi|i|m|g|)', 'return ''reg_exp'';']\n ['\"', 'this.begin(''interpolated_string''); return ''start_interpolated_string'';']\n \n [['interpolated_string'], '\\\\@', 'return ''escaped_interpolated_string_terminal_start'';']\n [['interpolated_string'], '@', 'this.begin(''interpolated_string_terminal''); return ''interpolated_string_terminal_start'';']\n [['interpolated_string_terminal'], identifier pattern, 'this.popState(); return ''identifier'';']\n [['interpolated_string_terminal'], '\\(', 'yy.setIndentation(yytext); yy.terms.interpolation.startInterpolation(); this.begin(''INITIAL''); return ''('';']\n [['interpolated_string'], '\"', 'this.popState(); return ''end_interpolated_string'';']\n [['interpolated_string'], '\\\\.', 'return ''escape_sequence'';']\n [['interpolated_string'], '[^\"@\\\\]*', 'return ''interpolated_string_body'';']\n \n ['.', 'return ''non_token'';']\n ]\n }\n\n operators [\n ['right', '=']\n ['left', ':']\n ]\n\n start 'module'\n\n bnf {\n module [\n ['statements eof', 'return yy.terms.module($1);']\n ]\n statements [\n ['statements_list', '$$ = yy.terms.statements($1);']\n ]\n hash_entries [\n ['hash_entries comma_dot expression', '$1.push($3.hashEntry()); $$ = $1;']\n ['expression', '$$ = [$1.hashEntry()];']\n ['', '$$ = [];']\n ]\n comma_dot [\n ['.', '$$ = $1;']\n [',', '$$ = $1;']\n ]\n statements_list [\n ['statements_list comma_dot statement', '$1.push($3); $$ = $1;']\n ['statement', '$$ = [$1];']\n ['', '$$ = [];']\n ]\n arguments_list [\n ['arguments_list , expression_list', '$1.push($3); $$ = $1;']\n ['expression_list', '$$ = [$1];']\n ['', '$$ = [];']\n ]\n parameter_list [\n ['parameter_list , statement', '$1.push($3); $$ = $1;']\n ['statement', '$$ = [$1];']\n ]\n expression_list [\n ['expression_list . statement', '$1.push($3); $$ = $1;']\n ['statement', '$$ = [$1];']\n ]\n list_statements_list [\n ['list_statements_list comma_dot list_statement', '$1.push($3); $$ = $1;']\n ['list_statement', '$$ = [$1];']\n ['', '$$ = [];']\n ]\n statement [\n ['expression', '$$ = $1.expression();']\n ]\n list_statement [\n ['list_expression', '$$ = $1.expression();']\n ]\n expression [\n ['expression = expression', '$$ = $1.definition($3.expression());']\n ['operator_expression', '$$ = $1;']\n ]\n list_expression [\n ['list_expression = list_expression', '$$ = $1.definition($3.expression());']\n ['list_operator_expression', '$$ = $1;']\n ]\n operator_with_newline [\n ['operator .', '$$ = $1']\n ['operator', '$$ = $1']\n ]\n operator_expression [\n ['operator_expression operator_with_newline unary_operator_expression', '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['unary_operator_expression', '$$ = yy.terms.operatorExpression($1);']\n ]\n list_operator_expression [\n ['list_operator_expression operator_with_newline list_unary_operator_expression', '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['list_unary_operator_expression', '$$ = yy.terms.operatorExpression($1);']\n ]\n unary_operator_expression [\n ['object_operation', '$$ = $1;']\n ['unary_operator object_operation', '$$ = yy.terms.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n list_unary_operator_expression [\n ['list_object_operation', '$$ = $1;']\n ['unary_operator list_object_operation', '$$ = yy.terms.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n object_reference_with_newline [\n [': .', '$$ = $1']\n [':', '$$ = $1']\n ]\n object_operation [\n ['object_operation object_reference_with_newline complex_expression', '$$ = $3.objectOperation($1.expression());']\n [': complex_expression', '$$ = $2.objectOperation(yy.terms.selfExpression());']\n ['complex_expression', '$$ = $1;']\n ]\n list_object_operation [\n ['list_object_operation object_reference_with_newline list_complex_expression', '$$ = $3.objectOperation($1.expression());']\n [': list_complex_expression', '$$ = $2.objectOperation(yy.terms.selfExpression());']\n ['list_complex_expression', '$$ = $1;']\n ]\n complex_expression [\n ['basic_expression_list', '$$ = yy.terms.complexExpression($1);']\n ]\n list_complex_expression [\n ['list_basic_expression', '$$ = yy.terms.complexExpression($1);']\n ]\n basic_expression_list [\n ['basic_expression_list ; terminal_list', '$1.push($3); $$ = $1;']\n ['terminal_list_no_arg', '$$ = [$1];']\n ]\n list_basic_expression [\n ['terminal_list_no_arg', '$$ = [$1];']\n ]\n terminal_list_no_arg [\n ['terminal_list no_arg_punctuation', '$1.push($2); $$ = $1;']\n ['terminal_list', '$$ = $1;']\n ]\n basic_expression [\n ['terminal_list', '$$ = yy.terms.basicExpression($1);']\n ]\n no_arg_punctuation [\n ['no_arg', '$$ = yy.terms.loc(yy.terms.noArgSuffix(), @$);']\n ]\n no_arg [\n ['!', '$$ = $1;']\n ['?', '$$ = $1;']\n ]\n terminal_list [\n ['terminal_list terminal', '$1.push($2); $$ = $1;']\n ['terminal', '$$ = [$1];']\n ]\n terminal [\n ['( arguments_list )', '$$ = yy.terms.loc(yy.terms.argumentList(yy.terms.normaliseArguments($2)), @$);']\n ['@ ( parameter_list )', '$$ = yy.terms.loc(yy.terms.parameters($3), @$);']\n ['block_start statements }', '$$ = yy.terms.loc(yy.terms.block([], $2), @$);']\n ['=> block_start statements }', '$$ = yy.terms.loc(yy.terms.block([], $3, {redefinesSelf: true}), @$);']\n ['[ statements_list ]', '$$ = yy.terms.loc(yy.terms.list($2), @$);']\n ['{ hash_entries }', '$$ = yy.terms.loc(yy.terms.hash($2), @$);']\n ['float', '$$ = yy.terms.loc(yy.terms.float(parseFloat(yytext)), @$);']\n ['integer', '$$ = yy.terms.loc(yy.terms.integer(parseInt(yytext)), @$);']\n ['identifier', '$$ = yy.terms.loc(yy.terms.identifier(yytext), @$);']\n ['string', '$$ = yy.terms.loc(yy.terms.string(yy.terms.unindent(@$.first_column + 1, yy.terms.normaliseString(yytext))), @$);']\n ['reg_exp', '$$ = yy.terms.loc(yy.terms.regExp(yy.terms.parseRegExp(yy.terms.unindent(@$.first_column + 1, yytext))), @$);']\n ['interpolated_string', '$$ = yy.terms.loc($1, @$);']\n ['...', '$$ = yy.terms.loc(yy.terms.splat(), @$);']\n ]\n block_start [\n ['@ {', '$$ = ''@{''']\n ['@{', '$$ = ''@{''']\n ]\n unary_operator [\n ['operator', '$$ = $1;']\n ['!', '$$ = $1;']\n ]\n interpolated_terminal [\n ['( statement )', '$$ = $2;']\n ['identifier', '$$ = yy.terms.variable([$1]);']\n ]\n interpolated_string [\n ['start_interpolated_string interpolated_string_components end_interpolated_string', '$$ = yy.terms.interpolatedString($2, @$.first_column);']\n ['start_interpolated_string end_interpolated_string', '$$ = yy.terms.interpolatedString([], @$.first_column);']\n ]\n interpolated_string_components [\n ['interpolated_string_components interpolated_string_component', '$1.push($2); $$ = $1;']\n ['interpolated_string_component', '$$ = [$1];']\n ]\n interpolated_string_component [\n ['interpolated_string_terminal_start interpolated_terminal', '$$ = $2;']\n ['interpolated_string_body', '$$ = yy.terms.string($1);']\n ['escaped_interpolated_string_terminal_start', '$$ = yy.terms.string(\"@\");']\n ['escape_sequence', '$$ = yy.terms.string(yy.terms.normaliseInterpolatedString($1));']\n ]\n }\n}\n","old_contents":"identifier pattern = '[a-zA-Z_$][a-zA-Z_$0-9]*'\ncomment pattern = '(\/\\*([^*](\\*[^\/]|))*(\\*\/|$)|\/\/[^\\n]*)'\n\nexports: grammar = {\n lex {\n start conditions {interpolated_string, interpolated_string_terminal}\n\n rules [\n [' +'. '\/* ignore whitespace *\/']\n ['\\s*$'. 'return yy.eof();']\n ['\\s*((\/\\*([^*](\\*[^\/]|))*(\\*\/|$)|\/\/[^\\n]*)\\s*)+'. 'var indentation = yy.indentation(yytext); if (indentation) { return indentation; }']\n ['\\(\\s*'. 'yy.setIndentation(yytext); if (yy.terms.interpolation.interpolating()) {yy.terms.interpolation.openBracket()} return \"(\";']\n ['\\s*\\)'. 'if (yy.terms.interpolation.interpolating()) {yy.terms.interpolation.closeBracket(); if (yy.terms.interpolation.finishedInterpolation()) {this.popState(); this.popState(); yy.terms.interpolation.stopInterpolation()}} return yy.unsetIndentation('')'');']\n ['{\\s*'. 'yy.setIndentation(yytext); return ''{'';']\n ['\\s*}'. 'return yy.unsetIndentation(''}'');']\n ['\\[\\s*'. 'yy.setIndentation(yytext); return ''['';']\n ['\\s*\\]'. 'return yy.unsetIndentation('']'')']\n ['(\\n *)*\\n *'. 'return yy.indentation(yytext);']\n ['[0-9]+\\.[0-9]+'. 'return ''float'';']\n ['[0-9]+'. 'return ''integer'';']\n ['([:;=,?!.@~#%^&*+<>\/?\\\\|-])+'. 'return yy.terms.lexOperator(yytext);']\n [identifier pattern. 'return ''identifier'';']\n ['$'. 'return ''eof'';']\n ['''([^'']*'''')*[^'']*'''. 'return ''string'';']\n ['`([^\\\\]*\\\\`)*[^`]*`(img|mgi|gim|igm|gmi|mig|im|ig|gm|mg|mi|gi|i|m|g|)'. 'return ''reg_exp'';']\n ['\"'. 'this.begin(''interpolated_string''); return ''start_interpolated_string'';']\n \n [['interpolated_string']. '\\\\@'. 'return ''escaped_interpolated_string_terminal_start'';']\n [['interpolated_string']. '@'. 'this.begin(''interpolated_string_terminal''); return ''interpolated_string_terminal_start'';']\n [['interpolated_string_terminal']. identifier pattern. 'this.popState(); return ''identifier'';']\n [['interpolated_string_terminal']. '\\('. 'yy.setIndentation(yytext); yy.terms.interpolation.startInterpolation(); this.begin(''INITIAL''); return ''('';']\n [['interpolated_string']. '\"'. 'this.popState(); return ''end_interpolated_string'';']\n [['interpolated_string']. '\\\\.'. 'return ''escape_sequence'';']\n [['interpolated_string']. '[^\"@\\\\]*'. 'return ''interpolated_string_body'';']\n \n ['.'. 'return ''non_token'';']\n ]\n }\n\n operators [\n ['right'. '=']\n ['left'. ':']\n ]\n\n start 'module'\n\n bnf {\n module [\n ['statements eof'. 'return yy.terms.module($1);']\n ]\n statements [\n ['statements_list'. '$$ = yy.terms.statements($1);']\n ]\n hash_entries [\n ['hash_entries comma_dot expression'. '$1.push($3.hashEntry()); $$ = $1;']\n ['expression'. '$$ = [$1.hashEntry()];']\n [''. '$$ = [];']\n ]\n comma_dot [\n ['.'. '$$ = $1;']\n [','. '$$ = $1;']\n ]\n statements_list [\n ['statements_list comma_dot statement'. '$1.push($3); $$ = $1;']\n ['statement'. '$$ = [$1];']\n [''. '$$ = [];']\n ]\n arguments_list [\n ['arguments_list , expression_list'. '$1.push($3); $$ = $1;']\n ['expression_list'. '$$ = [$1];']\n [''. '$$ = [];']\n ]\n parameter_list [\n ['parameter_list , statement'. '$1.push($3); $$ = $1;']\n ['statement'. '$$ = [$1];']\n ]\n expression_list [\n ['expression_list . statement'. '$1.push($3); $$ = $1;']\n ['statement'. '$$ = [$1];']\n ]\n list_statements_list [\n ['list_statements_list comma_dot list_statement'. '$1.push($3); $$ = $1;']\n ['list_statement'. '$$ = [$1];']\n [''. '$$ = [];']\n ]\n statement [\n ['expression'. '$$ = $1.expression();']\n ]\n list_statement [\n ['list_expression'. '$$ = $1.expression();']\n ]\n expression [\n ['expression = expression'. '$$ = $1.definition($3.expression());']\n ['operator_expression'. '$$ = $1;']\n ]\n list_expression [\n ['list_expression = list_expression'. '$$ = $1.definition($3.expression());']\n ['list_operator_expression'. '$$ = $1;']\n ]\n operator_with_newline [\n ['operator .'. '$$ = $1']\n ['operator'. '$$ = $1']\n ]\n operator_expression [\n ['operator_expression operator_with_newline unary_operator_expression'. '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['unary_operator_expression'. '$$ = yy.terms.operatorExpression($1);']\n ]\n list_operator_expression [\n ['list_operator_expression operator_with_newline list_unary_operator_expression'. '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['list_unary_operator_expression'. '$$ = yy.terms.operatorExpression($1);']\n ]\n unary_operator_expression [\n ['object_operation'. '$$ = $1;']\n ['unary_operator object_operation'. '$$ = yy.terms.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n list_unary_operator_expression [\n ['list_object_operation'. '$$ = $1;']\n ['unary_operator list_object_operation'. '$$ = yy.terms.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n object_reference_with_newline [\n [': .'. '$$ = $1']\n [':'. '$$ = $1']\n ]\n object_operation [\n ['object_operation object_reference_with_newline complex_expression'. '$$ = $3.objectOperation($1.expression());']\n [': complex_expression'. '$$ = $2.objectOperation(yy.terms.selfExpression());']\n ['complex_expression'. '$$ = $1;']\n ]\n list_object_operation [\n ['list_object_operation object_reference_with_newline list_complex_expression'. '$$ = $3.objectOperation($1.expression());']\n [': list_complex_expression'. '$$ = $2.objectOperation(yy.terms.selfExpression());']\n ['list_complex_expression'. '$$ = $1;']\n ]\n complex_expression [\n ['basic_expression_list'. '$$ = yy.terms.complexExpression($1);']\n ]\n list_complex_expression [\n ['list_basic_expression'. '$$ = yy.terms.complexExpression($1);']\n ]\n basic_expression_list [\n ['basic_expression_list ; terminal_list'. '$1.push($3); $$ = $1;']\n ['terminal_list_no_arg'. '$$ = [$1];']\n ]\n list_basic_expression [\n ['terminal_list_no_arg'. '$$ = [$1];']\n ]\n terminal_list_no_arg [\n ['terminal_list no_arg_punctuation'. '$1.push($2); $$ = $1;']\n ['terminal_list'. '$$ = $1;']\n ]\n basic_expression [\n ['terminal_list'. '$$ = yy.terms.basicExpression($1);']\n ]\n no_arg_punctuation [\n ['no_arg'. '$$ = yy.terms.loc(yy.terms.noArgSuffix(), @$);']\n ]\n no_arg [\n ['!'. '$$ = $1;']\n ['?'. '$$ = $1;']\n ]\n terminal_list [\n ['terminal_list terminal'. '$1.push($2); $$ = $1;']\n ['terminal'. '$$ = [$1];']\n ]\n terminal [\n ['( arguments_list )'. '$$ = yy.terms.loc(yy.terms.argumentList(yy.terms.normaliseArguments($2)), @$);']\n ['@ ( parameter_list )'. '$$ = yy.terms.loc(yy.terms.parameters($3), @$);']\n ['block_start statements }'. '$$ = yy.terms.loc(yy.terms.block([], $2), @$);']\n ['=> block_start statements }'. '$$ = yy.terms.loc(yy.terms.block([], $3, {redefinesSelf: true}), @$);']\n ['[ statements_list ]'. '$$ = yy.terms.loc(yy.terms.list($2), @$);']\n ['{ hash_entries }'. '$$ = yy.terms.loc(yy.terms.hash($2), @$);']\n ['float'. '$$ = yy.terms.loc(yy.terms.float(parseFloat(yytext)), @$);']\n ['integer'. '$$ = yy.terms.loc(yy.terms.integer(parseInt(yytext)), @$);']\n ['identifier'. '$$ = yy.terms.loc(yy.terms.identifier(yytext), @$);']\n ['string'. '$$ = yy.terms.loc(yy.terms.string(yy.terms.unindent(@$.first_column + 1, yy.terms.normaliseString(yytext))), @$);']\n ['reg_exp'. '$$ = yy.terms.loc(yy.terms.regExp(yy.terms.parseRegExp(yy.terms.unindent(@$.first_column + 1, yytext))), @$);']\n ['interpolated_string'. '$$ = yy.terms.loc($1, @$);']\n ['...'. '$$ = yy.terms.loc(yy.terms.splat(), @$);']\n ]\n block_start [\n ['@ {'. '$$ = ''@{''']\n ['@{'. '$$ = ''@{''']\n ]\n unary_operator [\n ['operator'. '$$ = $1;']\n ['!'. '$$ = $1;']\n ]\n interpolated_terminal [\n ['( statement )'. '$$ = $2;']\n ['identifier'. '$$ = yy.terms.variable([$1]);']\n ]\n interpolated_string [\n ['start_interpolated_string interpolated_string_components end_interpolated_string'. '$$ = yy.terms.interpolatedString($2, @$.first_column);']\n ['start_interpolated_string end_interpolated_string'. '$$ = yy.terms.interpolatedString([], @$.first_column);']\n ]\n interpolated_string_components [\n ['interpolated_string_components interpolated_string_component'. '$1.push($2); $$ = $1;']\n ['interpolated_string_component'. '$$ = [$1];']\n ]\n interpolated_string_component [\n ['interpolated_string_terminal_start interpolated_terminal'. '$$ = $2;']\n ['interpolated_string_body'. '$$ = yy.terms.string($1);']\n ['escaped_interpolated_string_terminal_start'. '$$ = yy.terms.string(\"@\");']\n ['escape_sequence'. '$$ = yy.terms.string(yy.terms.normaliseInterpolatedString($1));']\n ]\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"2c093b79c6e1ac7c24349c0e4feab485d083f701","subject":"refactoring","message":"refactoring\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parser.pogo","new_file":"src\/bootstrap\/parser.pogo","new_contents":"jison parser = require 'jison':Parser\nterms = require '.\/codeGenerator\/codeGenerator'\nms = require '..\/lib\/memorystream'\n\ncreate parser with grammar @grammar =\n new (jison parser @grammar)\n\nidentifier pattern = '[a-zA-Z_$][a-zA-Z_$0-9]*'\n\ngrammar = #\n lex #\n start conditions #{interpolated_string, interpolated_string_terminal}\n\n rules [\n ['\\\\s+'. '\/* ignore whitespace *\/']\n ['[0-9]+\\\\.[0-9]+'. 'return ''float'';']\n ['[0-9]+'. 'return ''integer'';']\n ['@' + identifier pattern. 'return ''argument'';']\n ['@:' + identifier pattern. 'return ''self_argument'';']\n ['\\\\?' + identifier pattern. 'return ''parameter'';']\n [identifier pattern. 'return ''identifier'';']\n ['\\\\??\\\\('. 'if (yy.interpolation.interpolating()) {yy.interpolation.openBracket()} return yytext;']\n ['\\\\)'. 'if (yy.interpolation.interpolating()) {yy.interpolation.closeBracket(); if (yy.interpolation.finishedInterpolation()) {this.popState(); this.popState(); yy.interpolation.stopInterpolation()}} return '')'';']\n ['{'. 'return ''{'';']\n ['}'. 'return ''}'';']\n ['\\\\['. 'return ''['';']\n ['\\\\]'. 'return '']'';']\n ['\\\\\\\\[.]'. 'return yytext.substring(1);']\n ['\\\\\\\\@[{]'. 'if (!yy.stringBrackets) {return yytext.substring(1);} else {++yy.stringBrackets;}']\n ['\\\\\\\\[}]'. 'if (!yy.stringBrackets) {return yytext.substring(1);} else {--yy.stringBrackets;}']\n ['\\\\.\\\\.\\\\.'. 'return ''...''']\n ['([:=,?!.@`~#$%^&*+<>\/?|-]|\\\\\\\\\\\\\\\\)+'. 'return yy.lexOperator(yytext);']\n ['$'. 'return ''eof'';']\n ['''([^'']*'''')*[^'']*'''. 'return ''string'';']\n ['\"'. 'this.begin(''interpolated_string''); return ''start_interpolated_string'';']\n [['interpolated_string']. '@'. 'this.begin(''interpolated_string_terminal''); return ''interpolated_string_terminal_start'';']\n [['interpolated_string_terminal']. identifier pattern. 'this.popState(); return ''identifier'';']\n [['interpolated_string_terminal']. '\\\\('. 'yy.interpolation.startInterpolation(); this.begin(''INITIAL''); return ''('';']\n [['interpolated_string']. '\"'. 'this.popState(); return ''end_interpolated_string'';']\n [['interpolated_string']. '\\\\\\\\[.]'. '\/* ignore *\/']\n [['interpolated_string']. '\\\\\\\\[{]'. 'yy.stringBrackets++']\n [['interpolated_string']. '\\\\\\\\[}]'. 'yy.stringBrackets--;']\n [['interpolated_string']. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'. 'return ''escaped_escape_interpolated_string_body'';']\n [['interpolated_string']. '\\\\\\\\\\\\\\\\.'. 'return ''escaped_interpolated_string_body'';']\n [['interpolated_string']. '[^\"@\\\\\\\\]*'. 'return ''interpolated_string_body'';']\n ['.'. 'return ''non_token'';']\n ]\n\n operators [\n ['right'. '=']\n ['left'. ':']\n ]\n\n start 'module'\n\n bnf #\n module [\n ['statements eof'. 'return yy.module($1);']\n ]\n statements [\n ['statements_list'. '$$ = yy.statements($1);']\n ]\n hash_entries [\n ['hash_entries comma_dot basic_expression'. '$1.push($3.hashEntry()); $$ = $1;']\n ['basic_expression'. '$$ = [$1.hashEntry()];']\n [''. '$$ = [];']\n ]\n comma_dot [\n ['.'. '$$ = $1;']\n [','. '$$ = $1;']\n ]\n statements_list [\n ['statements_list . statement'. '$1.push($3); $$ = $1;']\n ['statement'. '$$ = [$1];']\n [''. '$$ = [];']\n ]\n statement [\n ['expression'. '$$ = $1.expression();']\n ]\n expression [\n ['expression = expression'. '$$ = $1.definition($3.expression());']\n ['operator_expression'. '$$ = $1;']\n ]\n operator_expression [\n ['operator_expression operator unary_operator_expression'. '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['unary_operator_expression'. '$$ = yy.operatorExpression($1);']\n ]\n unary_operator_expression [\n ['object_operation'. '$$ = $1;']\n ['unary_operator object_operation'. '$$ = yy.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n object_operation [\n ['object_operation : complex_expression'. '$$ = $3.objectOperation($1.expression());']\n [': complex_expression'. '$$ = $2.objectOperation(yy.selfExpression());']\n ['complex_expression'. '$$ = $1;']\n ]\n complex_expression [\n ['basic_expression_list'. '$$ = yy.complexExpression($1);']\n ]\n basic_expression_list [\n ['basic_expression_list , terminal_list'. '$1.push($3); $$ = $1;']\n ['terminal_list_no_arg'. '$$ = [$1];']\n ]\n terminal_list_no_arg [\n ['terminal_list no_arg_punctuation'. '$1.push($2); $$ = $1;']\n ['terminal_list'. '$$ = $1;']\n ]\n basic_expression [\n ['terminal_list'. '$$ = yy.basicExpression($1);']\n ]\n no_arg_punctuation [\n ['no_arg'. '$$ = yy.loc(yy.noArgSuffix(), @$);']\n ]\n no_arg [\n ['!'. '$$ = $1;']\n ['?'. '$$ = $1;']\n ]\n terminal_list [\n ['terminal_list terminal'. '$1.push($2); $$ = $1;']\n ['terminal'. '$$ = [$1];']\n ]\n terminal [\n ['( statement )'. '$$ = $2;']\n ['?( statement )'. '$$ = yy.parameter($2);']\n ['block_start statements }'. '$$ = yy.loc(yy.block([], $2), @$);']\n ['=> { statements }'. '$$ = yy.loc(yy.block([], $3, {redefinesSelf: true}), @$);']\n ['[ statements_list ]'. '$$ = yy.loc(yy.list($2), @$);']\n ['{ hash_entries }'. '$$ = yy.loc(yy.hash($2), @$);']\n ['float'. '$$ = yy.loc(yy.float(parseFloat(yytext)), @$);']\n ['integer'. '$$ = yy.loc(yy.integer(parseInt(yytext)), @$);']\n ['identifier'. '$$ = yy.loc(yy.identifier(yytext), @$);']\n ['argument'. '$$ = yy.loc(yy.variable([yytext.substring(1)]), @$);']\n ['self_argument'. '$$ = yy.loc(yy.fieldReference(yy.variable([''self'']), [yytext.substring(2)]), @$);']\n ['parameter'. '$$ = yy.loc(yy.parameter(yy.variable([yytext.substring(1)])), @$);']\n ['string'. '$$ = yy.loc(yy.string(yy.normaliseString(yytext)), @$);']\n ['interpolated_string'. '$$ = yy.loc($1, @$);']\n ['...'. '$$ = yy.loc(yy.splat(), @$);']\n ]\n block_start [\n ['@ {'. '$$ = ''@{''']\n ['@{'. '$$ = ''@{''']\n ]\n operator [\n ['raw_operator'. '$$ = yy.normaliseOperator(yytext);']\n ]\n unary_operator [\n ['operator'. '$$ = $1;']\n ['!'. '$$ = $1;']\n ]\n interpolated_terminal [\n ['( statement )'. '$$ = $2;']\n ['identifier'. '$$ = yy.variable([$1]);']\n ]\n interpolated_string [\n ['start_interpolated_string interpolated_string_components end_interpolated_string'. '$$ = yy.interpolatedString($2);']\n ['start_interpolated_string end_interpolated_string'. '$$ = yy.interpolatedString([]);']\n ]\n interpolated_string_components [\n ['interpolated_string_components interpolated_string_component'. '$1.push($2); $$ = $1;']\n ['interpolated_string_component'. '$$ = [$1];']\n ]\n interpolated_string_component [\n ['interpolated_string_terminal_start interpolated_terminal'. '$$ = $2;']\n ['interpolated_string_body'. '$$ = yy.string($1);']\n ['escaped_interpolated_string_body'. '$$ = yy.string(yy.normaliseInterpolatedString($1.substring(1)));']\n ['escaped_escape_interpolated_string_body'. '$$ = yy.string($1.substring(3));']\n ]\n\nexports: parser = parser = create parser with grammar @grammar\nparser: yy = terms\n\nexports: parse @source = parser: parse @source\n","old_contents":"jison parser = require 'jison':Parser\nterms = require '.\/codeGenerator\/codeGenerator'\nms = require '..\/lib\/memorystream'\n\ncreate parser with grammar @grammar =\n new (jison parser @grammar)\n\nidentifier pattern = '[a-zA-Z_$][a-zA-Z_$0-9]*'\n\ngrammar = #\n lex #\n start conditions #{interpolated_string, interpolated_string_terminal}\n\n rules [\n ['\\\\s+'. '\/* ignore whitespace *\/']\n ['[0-9]+\\\\.[0-9]+'. 'return ''float'';']\n ['[0-9]+'. 'return ''integer'';']\n ['@' + identifier pattern. 'return ''argument'';']\n ['@:' + identifier pattern. 'return ''self_argument'';']\n ['\\\\?' + identifier pattern. 'return ''parameter'';']\n [identifier pattern. 'return ''identifier'';']\n ['\\\\??\\\\('. 'if (yy.interpolation.interpolating()) {yy.interpolation.openBracket()} return yytext;']\n ['\\\\)'. 'if (yy.interpolation.interpolating()) {yy.interpolation.closeBracket(); if (yy.interpolation.finishedInterpolation()) {this.popState(); this.popState(); yy.interpolation.stopInterpolation()}} return '')'';']\n ['{'. 'return ''{'';']\n ['}'. 'return ''}'';']\n ['\\\\['. 'return ''['';']\n ['\\\\]'. 'return '']'';']\n ['\\\\\\\\[.]'. 'return yytext.substring(1);']\n ['\\\\\\\\@[{]'. 'if (!yy.stringBrackets) {return yytext.substring(1);} else {++yy.stringBrackets;}']\n ['\\\\\\\\[}]'. 'if (!yy.stringBrackets) {return yytext.substring(1);} else {--yy.stringBrackets;}']\n ['\\\\.\\\\.\\\\.'. 'return ''...''']\n ['([:=,?!.@`~#$%^&*+<>\/?|-]|\\\\\\\\\\\\\\\\)+'. 'return yy.lexOperator(yytext);']\n ['$'. 'return ''eof'';']\n ['''([^'']*'''')*[^'']*'''. 'return ''string'';']\n ['\"'. 'this.begin(''interpolated_string''); return ''start_interpolated_string'';']\n [['interpolated_string']. '@'. 'this.begin(''interpolated_string_terminal''); return ''interpolated_string_terminal_start'';']\n [['interpolated_string_terminal']. identifier pattern. 'this.popState(); return ''identifier'';']\n [['interpolated_string_terminal']. '\\\\('. 'yy.interpolation.startInterpolation(); this.begin(''INITIAL''); return ''('';']\n [['interpolated_string']. '\"'. 'this.popState(); return ''end_interpolated_string'';']\n [['interpolated_string']. '\\\\\\\\[.]'. '\/* ignore *\/']\n [['interpolated_string']. '\\\\\\\\[{]'. 'yy.stringBrackets++']\n [['interpolated_string']. '\\\\\\\\[}]'. 'yy.stringBrackets--;']\n [['interpolated_string']. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'. 'return ''escaped_escape_interpolated_string_body'';']\n [['interpolated_string']. '\\\\\\\\\\\\\\\\.'. 'return ''escaped_interpolated_string_body'';']\n [['interpolated_string']. '[^\"@\\\\\\\\]*'. 'return ''interpolated_string_body'';']\n ['.'. 'return ''non_token'';']\n ]\n\n operators [\n ['right'. '=']\n ['left'. ':']\n ]\n\n start 'module'\n\n bnf #\n module [\n ['statements eof'. 'return yy.module($1);']\n ]\n statements [\n ['statements_list'. '$$ = yy.statements($1);']\n ]\n hash_entries [\n ['hash_entries comma_dot basic_expression'. '$1.push($3.hashEntry()); $$ = $1;']\n ['basic_expression'. '$$ = [$1.hashEntry()];']\n [''. '$$ = [];']\n ]\n comma_dot [\n ['.'. '$$ = $1;']\n [','. '$$ = $1;']\n ]\n statements_list [\n ['statements_list . statement'. '$1.push($3); $$ = $1;']\n ['statement'. '$$ = [$1];']\n [''. '$$ = [];']\n ]\n statement [\n ['expression'. '$$ = $1.expression();']\n ]\n expression [\n ['expression = expression'. '$$ = $1.definition($3.expression());']\n ['operator_expression'. '$$ = $1;']\n ]\n operator_expression [\n ['operator_expression operator unary_operator_expression'. '$1.addOperatorExpression($2, $3); $$ = $1;']\n ['unary_operator_expression'. '$$ = yy.operatorExpression($1);']\n ]\n unary_operator_expression [\n ['object_operation'. '$$ = $1;']\n ['unary_operator object_operation'. '$$ = yy.newUnaryOperatorExpression({operator: $1, expression: $2.expression()});']\n ]\n object_operation [\n ['object_operation : complex_expression'. '$$ = $3.objectOperation($1.expression());']\n [': complex_expression'. '$$ = $2.objectOperation(yy.selfExpression());']\n ['complex_expression'. '$$ = $1;']\n ]\n complex_expression [\n ['basic_expression_list'. '$$ = yy.complexExpression($1);']\n ]\n basic_expression_list [\n ['basic_expression_list , terminal_list'. '$1.push($3); $$ = $1;']\n ['terminal_list_no_arg'. '$$ = [$1];']\n ]\n terminal_list_no_arg [\n ['terminal_list no_arg_punctuation'. '$1.push($2); $$ = $1;']\n ['terminal_list'. '$$ = $1;']\n ]\n basic_expression [\n ['terminal_list'. '$$ = yy.basicExpression($1);']\n ]\n no_arg_punctuation [\n ['no_arg'. '$$ = yy.loc(yy.noArgSuffix(), @$);']\n ]\n no_arg [\n ['!'. '$$ = $1;']\n ['?'. '$$ = $1;']\n ]\n terminal_list [\n ['terminal_list terminal'. '$1.push($2); $$ = $1;']\n ['terminal'. '$$ = [$1];']\n ]\n terminal [\n ['( statement )'. '$$ = $2;']\n ['?( statement )'. '$$ = yy.parameter($2);']\n ['block_start statements }'. '$$ = yy.loc(yy.block([], $2), @$);']\n ['=> { statements }'. '$$ = yy.loc(yy.block([], $3, {redefinesSelf: true}), @$);']\n ['[ statements_list ]'. '$$ = yy.loc(yy.list($2), @$);']\n ['{ hash_entries }'. '$$ = yy.loc(yy.hash($2), @$);']\n ['float'. '$$ = yy.loc(yy.float(parseFloat(yytext)), @$);']\n ['integer'. '$$ = yy.loc(yy.integer(parseInt(yytext)), @$);']\n ['identifier'. '$$ = yy.loc(yy.identifier(yytext), @$);']\n ['argument'. '$$ = yy.loc(yy.variable([yytext.substring(1)]), @$);']\n ['self_argument'. '$$ = yy.loc(yy.fieldReference(yy.variable([''self'']), [yytext.substring(2)]), @$);']\n ['parameter'. '$$ = yy.loc(yy.parameter(yy.variable([yytext.substring(1)])), @$);']\n ['string'. '$$ = yy.loc(yy.string(yy.normaliseString(yytext)), @$);']\n ['interpolated_string'. '$$ = yy.loc($1, @$);']\n ['...'. '$$ = yy.loc(yy.splat(), @$);']\n ]\n 'block_start' [\n ['@ {'. '$$ = ''@{''']\n ['@{'. '$$ = ''@{''']\n ]\n operator [\n ['raw_operator'. '$$ = yy.normaliseOperator(yytext);']\n ]\n unary_operator [\n ['operator'. '$$ = $1;']\n ['!'. '$$ = $1;']\n ]\n interpolated_terminal [\n ['( statement )'. '$$ = $2;']\n ['identifier'. '$$ = yy.variable([$1]);']\n ]\n interpolated_string [\n ['start_interpolated_string interpolated_string_components end_interpolated_string'. '$$ = yy.interpolatedString($2);']\n ['start_interpolated_string end_interpolated_string'. '$$ = yy.interpolatedString([]);']\n ]\n interpolated_string_components [\n ['interpolated_string_components interpolated_string_component'. '$1.push($2); $$ = $1;']\n ['interpolated_string_component'. '$$ = [$1];']\n ]\n interpolated_string_component [\n ['interpolated_string_terminal_start interpolated_terminal'. '$$ = $2;']\n ['interpolated_string_body'. '$$ = yy.string($1);']\n ['escaped_interpolated_string_body'. '$$ = yy.string(yy.normaliseInterpolatedString($1.substring(1)));']\n ['escaped_escape_interpolated_string_body'. '$$ = yy.string($1.substring(3));']\n ]\n\nexports: parser = parser = create parser with grammar @grammar\nparser: yy = terms\n\nexports: parse @source = parser: parse @source\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"24b821eb75743300779344e71360d9cd18e441d8","subject":"basicExpressionSpec.pogo using new syntax","message":"basicExpressionSpec.pogo using new syntax\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/basicExpressionSpec.pogo","new_file":"src\/bootstrap\/basicExpressionSpec.pogo","new_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\nassert = require 'assert'\n\nspec 'basic expression'\n with terminals @terminals should not have arguments =\n ex = cg: basic expression @terminals\n (ex: has arguments?) should be falsy\n \n with terminals @terminals should have arguments =\n ex = cg: basic expression @terminals\n (ex: has arguments?) should be truthy\n \n variable = cg: variable ['a']\n block = cg: block [] (cg: statements [variable])\n id @name = cg: identifier @name\n int @n =\n cg: integer @n\n \n string @n =\n cg: string @n\n \n no arg punctuation = cg: no arg suffix?\n \n spec 'has arguments'\n spec 'with one variable'\n with terminals [variable] should have arguments\n \n spec 'with a block'\n with terminals [block] should have arguments\n \n spec 'with name and a block'\n with terminals [id 'c'. block] should have arguments\n \n spec 'with name, no arguments but a no arg punctuation'\n with terminals [id 'c'. no arg punctuation] should have arguments\n \n spec 'doesnt have arguments'\n spec 'with just an identifier'\n with terminals [id 'a'] should not have arguments\n \n spec 'with two identifiers'\n with terminals [id 'a'. id 'b'] should not have arguments\n\n spec 'arguments'\n terminals @terminals should have arguments @arguments =\n (cg: basic expression @terminals: arguments?) should contain fields @arguments\n \n spec 'single variable'\n terminals [variable] should have arguments [variable]\n \n spec 'variable with name'\n terminals [id 'move'. variable] should have arguments [variable]\n \n spec 'block'\n terminals [block] should have arguments [{\n is block\n body {\n statements [{is variable, variable ['a']}]\n }\n }]\n \n spec 'block with a parameter'\n terminals [cg: parameter (cg: variable ['x']). block] should have arguments [{\n is block\n parameters [{is parameter, expression {variable ['x']}}]\n body {\n statements [{is variable, variable ['a']}]\n }\n }]\n\n spec 'parameters'\n target @expression has some parameters =\n (cg: basic expression @expression: has parameters?) should be truthy\n \n target @expression doesnt have some parameters =\n (cg: basic expression @expression: has parameters?) should be falsy\n \n target @expression has parameters @parameters =\n (cg: basic expression @expression: parameters?) should contain fields @parameters\n \n spec 'single name'\n target [id 'car'] doesnt have some parameters\n \n spec 'name and variable'\n spec 'has parameters'\n target [id 'car'. variable] has some parameters\n\n spec 'parameters'\n target [id 'car'. variable] has parameters [{is parameter, expression {variable ['a']}}]\n \n spec 'no arg punctuation'\n spec 'has parameters'\n target [id 'car'. no arg punctuation] has some parameters\n \n spec 'parameters'\n target [id 'car'. no arg punctuation] has parameters []\n \n spec 'has name'\n terminals @terminals should have a name =\n (cg: basic expression @terminals: has name?) should be truthy\n\n spec 'with two identifiers'\n terminals [id 'car'. id 'idle'] should have a name\n\n spec 'name'\n terminals @terminals should have name @name =\n (cg: basic expression @terminals: name?) should contain fields @name\n \n spec 'with two identifiers'\n terminals [id 'car'. id 'idle'] should have name ['car'. 'idle']\n \n spec 'with two identifiers and arg'\n terminals [id 'car'. cg: variable ['car']. id 'idle'] should have name ['car'. 'idle']\n\n spec 'hash entry'\n hash entry @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry?) should contain fields @f\n \n spec 'with an argument'\n hash entry [id 'port'. int 10] should contain fields {\n is hash entry\n field ['port']\n value {integer 10}\n }\n \n spec 'without an argument'\n hash entry [id 'port'] should contain fields {\n is hash entry\n field ['port']\n value @undefined\n }\n \n spec 'with a string name'\n hash entry [string 'the port'. int 8] should contain fields {\n is hash entry\n field ['the port']\n value {integer 8}\n }\n\n spec 'hash entry, without block'\n hash entry @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry, without block) should contain fields @f\n \n spec 'with block'\n hash entry [id 'port'. int 10. block] should contain fields {\n is hash entry\n field ['port']\n value {integer 10}\n }\n \n spec 'without arguments'\n hash entry [id 'port'] should contain fields {\n is hash entry\n field ['port']\n value @undefined\n }\n\n spec 'hash entry block'\n hash entry block @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry block?) should contain fields @f\n\n spec 'with block'\n hash entry block [id 'port'. int 10. block] should contain fields {\n is block\n body {statements [{variable ['a']}]}\n }\n\n spec 'without block'\n assert: (cg: basic expression [id 'port'. int 10]: hash entry block?) equal @undefined\n\n spec 'without hash'\n assert: (cg: basic expression [id 'port']: hash entry block?) equal @undefined\n","old_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\nassert = require 'assert'\n\nspec 'basic expression'\n with terminals @terminals should not have arguments =\n ex = cg: basic expression @terminals\n (ex: has arguments?) should be falsy\n \n with terminals @terminals should have arguments =\n ex = cg: basic expression @terminals\n (ex: has arguments?) should be truthy\n \n variable = cg: variable ['a']\n block = cg: block [] (cg: statements [variable])\n id @name = cg: identifier @name\n int @n =\n cg: integer @n\n \n string @n =\n cg: string @n\n \n no arg punctuation = cg: no arg suffix?\n \n spec 'has arguments'\n spec 'with one variable'\n with terminals [variable] should have arguments\n \n spec 'with a block'\n with terminals [block] should have arguments\n \n spec 'with name and a block'\n with terminals [id 'c'. block] should have arguments\n \n spec 'with name, no arguments but a no arg punctuation'\n with terminals [id 'c'. no arg punctuation] should have arguments\n \n spec 'doesnt have arguments'\n spec 'with just an identifier'\n with terminals [id 'a'] should not have arguments\n \n spec 'with two identifiers'\n with terminals [id 'a'. id 'b'] should not have arguments\n\n spec 'arguments'\n terminals @terminals should have arguments @arguments =\n (cg: basic expression @terminals: arguments?) should contain fields @arguments\n \n spec 'single variable'\n terminals [variable] should have arguments [variable]\n \n spec 'variable with name'\n terminals [id 'move'. variable] should have arguments [variable]\n \n spec 'block'\n terminals [block] should have arguments [#{\n is block\n body #{\n statements [#{is variable, variable ['a']}]\n }\n }]\n \n spec 'block with a parameter'\n terminals [cg: parameter (cg: variable ['x']). block] should have arguments [#{\n is block\n parameters [#{is parameter, expression #{variable ['x']}}]\n body #{\n statements [#{is variable, variable ['a']}]\n }\n }]\n\n spec 'parameters'\n target @expression has some parameters =\n (cg: basic expression @expression: has parameters?) should be truthy\n \n target @expression doesnt have some parameters =\n (cg: basic expression @expression: has parameters?) should be falsy\n \n target @expression has parameters @parameters =\n (cg: basic expression @expression: parameters?) should contain fields @parameters\n \n spec 'single name'\n target [id 'car'] doesnt have some parameters\n \n spec 'name and variable'\n spec 'has parameters'\n target [id 'car'. variable] has some parameters\n\n spec 'parameters'\n target [id 'car'. variable] has parameters [#{is parameter, expression #{variable ['a']}}]\n \n spec 'no arg punctuation'\n spec 'has parameters'\n target [id 'car'. no arg punctuation] has some parameters\n \n spec 'parameters'\n target [id 'car'. no arg punctuation] has parameters []\n \n spec 'has name'\n terminals @terminals should have a name =\n (cg: basic expression @terminals: has name?) should be truthy\n\n spec 'with two identifiers'\n terminals [id 'car'. id 'idle'] should have a name\n\n spec 'name'\n terminals @terminals should have name @name =\n (cg: basic expression @terminals: name?) should contain fields @name\n \n spec 'with two identifiers'\n terminals [id 'car'. id 'idle'] should have name ['car'. 'idle']\n \n spec 'with two identifiers and arg'\n terminals [id 'car'. cg: variable ['car']. id 'idle'] should have name ['car'. 'idle']\n\n spec 'hash entry'\n hash entry @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry?) should contain fields @f\n \n spec 'with an argument'\n hash entry [id 'port'. int 10] should contain fields #\n is hash entry\n field ['port']\n value #{integer 10}\n \n spec 'without an argument'\n hash entry [id 'port'] should contain fields #\n is hash entry\n field ['port']\n value @undefined\n \n spec 'with a string name'\n hash entry [string 'the port'. int 8] should contain fields #\n is hash entry\n field ['the port']\n value #{integer 8}\n\n spec 'hash entry, without block'\n hash entry @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry, without block) should contain fields @f\n \n spec 'with block'\n hash entry [id 'port'. int 10. block] should contain fields #\n is hash entry\n field ['port']\n value #{integer 10}\n \n spec 'without arguments'\n hash entry [id 'port'] should contain fields #\n is hash entry\n field ['port']\n value @undefined\n\n spec 'hash entry block'\n hash entry block @terminals should contain fields @f =\n (cg: basic expression @terminals: hash entry block?) should contain fields @f\n\n spec 'with block'\n hash entry block [id 'port'. int 10. block] should contain fields #\n is block\n body #{statements [#{variable ['a']}]}\n\n spec 'without block'\n assert: (cg: basic expression [id 'port'. int 10]: hash entry block?) equal @undefined\n\n spec 'without hash'\n assert: (cg: basic expression [id 'port']: hash entry block?) equal @undefined\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6d42243bef9180a8fe3589eb3d0e86e2eee6f969","subject":"additional for loop tests","message":"additional for loop tests\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/forSpec.pogo","new_file":"test\/forSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\n\ndescribe 'for'\n describe 'for each'\n it \"returns in functions within for don't return from for\"\n script.'items = [[1, 2, 3], [1, 2], [1]]\n\n for each @(item) in (items)\n item count () = return (item.length)\n\n print (item count ())' shouldOutput '3\n 2\n 1'\n\n describe 'async'\n it \"waits for loop to finish resolving promise before moving onto next loop\"\n script.'items = [1, 2, 3]\n\n for each @(item) in (items)\n print \"before #(item)\"\n p()!\n print \"after #(item)\"\n\n print \"finished\"' shouldOutput \"'before 1'\n 'after 1'\n 'before 2'\n 'after 2'\n 'before 3'\n 'after 3'\n 'finished'\"\n\n it \"doesn't loop if there aren't any items\"\n script.'items = []\n\n for each @(item) in (items)\n print \"before #(item)\"\n p()!\n print \"after #(item)\"\n\n print \"finished\"' shouldOutput \"'finished'\"\n\n describe 'for loop'\n it 'can be returned from'\n script.'count to three () =\n for (n = 0, n < 10, ++n)\n if (n > 2)\n return \"three\"\n\n print (count to three ())' shouldOutput \"'three'\"\n\n it 'can loop'\n script.'count to three () =\n for (n = 0, n < 10, ++n)\n print (n)\n\n count to three ()' shouldOutput '0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9'\n\n describe 'async'\n it 'waits for loop to finish resolving promise before moving onto next loop'\n script.'for (n = 0, n < 3, ++n)\n print \"before #(n)\"\n p()!\n print \"after #(n)\"\n\n print \"finished\"' shouldOutput \"'before 0'\n 'after 0'\n 'before 1'\n 'after 1'\n 'before 2'\n 'after 2'\n 'finished'\"\n\n it \"doesn't loop if the test fails\"\n script.'for (n = 0, false, ++n)\n print \"before #(n)\"\n p()!\n print \"after #(n)\"\n\n print \"finished\"' shouldOutput \"'finished'\"\n\n describe 'for in'\n it \"iterates over object's fields\"\n script.'object = {a = 1, b = 2}\n\n for @(field) in (object)\n print (field)' shouldOutput \"'a'\n 'b'\"\n","old_contents":"script = require '.\/scriptAssertions'\n\ndescribe 'for'\n describe 'for each'\n it \"returns in functions within for don't return from for\"\n script.'items = [[1, 2, 3], [1, 2], [1]]\n\n for each @(item) in (items)\n item count () = return (item.length)\n\n print (item count ())' shouldOutput '3\n 2\n 1'\n\n it \"waits for loop to finish resolving promise before moving onto next loop\"\n script.'items = [1, 2, 3]\n\n for each @(item) in (items)\n print \"before #(item)\"\n p()!\n print \"after #(item)\"\n\n print \"finished\"' shouldOutput \"'before 1'\n 'after 1'\n 'before 2'\n 'after 2'\n 'before 3'\n 'after 3'\n 'finished'\"\n\n describe 'for loop'\n it 'can be returned from'\n script.'count to three () =\n for (n = 0, n < 10, ++n)\n if (n > 2)\n return \"three\"\n\n print (count to three ())' shouldOutput \"'three'\"\n\n it 'can loop'\n script.'count to three () =\n for (n = 0, n < 10, ++n)\n print (n)\n\n count to three ()' shouldOutput '0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9'\n\n it 'waits for loop to finish resolving promise before moving onto next loop'\n script.'for (n = 0, n < 3, ++n)\n print \"before #(n)\"\n p()!\n print \"after #(n)\"\n\n print \"finished\"' shouldOutput \"'before 0'\n 'after 0'\n 'before 1'\n 'after 1'\n 'before 2'\n 'after 2'\n 'finished'\"\n\n describe 'for in'\n it \"iterates over object's fields\"\n script.'object = {a = 1, b = 2}\n\n for @(field) in (object)\n print (field)' shouldOutput \"'a'\n 'b'\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"1d8c8d5856f0142e9d6f692d61b43f38fcbabf00","subject":"removed a few @ symbols :)","message":"removed a few @ symbols :)\n","repos":"featurist\/pogo-examples","old_file":"index.pogo","new_file":"index.pogo","new_contents":"fs = require \"fs\"\nasync = require \"async\"\nhandlebars = require \"handlebars\"\nexec = require \"child_process\" : exec\nhighlight = require \"highlight\" : Highlight\n\nhtml = \"\n\n
\n{{{pogo this}}}<\/code><\/pre>\n <\/div>\n \n {{{js this}}}<\/code><\/pre>\n <\/div>\n
\n <\/li>\n {{\/each}}\n <\/ul>\n \n <\/body>\n<\/html>\n\"\ntemplate = handlebars: compile @html\n\ntitle case @string =\n reg = new (RegExp \"_\" \"g\")\n string = string : replace @reg \" \"\n reg = new (RegExp \"\\w\\S*\" \"g\")\n string: replace @reg #text\n (text : char at 0 : to upper case!) + (text : substr 1 : to lower case!)\n\nremove closure from @js =\n reg = new (RegExp \"(^[^\\n]+\\n\\s*)|(\\n[^\\n]+$)\" \"g\")\n js : replace @reg (new (String))\n\nunindent @js =\n reg = new (RegExp \"\\n \" \"g\")\n js : replace @reg \"\\n\"\n\nsimplify @js =\n unindent (remove closure from @js)\n\nread compiled js at @path @pogo @callback =\n fs : read file @path \"utf-8\" #jserr #js\n js = simplify @js\n name = path : replace \".\/examples\/\" (new (String))\n name = name : replace \".js\" (new (String))\n @callback @null {\n js = @highlight @js\n pogo = @highlight @pogo\n name = (title case) @name\n } \n\ncompile pogo @path @pogo @callback =\n js path = path: replace \".pogo\" \".js\"\n exec \"pogo -c @path\" #error #stdout #stderr\n read compiled js at (js path) @pogo @callback\n\nrender @file @callback =\n path = \".\/examples\/@file\"\n fs: read file @path \"utf-8\" #err #pogo\n compile pogo @path @pogo @callback\n\nprint @err @results =\n rendered = template { examples = @results }\n console: log @rendered\n\nis @path pogo =\n path : index of \".pogo\" > -1\n \ndir @err @files =\n pogos = files : filter (is pogo)\n async: map @pogos @render @print\n \nfs: readdir \".\/examples\/\" @dir\n\n","old_contents":"fs = require \"fs\"\nasync = require \"async\"\nhandlebars = require \"handlebars\"\nexec = require \"child_process\" : exec\nhighlight = require \"highlight\" : Highlight\n\nhtml = \"\n\n \n Pogo Examples<\/title>\n \n \n <\/head>\n \n
<\/a>\n PogoScript to JavaScript Examples<\/h1>\n \n {{#each examples}}\n - \n
{{this.name}}<\/h2>\n \n {{{pogo this}}}<\/code><\/pre>\n <\/div>\n \n {{{js this}}}<\/code><\/pre>\n <\/div>\n
\n <\/li>\n {{\/each}}\n <\/ul>\n \n <\/body>\n<\/html>\n\"\ntemplate = handlebars: compile @html\n\ntitle case @string =\n reg = new (RegExp \"_\" \"g\")\n string = string : replace @reg \" \"\n reg = new (RegExp \"\\w\\S*\" \"g\")\n string: replace @reg #text\n (text : char at 0 : to upper case!) + (text : substr 1 : to lower case!)\n\nremove closure from @js =\n reg = new (RegExp \"(^[^\\n]+\\n\\s*)|(\\n[^\\n]+$)\" \"g\")\n js : replace @reg (new (String))\n\nunindent @js =\n reg = new (RegExp \"\\n \" \"g\")\n js : replace @reg \"\\n\"\n\nsimplify @js =\n unindent (remove closure from @js)\n\nread compiled js at @path @pogo @callback =\n fs : read file @path \"utf-8\" #jserr #js\n js = simplify @js\n name = @path : replace \".\/examples\/\" (new (String))\n name = @name : replace \".js\" (new (String))\n @callback @null {\n js = @highlight @js\n pogo = @highlight @pogo\n name = (title case) @name\n } \n\ncompile pogo @path @pogo @callback =\n js path = @path: replace \".pogo\" \".js\"\n exec \"pogo -c @path\" #error #stdout #stderr\n read compiled js at (js path) @pogo @callback\n\nrender @file @callback =\n path = \".\/examples\/@file\"\n fs: read file @path \"utf-8\" #err #pogo\n compile pogo @path @pogo @callback\n\nprint @err @results =\n rendered = template { examples = @results }\n console: log @rendered\n\nis @path pogo =\n path : index of \".pogo\" > -1\n \ndir @err @files =\n pogos = files : filter (is pogo)\n async: map @pogos @render @print\n \nfs: readdir \".\/examples\/\" @dir\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"bafb002dbcd38c603f8aeb536036f4fb13b2a6b6","subject":"atoms: not yet!","message":"atoms: not yet!\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"lib\/parser\/atoms.pogo","new_file":"lib\/parser\/atoms.pogo","new_contents":"","old_contents":"require '.\/runtime.pogo'\n\natom prototype = object {\n arguments () = []\n block parameters () = []\n word () = null\n block () = null\n}\n\nself.atom (forms, members) =\n a = object extending (atom prototype) (members)\n a.forms = forms\n a\n\nself.argument (forms, argument) = self.atom (forms) {\n arguments () = [argument]\n}\n\nself.block atom (forms, block) = self.atom (forms) {\n block () = block\n}\n\nself.word (forms, word) = self.atom (forms) {\n word () = word\n}\n\nself.block parameters (forms, parameters) = self.atom (forms) {\n block parameters () = parameters\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"fe1d683b2103180ae23a7854e9989cb8545550b6","subject":"reorganise test","message":"reorganise test\n","repos":"featurist\/bo-selector","old_file":"test\/parser_spec.pogo","new_file":"test\/parser_spec.pogo","new_contents":"parser = require(\"..\/parser\").parser\nNode = require(\".\/renderer\").Node\n\ndescribe 'parser'\n\n parser.yy.create (data) = @new Node (data)\n\n parses (input) as (output) =\n it \"parses #(input) as #(output)\"\n parser.parse(input).render().should.equal(output.replace('*', ''))\n\n parses (input) =\n parses (input) as (input)\n\n parses \"*\"\n parses \"a\"\n parses \"a, b\"\n parses \"a,b\" as \"a, b\"\n parses \"a, b,c\" as \"a, b, c\"\n parses \"a.b\"\n parses \"a.b.c\"\n parses \"#a\"\n parses \"#a.b\"\n parses \".a #b\"\n parses \"a[b]\"\n parses \"a[b][c]\"\n\n parses \"a[b = c]\"\n parses \"a[b= c]\" as \"a[b = c]\"\n parses \"a[b =c]\" as \"a[b = c]\"\n parses \"a[b=c]\" as \"a[b = c]\"\n parses \"a[b = 'c']\" as \"a[b = c]\"\n parses \"a[b= 'c']\" as \"a[b = c]\"\n parses \"a[b ='c']\" as \"a[b = c]\"\n parses \"a[b='c']\" as \"a[b = c]\"\n parses 'a[b = \"c\"]' as \"a[b = c]\"\n parses 'a[b= \"c\"]' as 'a[b = c]'\n parses 'a[b =\"c\"]' as 'a[b = c]'\n parses 'a[b=\"c\"]' as 'a[b = c]'\n\n parses \"a[b ~= c]\"\n parses \"a[b~= c]\" as \"a[b ~= c]\"\n parses \"a[b ~=c]\" as \"a[b ~= c]\"\n parses \"a[b~=c]\" as \"a[b ~= c]\"\n parses \"a[b ~= 'c']\" as \"a[b ~= c]\"\n parses \"a[b~= 'c']\" as \"a[b ~= c]\"\n parses \"a[b ~='c']\" as \"a[b ~= c]\"\n parses \"a[b~='c']\" as \"a[b ~= c]\"\n parses 'a[b ~= \"c\"]' as \"a[b ~= c]\"\n parses 'a[b~= \"c\"]' as 'a[b ~= c]'\n parses 'a[b ~=\"c\"]' as 'a[b ~= c]'\n parses 'a[b~=\"c\"]' as 'a[b ~= c]'\n\n parses \"a[b |= c]\"\n parses \"a[b|= c]\" as \"a[b |= c]\"\n parses \"a[b |=c]\" as \"a[b |= c]\"\n parses \"a[b|=c]\" as \"a[b |= c]\"\n parses \"a[b |= 'c']\" as \"a[b |= c]\"\n parses \"a[b|= 'c']\" as \"a[b |= c]\"\n parses \"a[b |='c']\" as \"a[b |= c]\"\n parses \"a[b|='c']\" as \"a[b |= c]\"\n parses 'a[b |= \"c\"]' as \"a[b |= c]\"\n parses 'a[b|= \"c\"]' as 'a[b |= c]'\n parses 'a[b |=\"c\"]' as 'a[b |= c]'\n parses 'a[b|=\"c\"]' as 'a[b |= c]'\n\n parses \"a b\"\n parses \"a > b\"\n parses \"a> b\" as \"a > b\"\n parses \"a >b\" as \"a > b\"\n parses \"a>b\" as \"a > b\"\n parses \"a>b >c\" as \"a > b > c\"\n parses \"a > b > c d\"\n parses \"> a\" as \"* > a\"\n parses \"> a > b\" as \"* > a > b\"\n\n parses \"*:a\"\n parses \":a\"\n parses \":a-b\"\n parses \"a:b\"\n parses \"a:b:c\"\n parses \":a(b)\"\n parses \":a-b(c)\"\n parses \"a:b(c)\"\n parses \"a:b(c > d)\"\n\n parses \":has(> a)\" as \":has(* > a)\"\n\n parses \"a[b = c], c[d]:e:f(g *:h:i[j]:k), :l > m[n ~= o][p = q]\"\n","old_contents":"parser = require(\"..\/parser\").parser\nNode = require(\".\/renderer\").Node\n\ndescribe 'parser'\n\n parser.yy.create (data) = @new Node (data)\n\n parses (input) as (output) =\n it \"parses #(input) as #(output)\"\n parser.parse(input).render().should.equal(output.replace('*', ''))\n\n parses (input) =\n parses (input) as (input)\n\n parses \"*\"\n parses \"a\"\n parses \"a, b\"\n parses \"a,b\" as \"a, b\"\n parses \"a, b,c\" as \"a, b, c\"\n parses \"a.b\"\n parses \"a.b.c\"\n parses \"#a\"\n parses \"#a.b\"\n parses \".a #b\"\n parses \"a[b]\"\n\n parses \"a[b = c]\"\n parses \"a[b= c]\" as \"a[b = c]\"\n parses \"a[b =c]\" as \"a[b = c]\"\n parses \"a[b=c]\" as \"a[b = c]\"\n parses \"a[b = 'c']\" as \"a[b = c]\"\n parses \"a[b= 'c']\" as \"a[b = c]\"\n parses \"a[b ='c']\" as \"a[b = c]\"\n parses \"a[b='c']\" as \"a[b = c]\"\n parses 'a[b = \"c\"]' as \"a[b = c]\"\n parses 'a[b= \"c\"]' as 'a[b = c]'\n parses 'a[b =\"c\"]' as 'a[b = c]'\n parses 'a[b=\"c\"]' as 'a[b = c]'\n\n parses \"a[b ~= c]\"\n parses \"a[b~= c]\" as \"a[b ~= c]\"\n parses \"a[b ~=c]\" as \"a[b ~= c]\"\n parses \"a[b~=c]\" as \"a[b ~= c]\"\n parses \"a[b ~= 'c']\" as \"a[b ~= c]\"\n parses \"a[b~= 'c']\" as \"a[b ~= c]\"\n parses \"a[b ~='c']\" as \"a[b ~= c]\"\n parses \"a[b~='c']\" as \"a[b ~= c]\"\n parses 'a[b ~= \"c\"]' as \"a[b ~= c]\"\n parses 'a[b~= \"c\"]' as 'a[b ~= c]'\n parses 'a[b ~=\"c\"]' as 'a[b ~= c]'\n parses 'a[b~=\"c\"]' as 'a[b ~= c]'\n\n parses \"a[b |= c]\"\n parses \"a[b|= c]\" as \"a[b |= c]\"\n parses \"a[b |=c]\" as \"a[b |= c]\"\n parses \"a[b|=c]\" as \"a[b |= c]\"\n parses \"a[b |= 'c']\" as \"a[b |= c]\"\n parses \"a[b|= 'c']\" as \"a[b |= c]\"\n parses \"a[b |='c']\" as \"a[b |= c]\"\n parses \"a[b|='c']\" as \"a[b |= c]\"\n parses 'a[b |= \"c\"]' as \"a[b |= c]\"\n parses 'a[b|= \"c\"]' as 'a[b |= c]'\n parses 'a[b |=\"c\"]' as 'a[b |= c]'\n parses 'a[b|=\"c\"]' as 'a[b |= c]'\n\n parses \"a b\"\n parses \"a > b\"\n parses \"a> b\" as \"a > b\"\n parses \"a >b\" as \"a > b\"\n parses \"a>b\" as \"a > b\"\n parses \"a>b >c\" as \"a > b > c\"\n parses \"a > b > c d\"\n\n parses \"a, [b = c], c\"\n parses \"*:a\"\n parses \":a\"\n parses \":a-b\"\n parses \"a:b\"\n parses \"a:b:c\"\n parses \":a(b)\"\n parses \":a-b(c)\"\n parses \"a:b(c)\"\n parses \"a:b(c > d)\"\n parses \"a[b = c], c[d]:e:f(g *:h:i[j]:k), :l > m[n ~= o]\"\n\n parses \"> a\" as \"* > a\"\n parses \":has(> a)\" as \":has(* > a)\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"433c910ce7386b9321cf9b70e3d247e9e6c40ae7","subject":"parser spec using mocha","message":"parser spec using mocha\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parserSpec.pogo","new_file":"src\/bootstrap\/parserSpec.pogo","new_contents":"require '.\/assertions.pogo'\n\nparser = require '.\/parser.pogo'\nrequire '.\/parserAssertions.pogo'\n\ndescribe 'parser'\n describe 'terminals'\n it 'integer'\n (expression '5') should contain fields {\n integer 5\n }\n\n it 'float'\n (expression '5.6') should contain fields {\n float 5.6\n }\n\n describe 'variables'\n it 'simple'\n (expression 'total weight') should contain fields {\n variable ['total'. 'weight']\n }\n\n it 'can use $ as a variable'\n (expression '$') should contain fields {\n variable ['$']\n }\n \n describe 'strings'\n it 'simple string'\n (expression '''a string''') should contain fields {\n is string\n string 'a string'\n }\n \n it 'string with single quotes'\n (expression '''''''alright!'''' he said''') should contain fields {\n is string\n string '''alright!'' he said'\n }\n \n it 'string with backslash'\n (expression \"'one \\\\ two'\") should contain fields {\n is string\n string \"one \\\\ two\"\n }\n \n it 'multiline string'\n (expression \" 'one\\n two'\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'multiline double-quote string'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n it 'two multiline string in function'\n (expression \"x 'one\\n two' y \\\"three\\n four\\\"\") should contain fields {\n is function call\n function {variable ['x'. 'y']}\n arguments [\n {string \"one\\ntwo\"}\n {string \"three\\nfour\"}\n ]\n }\n\n describe 'interpolated strings'\n it 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n it 'empty'\n (expression '\"\"') should contain fields {\n is string\n string ''\n }\n\n it 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with newline escape and indentation should not remove indentation'\n (expression ' \"one\\n two\"') should contain fields {\n string \"one\\n two\"\n }\n\n it 'with indentation'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n string \"one\\ntwo\"\n }\n\n it 'with single variable expression'\n (expression '\"a boat #(boat length) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['boat'. 'length']}\n {string ' meters in length'}\n ]\n }\n\n it 'with escaped #'\n (expression '\"a boat \\#(boat length) meters in length\"') should contain fields {\n is string\n string 'a boat #(boat length) meters in length'\n }\n\n it 'with complex expression'\n (expression '\"a boat #(lookup boat length from (boat database)) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n function {variable ['lookup'. 'boat'. 'length'. 'from']}\n arguments [{variable ['boat'. 'database']}]\n }\n {string ' meters in length'}\n ]\n }\n \n it 'in block'\n (expression \"abc =\\n \\\"\\#(stuff)\\\"\") should contain fields {\n is definition\n target {\n is variable\n variable ['abc']\n }\n source {\n is scope\n statements [{\n is variable\n variable ['stuff']\n }]\n }\n }\n\n it 'with inner interpolation'\n (expression '\"a boat #(\"#(boat length) meters\") in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n is interpolated string\n components [\n {variable ['boat'. 'length']}\n {string ' meters'}\n ]\n }\n {string ' in length'}\n ]\n }\n\n describe 'sub expressions'\n it 'single expression'\n (expression '(x)') should contain fields {variable ['x']}\n\n it 'two expressions'\n (expression '(x. y)') should contain fields {\n is scope\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n \n describe 'lists'\n it 'empty'\n (expression '[]') should contain fields {\n is list\n items []\n }\n \n it 'one item'\n (expression '[1]') should contain fields {\n is list\n items [{integer 1}]\n }\n \n it 'two items'\n (expression '[1, 2]') should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n it 'two items separated by newlines'\n (expression \"[\\n 1\\n 2\\n]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n it 'two items separated by dots'\n (expression \"[1. 2]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n describe 'hashes'\n it 'empty hash'\n (expression '{}') should contain fields {\n is hash\n entries []\n }\n \n it 'hash with one entry'\n (expression '{port 1234}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n it 'hash with two entries'\n (expression '{port 1234, ip address ''1.1.1.1''}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n {\n field ['ip'. 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with two entries on different lines'\n (expression \"{port = 1234\\nip address = '1.1.1.1'}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['ip'. 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n it 'hash with string with assignment'\n (expression \"{'port' = 1234}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n it 'values can be specified on a new line'\n (expression \"{\n height =\n 80\n }\") should contain fields {\n is hash\n entries [\n {\n field ['height']\n value {\n is scope\n statements [{integer 80}]\n }\n }\n ]\n }\n \n it 'should allow methods to be defined, redefining self'\n (expression '{say hi to (name); greeting = print (name)}') should contain fields {\n is hash\n entries [\n {\n field ['say'. 'hi'. 'to']\n value {\n is block\n redefines self\n\n body {\n statements [{\n is function call\n\n function {variable ['print']}\n }]\n }\n\n parameters [{variable ['name']}]\n\n optional parameters [{\n is hash entry\n field ['greeting']\n }]\n }\n }\n ]\n }\n \n it 'hash with true entry'\n (expression '{port 1234. readonly}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['readonly']\n value (undefined)\n }\n ]\n }\n\n describe 'function calls'\n it 'function call'\n (expression 'touch (file)') should contain fields {\n function {variable ['touch']}\n arguments [{variable ['file']}]\n }\n\n it 'function call with splat argument'\n (expression 'touch (files) ...') should contain fields {\n function {variable ['touch']}\n arguments [\n {variable ['files']}\n {is splat}\n ]\n }\n\n it 'function call with no argument'\n (expression 'delete everything!') should contain fields {\n function {variable ['delete'. 'everything']}\n arguments []\n }\n\n it 'function call with no argument using empty parens'\n (expression 'delete everything ()') should contain fields {\n function {variable ['delete'. 'everything']}\n arguments []\n }\n\n it 'function call with block with parameters'\n (expression \"with file (file) @(stream)\\n stream\") should contain fields {\n function {variable ['with'. 'file']}\n arguments [\n {variable ['file']}\n {\n body {statements [{variable ['stream']}]}\n parameters [{variable ['stream']}]\n }\n ]\n }\n\n it 'function call with block with long parameters'\n (expression \"open database @(database connection)\\n database connection\") should contain fields {\n function {variable ['open'. 'database']}\n arguments [\n {\n parameters [\n {variable ['database'. 'connection']}\n ]\n body {statements [{variable ['database'. 'connection']}]}\n }\n ]\n }\n\n it 'function call with two blocks with parameters'\n (expression 'name @(x) @{x} @ (y) @ {y}') should contain fields {\n function {variable ['name']}\n arguments [\n {\n body {statements [{variable ['x']}]}\n parameters [{variable ['x']}]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{variable ['y']}]\n }\n ]\n }\n\n it 'function call with two optional arguments'\n (expression 'name (a); port 34; server (s)') should contain fields {\n function {variable ['name']}\n arguments [\n {variable ['a']}\n ]\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n {\n field ['server']\n value {variable ['s']}\n }\n ]\n }\n\n it 'function call with no arguments and one optional argument'\n (expression 'start server; port 34') should contain fields {\n function {variable ['start'. 'server']}\n arguments []\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n ]\n }\n \n describe 'object operations'\n it 'method call'\n (expression 'object: method (argument)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n arguments [{variable ['argument']}]\n }\n \n it 'method call with optional arguments'\n (expression 'object: method (argument); view (view)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n arguments [{variable ['argument']}]\n optional arguments [\n {field ['view']. value {variable ['view']}}\n ]\n }\n \n it 'field reference'\n (expression 'object: field') should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'field reference with newline'\n (expression \"object:\\nfield\") should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n it 'self field reference'\n (expression ':field') should contain fields {\n is field reference\n object {variable ['self']}\n name ['field']\n }\n \n it 'indexer'\n (expression 'object: (x)') should contain fields {\n is indexer\n object {variable ['object']}\n indexer {variable ['x']}\n }\n\n describe 'blocks'\n it 'empty block'\n (expression '@{}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements []}\n }\n \n it 'block'\n (expression '@{x.y}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements [\n {variable ['x']}\n {variable ['y']}\n ]}\n }\n\n it 'block with parameter'\n (expression \"@(x)\\n x.y\") should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (false)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n it 'block in parens'\n (expression \"(one\\n two\\n)\") should contain fields {\n is function call\n function {variable ['one']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['two']}\n ]\n }\n }\n ]\n }\n\n it 'block with parameter, redefining self'\n (expression '@(x) => @{x.y}') should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (true)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n describe 'operators'\n it 'should be lower precedence than object operation'\n (expression 'o:m 2 +- o:x') should contain fields {\n is method call\n object {\n is method call\n object {variable ['o']}\n name ['m']\n arguments [{integer 2}]\n }\n \n name ['+-']\n arguments [\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n ]\n }\n \n it 'parses backslash'\n (expression \"2 +\\\\+ 1\") should contain fields {\n is method call\n object {integer 2}\n \n name [\"+\\\\+\"]\n arguments [\n {integer 1}\n ]\n }\n \n it 'unary operators should be higher precedence than binary operators'\n (expression 'a && ! b') should contain fields {\n is operator\n operator '&&'\n \n arguments [\n {variable ['a']}\n {\n is operator\n operator '!'\n arguments [{variable ['b']}]\n }\n ]\n }\n \n it 'can have newlines immediately after operator'\n (expression \"a &&\\nb\") should contain fields {\n is operator\n operator '&&'\n \n arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n describe 'assignment'\n it 'assignment'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n describe 'function definition'\n it 'function with one parameter'\n (expression 'func (x) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'function with one parameter, and one optional parameter'\n (expression 'func (x); port 80 = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n optional parameters [{field ['port']. value {integer 80}}]\n body {statements [{variable ['x']}]}\n }\n }\n\n it 'field assignment'\n (expression 'o: x = y') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n\n source {variable ['y']}\n }\n\n it 'index assignment'\n (expression 'o: (x) = y') should contain fields {\n is definition\n target {\n is indexer\n object {variable ['o']}\n indexer {variable ['x']}\n }\n\n source {variable ['y']}\n }\n\n it 'assignment from field'\n (expression 'x = y: z') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is field reference\n object {\n variable ['y']\n }\n\n name ['z']\n }\n }\n\n it 'assignment of command'\n (expression 'x! = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'definition of function with no arguments, using empty parens \"()\"'\n (expression 'x () = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'assignment of query'\n (expression 'x? = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n it 'assignment from method call'\n (expression 'x = y: z (a)') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n arguments [{variable ['a']}]\n }\n }\n\n it 'field assignment from method call'\n (expression 'i: x = y: z (a)') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['i']}\n name ['x']\n }\n\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n arguments [{variable ['a']}]\n }\n }\n \n describe 'regexps'\n it 'simple'\n (expression '`abc`') should contain fields {\n is reg exp\n pattern 'abc'\n }\n\n it 'with options'\n (expression '`abc`img') should contain fields {\n is reg exp\n pattern 'abc'\n options 'img'\n }\n\n it 'with escaped back ticks'\n (expression '`abc\\`def\\`ghi`') should contain fields {\n is reg exp\n pattern 'abc`def`ghi'\n }\n\n it 'with newline'\n (expression \"a = `abc\\n def`\") should contain fields {\n is definition\n target {\n is variable\n variable ['a']\n }\n source {\n is reg exp\n pattern \"abc\\\\ndef\"\n }\n }\n \n describe 'comments'\n it 'should not treat comment-like syntax as comments in strings'\n (statements \"get 'http:\/\/pogoscript.org\/'\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['get']}\n arguments [\n {string 'http:\/\/pogoscript.org\/'}\n ]\n }]\n }\n \n describe 'should allow one-line C++ style comments, as in: \/\/ this is a comment'\n it 'when at the end of a line'\n (statements \"a \/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n it 'when before an indented block'\n (statements \"a \/\/ this is a comment\\n b\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['a']}\n arguments [{\n is block\n body {\n statements [\n {variable ['b']}\n ]\n }\n }]\n }]\n }\n\n it 'when at end of file'\n (statements \"a \/\/ this is a comment\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n describe 'should allow multi-line C style comments, as in: \/* this is a comment *\/'\n it 'when on one line'\n (statements \"a \/* comment *\/ b\") should contain fields {\n statements [\n {variable ['a'. 'b']}\n ]\n }\n\n it 'when there are two'\n (statements \"a \/* comment *\/ b \/* another comment *\/ c\") should contain fields {\n statements [\n {variable ['a'. 'b'. 'c']}\n ]\n }\n\n it 'when between lines'\n (statements \"a\\n\/* comment *\/\\nb\\n\/* another comment *\/\\nc\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n {variable ['c']}\n ]\n }\n\n it 'when it contains a * character'\n (statements \"a \/* sh*t *\/ b\") should contain fields {\n statements [\n {variable ['a'. 'b']}\n ]\n }\n\n it 'when it covers two lines'\n (statements \"a \/* line one\\nline two *\/ b\") should contain fields {\n statements [{\n is variable\n variable ['a'. 'b']\n }]\n }\n\n it 'when it extends to the end of the file'\n (statements \"a \/* comment to eof\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n it 'lexer'\n tokens = parser: lex 'a (b)'\n (tokens) should contain fields [\n ['identifier'. 'a']\n ['(']\n ['identifier'. 'b']\n [')']\n ['eof']\n ]\n","old_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparser = require '.\/parser.pogo'\nrequire '.\/parserAssertions.pogo'\n\nspec 'parser'\n spec 'terminals'\n spec 'integer'\n (expression '5') should contain fields {\n integer 5\n }\n\n spec 'float'\n (expression '5.6') should contain fields {\n float 5.6\n }\n\n spec 'variables'\n spec 'simple'\n (expression 'total weight') should contain fields {\n variable ['total'. 'weight']\n }\n\n spec 'can use $ as a variable'\n (expression '$') should contain fields {\n variable ['$']\n }\n \n spec 'strings'\n spec 'simple string'\n (expression '''a string''') should contain fields {\n is string\n string 'a string'\n }\n \n spec 'string with single quotes'\n (expression '''''''alright!'''' he said''') should contain fields {\n is string\n string '''alright!'' he said'\n }\n \n spec 'string with backslash'\n (expression \"'one \\\\ two'\") should contain fields {\n is string\n string \"one \\\\ two\"\n }\n \n spec 'multiline string'\n (expression \" 'one\\n two'\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n spec 'multiline double-quote string'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n is string\n string \"one\\ntwo\"\n }\n \n spec 'two multiline string in function'\n (expression \"x 'one\\n two' y \\\"three\\n four\\\"\") should contain fields {\n is function call\n function {variable ['x'. 'y']}\n arguments [\n {string \"one\\ntwo\"}\n {string \"three\\nfour\"}\n ]\n }\n\n spec 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n spec 'empty'\n (expression '\"\"') should contain fields {\n is string\n string ''\n }\n\n spec 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n string \"one\\ntwo\"\n }\n\n spec 'with newline escape and indentation should not remove indentation'\n (expression ' \"one\\n two\"') should contain fields {\n string \"one\\n two\"\n }\n\n spec 'with indentation'\n (expression \" \\\"one\\n two\\\"\") should contain fields {\n string \"one\\ntwo\"\n }\n\n spec 'with single variable expression'\n (expression '\"a boat #(boat length) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['boat'. 'length']}\n {string ' meters in length'}\n ]\n }\n\n spec 'with escaped #'\n (expression '\"a boat \\#(boat length) meters in length\"') should contain fields {\n is string\n string 'a boat #(boat length) meters in length'\n }\n\n spec 'with complex expression'\n (expression '\"a boat #(lookup boat length from (boat database)) meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n function {variable ['lookup'. 'boat'. 'length'. 'from']}\n arguments [{variable ['boat'. 'database']}]\n }\n {string ' meters in length'}\n ]\n }\n \n spec 'in block'\n (expression \"abc =\\n \\\"\\#(stuff)\\\"\") should contain fields {\n is definition\n target {\n is variable\n variable ['abc']\n }\n source {\n is scope\n statements [{\n is variable\n variable ['stuff']\n }]\n }\n }\n\n spec 'with inner interpolation'\n (expression '\"a boat #(\"#(boat length) meters\") in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {\n is interpolated string\n components [\n {variable ['boat'. 'length']}\n {string ' meters'}\n ]\n }\n {string ' in length'}\n ]\n }\n\n spec 'sub expressions'\n spec 'single expression'\n (expression '(x)') should contain fields {variable ['x']}\n\n spec 'two expressions'\n (expression '(x. y)') should contain fields {\n is scope\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n \n spec 'lists'\n spec 'empty'\n (expression '[]') should contain fields {\n is list\n items []\n }\n \n spec 'one item'\n (expression '[1]') should contain fields {\n is list\n items [{integer 1}]\n }\n \n spec 'two items'\n (expression '[1, 2]') should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n spec 'two items separated by newlines'\n (expression \"[\\n 1\\n 2\\n]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n spec 'two items separated by dots'\n (expression \"[1. 2]\") should contain fields {\n is list\n items [\n {integer 1}\n {integer 2}\n ]\n }\n \n spec 'hashes'\n spec 'empty hash'\n (expression '{}') should contain fields {\n is hash\n entries []\n }\n \n spec 'hash with one entry'\n (expression '{port 1234}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n spec 'hash with two entries'\n (expression '{port 1234, ip address ''1.1.1.1''}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n {\n field ['ip'. 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n spec 'hash with two entries on different lines'\n (expression \"{port = 1234\\nip address = '1.1.1.1'}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['ip'. 'address']\n value {string '1.1.1.1'}\n }\n ]\n }\n \n spec 'hash with string with assignment'\n (expression \"{'port' = 1234}\") should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n }\n ]\n }\n \n spec 'values can be specified on a new line'\n (expression \"{\n height =\n 80\n }\") should contain fields {\n is hash\n entries [\n {\n field ['height']\n value {\n is scope\n statements [{integer 80}]\n }\n }\n ]\n }\n \n spec 'should allow methods to be defined, redefining self'\n (expression '{say hi to (name); greeting = print (name)}') should contain fields {\n is hash\n entries [\n {\n field ['say'. 'hi'. 'to']\n value {\n is block\n redefines self\n\n body {\n statements [{\n is function call\n\n function {variable ['print']}\n }]\n }\n\n parameters [{variable ['name']}]\n\n optional parameters [{\n is hash entry\n field ['greeting']\n }]\n }\n }\n ]\n }\n \n spec 'hash with true entry'\n (expression '{port 1234. readonly}') should contain fields {\n is hash\n entries [\n {\n field ['port']\n value {integer 1234}\n } \n {\n field ['readonly']\n value (undefined)\n }\n ]\n }\n\n spec 'function calls'\n spec 'function call'\n (expression 'touch (file)') should contain fields {\n function {variable ['touch']}\n arguments [{variable ['file']}]\n }\n\n spec 'function call with splat argument'\n (expression 'touch (files) ...') should contain fields {\n function {variable ['touch']}\n arguments [\n {variable ['files']}\n {is splat}\n ]\n }\n\n spec 'function call with no argument'\n (expression 'delete everything!') should contain fields {\n function {variable ['delete'. 'everything']}\n arguments []\n }\n\n spec 'function call with no argument using empty parens'\n (expression 'delete everything ()') should contain fields {\n function {variable ['delete'. 'everything']}\n arguments []\n }\n\n spec 'function call with block with parameters'\n (expression \"with file (file) @(stream)\\n stream\") should contain fields {\n function {variable ['with'. 'file']}\n arguments [\n {variable ['file']}\n {\n body {statements [{variable ['stream']}]}\n parameters [{variable ['stream']}]\n }\n ]\n }\n\n spec 'function call with block with long parameters'\n (expression \"open database @(database connection)\\n database connection\") should contain fields {\n function {variable ['open'. 'database']}\n arguments [\n {\n parameters [\n {variable ['database'. 'connection']}\n ]\n body {statements [{variable ['database'. 'connection']}]}\n }\n ]\n }\n\n spec 'function call with two blocks with parameters'\n (expression 'name @(x) @{x} @ (y) @ {y}') should contain fields {\n function {variable ['name']}\n arguments [\n {\n body {statements [{variable ['x']}]}\n parameters [{variable ['x']}]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{variable ['y']}]\n }\n ]\n }\n\n spec 'function call with two optional arguments'\n (expression 'name (a); port 34; server (s)') should contain fields {\n function {variable ['name']}\n arguments [\n {variable ['a']}\n ]\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n {\n field ['server']\n value {variable ['s']}\n }\n ]\n }\n\n spec 'function call with no arguments and one optional argument'\n (expression 'start server; port 34') should contain fields {\n function {variable ['start'. 'server']}\n arguments []\n optional arguments [\n {\n field ['port']\n value {integer 34}\n }\n ]\n }\n \n spec 'object operations'\n spec 'method call'\n (expression 'object: method (argument)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n arguments [{variable ['argument']}]\n }\n \n spec 'method call with optional arguments'\n (expression 'object: method (argument); view (view)') should contain fields {\n is method call\n object {variable ['object']}\n name ['method']\n arguments [{variable ['argument']}]\n optional arguments [\n {field ['view']. value {variable ['view']}}\n ]\n }\n \n spec 'field reference'\n (expression 'object: field') should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n spec 'field reference with newline'\n (expression \"object:\\nfield\") should contain fields {\n is field reference\n object {variable ['object']}\n name ['field']\n }\n \n spec 'self field reference'\n (expression ':field') should contain fields {\n is field reference\n object {variable ['self']}\n name ['field']\n }\n \n spec 'indexer'\n (expression 'object: (x)') should contain fields {\n is indexer\n object {variable ['object']}\n indexer {variable ['x']}\n }\n\n spec 'blocks'\n spec 'empty block'\n (expression '@{}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements []}\n }\n \n spec 'block'\n (expression '@{x.y}') should contain fields {\n is block\n parameters []\n redefines self (false)\n body {statements [\n {variable ['x']}\n {variable ['y']}\n ]}\n }\n\n spec 'block with parameter'\n (expression \"@(x)\\n x.y\") should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (false)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n \n spec 'block in parens'\n (expression \"(one\\n two\\n)\") should contain fields {\n is function call\n function {variable ['one']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['two']}\n ]\n }\n }\n ]\n }\n\n spec 'block with parameter, redefining self'\n (expression '@(x) => @{x.y}') should contain fields {\n is block\n parameters [{variable ['x']}]\n redefines self (true)\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n spec 'operators'\n spec 'should be lower precedence than object operation'\n (expression 'o:m 2 +- o:x') should contain fields {\n is method call\n object {\n is method call\n object {variable ['o']}\n name ['m']\n arguments [{integer 2}]\n }\n \n name ['+-']\n arguments [\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n ]\n }\n \n spec 'parses backslash'\n (expression \"2 +\\\\+ 1\") should contain fields {\n is method call\n object {integer 2}\n \n name [\"+\\\\+\"]\n arguments [\n {integer 1}\n ]\n }\n \n spec 'unary operators should be higher precedence than binary operators'\n (expression 'a && ! b') should contain fields {\n is operator\n operator '&&'\n \n arguments [\n {variable ['a']}\n {\n is operator\n operator '!'\n arguments [{variable ['b']}]\n }\n ]\n }\n \n spec 'can have newlines immediately after operator'\n (expression \"a &&\\nb\") should contain fields {\n is operator\n operator '&&'\n \n arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n spec 'assignment'\n spec 'assignment'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n spec 'function definition'\n spec 'function with one parameter'\n (expression 'func (x) = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n\n spec 'function with one parameter, and one optional parameter'\n (expression 'func (x); port 80 = x') should contain fields {\n is definition\n target {variable ['func']}\n source {\n parameters [{variable ['x']}]\n optional parameters [{field ['port']. value {integer 80}}]\n body {statements [{variable ['x']}]}\n }\n }\n\n spec 'field assignment'\n (expression 'o: x = y') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['o']}\n name ['x']\n }\n\n source {variable ['y']}\n }\n\n spec 'index assignment'\n (expression 'o: (x) = y') should contain fields {\n is definition\n target {\n is indexer\n object {variable ['o']}\n indexer {variable ['x']}\n }\n\n source {variable ['y']}\n }\n\n spec 'assignment from field'\n (expression 'x = y: z') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is field reference\n object {\n variable ['y']\n }\n\n name ['z']\n }\n }\n\n spec 'assignment of command'\n (expression 'x! = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n spec 'definition of function with no arguments, using empty parens \"()\"'\n (expression 'x () = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n spec 'assignment of query'\n (expression 'x? = 8') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is block\n parameters []\n body {\n statements [{integer 8}]\n }\n }\n }\n\n spec 'assignment from method call'\n (expression 'x = y: z (a)') should contain fields {\n is definition\n target {variable ['x']}\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n arguments [{variable ['a']}]\n }\n }\n\n spec 'field assignment from method call'\n (expression 'i: x = y: z (a)') should contain fields {\n is definition\n target {\n is field reference\n object {variable ['i']}\n name ['x']\n }\n\n source {\n is method call\n object {\n variable ['y']\n }\n\n name ['z']\n arguments [{variable ['a']}]\n }\n }\n \n spec 'regexps'\n spec 'simple'\n (expression '`abc`') should contain fields {\n is reg exp\n pattern 'abc'\n }\n\n spec 'with options'\n (expression '`abc`img') should contain fields {\n is reg exp\n pattern 'abc'\n options 'img'\n }\n\n spec 'with escaped back ticks'\n (expression '`abc\\`def\\`ghi`') should contain fields {\n is reg exp\n pattern 'abc`def`ghi'\n }\n\n spec 'with newline'\n (expression \"a = `abc\\n def`\") should contain fields {\n is definition\n target {\n is variable\n variable ['a']\n }\n source {\n is reg exp\n pattern \"abc\\\\ndef\"\n }\n }\n \n spec 'comments'\n spec 'should not treat comment-like syntax as comments in strings'\n (statements \"get 'http:\/\/pogoscript.org\/'\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['get']}\n arguments [\n {string 'http:\/\/pogoscript.org\/'}\n ]\n }]\n }\n \n spec 'should allow one-line C++ style comments, as in: \/\/ this is a comment'\n spec 'when at the end of a line'\n (statements \"a \/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n spec 'when before an indented block'\n (statements \"a \/\/ this is a comment\\n b\") should contain fields {\n is statements\n statements [{\n is function call\n function {variable ['a']}\n arguments [{\n is block\n body {\n statements [\n {variable ['b']}\n ]\n }\n }]\n }]\n }\n\n spec 'when at end of file'\n (statements \"a \/\/ this is a comment\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n ]\n }\n\n spec 'when between lines'\n (statements \"a\\n\/\/ this is a comment\\nb\") should contain fields {\n is statements\n statements [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n\n spec 'should allow multi-line C style comments, as in: \/* this is a comment *\/'\n spec 'when on one line'\n (statements \"a \/* comment *\/ b\") should contain fields {\n statements [\n {variable ['a'. 'b']}\n ]\n }\n\n spec 'when there are two'\n (statements \"a \/* comment *\/ b \/* another comment *\/ c\") should contain fields {\n statements [\n {variable ['a'. 'b'. 'c']}\n ]\n }\n\n spec 'when between lines'\n (statements \"a\\n\/* comment *\/\\nb\\n\/* another comment *\/\\nc\") should contain fields {\n statements [\n {variable ['a']}\n {variable ['b']}\n {variable ['c']}\n ]\n }\n\n spec 'when it contains a * character'\n (statements \"a \/* sh*t *\/ b\") should contain fields {\n statements [\n {variable ['a'. 'b']}\n ]\n }\n\n spec 'when it covers two lines'\n (statements \"a \/* line one\\nline two *\/ b\") should contain fields {\n statements [{\n is variable\n variable ['a'. 'b']\n }]\n }\n\n spec 'when it extends to the end of the file'\n (statements \"a \/* comment to eof\") should contain fields {\n statements [\n {variable ['a']}\n ]\n }\n\n spec 'lexer'\n tokens = parser: lex 'a (b)'\n (tokens) should contain fields [\n ['identifier'. 'a']\n ['(']\n ['identifier'. 'b']\n [')']\n ['eof']\n ]\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"23c8d99d837140f41e6776b4a4a5d687e1eba855","subject":"removed logging from tests","message":"removed logging from tests\n","repos":"featurist\/httpism","old_file":"test\/httpismSpec.pogo","new_file":"test\/httpismSpec.pogo","new_contents":"httpism = require '..\/index'\nexpress = require 'express'\nbodyParser = require 'body-parser'\nshould = require 'chai'.should()\nassert = require 'chai'.assert\nhttps = require 'https'\nfs = require 'fs'\nqs = require 'qs'\nmiddleware = require '..\/middleware'\nbasicAuth = require 'basic-auth-connect'\n\ndescribe 'httpism'\n server = nil\n app = nil\n port = 12345\n baseurl = \"http:\/\/localhost:#(port)\"\n\n beforeEach\n app := express()\n server := app.listen (port)\n\n afterEach\n server.close()\n\n describe 'json'\n beforeEach\n app.use(bodyParser.json())\n\n itCanMake (method) requests =\n it \"can make #(method) requests\"\n app.(method.toLowerCase()) '\/' @(req, res)\n res.send {method = req.method, path = req.path, accept = req.headers.accept}\n\n response = httpism.(method.toLowerCase()) (baseurl)!\n response.body.should.eql {method = method, path = '\/', accept = 'application\/json'}\n\n it \"can make HEAD requests\"\n app.head '\/' @(req, res)\n res.header 'x-method' (req.method)\n res.header 'x-path' (req.path)\n res.end()\n\n response = httpism.head (baseurl)!\n response.headers.'x-method'.should.equal 'HEAD'\n response.headers.'x-path'.should.equal '\/'\n\n itCanMake (method) requestsWithBody =\n it \"can make #(method) requests with body\"\n app.(method.toLowerCase()) '\/' @(req, res)\n res.send {method = req.method, path = req.path, accept = req.headers.accept, body = req.body}\n\n response = httpism.(method.toLowerCase()) (baseurl, { joke = 'a chicken...' })!\n response.body.should.eql {method = method, path = '\/', accept = 'application\/json', body = { joke = 'a chicken...' }}\n\n itCanMake 'GET' requests\n itCanMake 'DELETE' requests\n itCanMake 'POST' requestsWithBody\n itCanMake 'PUT' requestsWithBody\n itCanMake 'PATCH' requestsWithBody\n itCanMake 'OPTIONS' requestsWithBody\n\n describe 'content type request header'\n beforeEach\n app.post '\/' @(req, res)\n res.header 'received-content-type' (req.headers.'content-type')\n res.header 'content-type' 'text\/plain'\n req.pipe(res)\n\n it 'can upload JSON as application\/custom'\n response = httpism.post (baseurl) { json = 'json' } (headers: { 'content-type' = 'application\/custom' })!\n JSON.parse (response.body).should.eql { json = 'json' }\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n it 'can upload form as application\/custom'\n response = httpism.post (baseurl) { json = 'json' } (form: true, headers: { 'content-type' = 'application\/custom' })!\n qs.parse (response.body).should.eql { json = 'json' }\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n it 'can upload string as application\/custom'\n response = httpism.post (baseurl) 'a string' (headers: { 'content-type' = 'application\/custom' })!\n response.body.should.eql 'a string'\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n describe 'content-length header'\n unicodeText = '\u266b\u266b\u266b\u266b\u266a \u263a'\n\n beforeEach\n app.post '\/' @(req, res)\n res.send {\n 'content-length' = req.headers.'content-length'\n 'transfer-encoding' = req.headers.'transfer-encoding'\n }\n\n\n it 'sends content-length, and not transfer-encoding: chunked, with JSON'\n response = httpism.post (baseurl) { json = unicodeText }!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(JSON.stringify { json = unicodeText }).toString()\n }\n\n it 'sends content-length, and not transfer-encoding: chunked, with plain text'\n response = httpism.post (baseurl, unicodeText)!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(unicodeText).toString()\n }\n\n it 'sends content-length, and not transfer-encoding: chunked, with form data'\n response = httpism.post (baseurl, { formData = unicodeText }, form: true)!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(qs.stringify { formData = unicodeText }).toString()\n }\n\n describe 'accept request header'\n beforeEach\n app.get '\/' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.send (req.headers.accept)\n\n it 'sends Accept: application\/json by default'\n response = httpism.get (baseurl)!\n response.body.should.eql 'application\/json'\n\n it 'can send a custom Accept header'\n response = httpism.get (baseurl, headers: {accept = 'application\/custom'})!\n response.body.should.eql 'application\/custom'\n\n describe 'request headers'\n it 'can specify headers for the request'\n app.get '\/' @(req, res)\n res.send {'x-header' = req.headers.'x-header'}\n\n response = httpism.get (baseurl, headers: {'x-header' = 'haha'})!\n response.body.'x-header'.should.equal 'haha'\n\n describe 'text'\n itReturnsAStringForContentType (mimeType) =\n it \"returns a string if the content-type is #(mimeType)\"\n app.get '\/' @(req, res)\n res.header 'content-type' (mimeType)\n res.send 'content as string'\n\n response = httpism.get (baseurl)!\n response.body.should.equal 'content as string'\n\n itReturnsAStringForContentType 'text\/plain'\n itReturnsAStringForContentType 'text\/html'\n itReturnsAStringForContentType 'text\/css'\n itReturnsAStringForContentType 'text\/javascript'\n itReturnsAStringForContentType 'application\/javascript'\n\n it 'will upload a string as text\/plain'\n app.post '\/text' @(req, res)\n res.header 'received-content-type' (req.headers.'content-type')\n res.header 'content-type' 'text\/plain'\n req.pipe(res)\n\n response = httpism.post \"#(baseurl)\/text\" 'content as string'!\n response.headers.'received-content-type'.should.equal 'text\/plain'\n response.body.should.equal 'content as string'\n\n describe 'query strings'\n beforeEach\n app.get '\/' @(req, res)\n res.send(req.query)\n\n it 'can set query string'\n response = httpism.get (baseurl, querystring = {a = 'a', b = 'b'})!\n response.body.should.eql {a = 'a', b = 'b'}\n\n it 'can override query string in url'\n response = httpism.get (\"#(baseurl)\/?a=a&c=c\", querystring: {a = 'newa', b = 'b'})!\n response.body.should.eql {a = 'newa', b = 'b', c = 'c'}\n\n describe 'apis'\n it 'can make a new client that adds headers'\n app.get '\/' @(req, res)\n res.send {joke = req.headers.joke}\n\n client = httpism.api @(request, next)\n request.headers.joke = 'a chicken...'\n next (request)!\n\n response = client.get (baseurl)!\n\n response.body.should.eql {joke = 'a chicken...'}\n\n describe 'exceptions'\n beforeEach\n app.get '\/400' @(req, res)\n res.status 400.send {message = 'oh dear'}\n\n it 'throws exceptions on 400-500 status codes, by default'\n try\n httpism.api (baseurl).get '\/400'!\n assert.fail 'expected an exception to be thrown'\n catch (e)\n e.message.should.equal \"GET #(baseurl)\/400 => 400 Bad Request\"\n e.statusCode.should.equal 400\n e.body.message.should.equal 'oh dear'\n\n it \"doesn't throw exceptions on 400-500 status codes, when specified\"\n response = httpism.api (baseurl).get ('\/400', exceptions: false)!\n response.body.message.should.equal 'oh dear'\n\n describe 'options'\n client = nil\n beforeEach\n client := httpism.api @(request, next)\n request.body = request.options\n next (request)!\n (a: 'a')\n\n app.post '\/' @(req, res)\n res.send (req.body)\n\n it 'clients have options, which can be overwritten on each request'\n root = client.api (baseurl)\n response = root.post '' (nil, b: 'b')!\n response.body.should.eql {a = 'a', b = 'b'}\n response.post '' (nil, c: 'c')!.body.should.eql {a = 'a', c = 'c'}\n root.post '' (nil)!.body.should.eql {a = 'a'}\n\n describe 'responses act as clients'\n path = nil\n\n beforeEach\n pathResponse (req, res) =\n res.send {path = req.path}\n\n app.get '\/' (pathResponse)\n app.get '\/rootfile' (pathResponse)\n app.get '\/path\/' (pathResponse)\n app.get '\/path\/file' (pathResponse)\n\n api = httpism.api (baseurl)\n path := api.get '\/path\/'!\n\n it 'resources respond with their url'\n path.url.should.equal \"#(baseurl)\/path\/\"\n path.body.path.should.equal '\/path\/'\n\n it \"addresses original resource if url is ''\"\n path.get ''!.body.path.should.equal '\/path\/'\n\n it 'makes relative sub path'\n path.get 'file'!.body.path.should.equal '\/path\/file'\n\n it 'addresses root'\n path.get '\/'!.body.path.should.equal '\/'\n\n it 'can address ..\/ paths'\n path.get '..\/rootfile'!.body.path.should.equal '\/rootfile'\n\n it 'can create new apis from relative paths'\n path.api 'file'.get ''!.body.path.should.equal '\/path\/file'\n\n describe 'redirects'\n beforeEach\n app.get '\/redirecttoredirect' @(req, res)\n res.redirect '\/redirect'\n\n app.get '\/redirect' @(req, res)\n res.location '\/path\/'\n res.status 302.send {path = req.path}\n\n app.get '\/' @(req, res)\n res.send {path = req.path}\n\n app.get '\/path\/' @(req, res)\n res.send {path = req.path}\n\n app.get '\/path\/file' @(req, res)\n res.send {path = req.path}\n\n it 'follows redirects by default'\n response = httpism.get \"#(baseurl)\/redirect\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n itFollows (statusCode) redirects =\n it \"follows #(statusCode) redirects\"\n app.get \"\/#(statusCode)\" @(req, res)\n res.location '\/path\/'\n res.status (statusCode).send()\n\n response = httpism.get \"#(baseurl)\/#(statusCode)\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n describe 'redirects'\n itFollows 300 redirects\n itFollows 301 redirects\n itFollows 302 redirects\n itFollows 303 redirects\n itFollows 307 redirects\n\n it 'paths are relative to destination resource'\n response = httpism.get \"#(baseurl)\/redirect\"!\n response.get 'file'!.body.path.should.equal '\/path\/file'\n\n it 'follows a more than one redirect'\n response = httpism.get \"#(baseurl)\/redirecttoredirect\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n it \"doesn't follow redirects when specified\"\n response = httpism.get \"#(baseurl)\/redirect\" (redirect: false)!\n response.body.should.eql {path = '\/redirect'}\n response.url.should.eql \"#(baseurl)\/redirect\"\n response.headers.location.should.equal '\/path\/'\n response.statusCode.should.equal 302\n\n describe 'https'\n httpsServer = nil\n httpsPort = 23456\n httpsBaseurl = \"https:\/\/localhost:#(httpsPort)\/\"\n\n beforeEach\n credentials = {\n key = fs.readFileSync \"#(__dirname)\/server.key\" 'utf-8'\n cert = fs.readFileSync \"#(__dirname)\/server.crt\" 'utf-8'\n }\n\n httpsServer := https.createServer (credentials, app)\n httpsServer.listen (httpsPort)\n\n afterEach\n httpsServer.close()\n\n it 'can make HTTPS requests' =>\n app.get '\/' @(req, res)\n res.send { protocol = req.protocol }\n\n httpism.get (httpsBaseurl, https: {rejectUnauthorized = false})!.body.protocol.should.equal 'https'\n\n describe 'forms'\n it 'can upload application\/x-www-form-urlencoded'\n app.post '\/form' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.header 'received-content-type' (req.headers.'content-type')\n req.pipe(res)\n\n response = httpism.post \"#(baseurl)\/form\" {name = 'Betty Boo', address = 'one & two'} (form: true)!\n response.body.should.equal 'name=Betty%20Boo&address=one%20%26%20two'\n response.headers.'received-content-type'.should.equal 'application\/x-www-form-urlencoded'\n\n it 'can download application\/x-www-form-urlencoded'\n app.get '\/form' @(req, res)\n res.header 'content-type' 'application\/x-www-form-urlencoded'\n res.send (qs.stringify {name = 'Betty Boo', address = 'one & two'})\n\n response = httpism.get \"#(baseurl)\/form\"!\n response.body.should.eql {name = 'Betty Boo', address = 'one & two'}\n response.headers.'content-type'.should.equal 'application\/x-www-form-urlencoded; charset=utf-8'\n\n describe 'basic authentication'\n beforeEach\n app.use(basicAuth @(user, pass)\n user == 'good user' @and pass == 'good password!'\n )\n\n app.get '\/secret' @(req, res)\n res.send 'this is secret'\n\n it 'can authenticate using username password'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good user', password = 'good password!'})!.body.should.equal 'this is secret'\n\n it 'can authenticate using username password encoded in URL'\n u = encodeURIComponent\n httpism.get \"http:\/\/#(u 'good user'):#(u 'good password!')@localhost:#(port)\/secret\"!.body.should.equal 'this is secret'\n\n it 'can authenticate using username with colons :'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good: :user', password = 'good password!'})!.body.should.equal 'this is secret'\n\n it 'fails to authenticate when password is incorrect'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good user', password = 'bad password!'}, exceptions: false)!.statusCode.should.equal 401\n\n describe 'streams'\n filename = \"#(__dirname)\/afile.txt\"\n\n beforeEach\n fs.writeFile (filename, 'some content', ^)!\n\n app.post '\/file' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.header 'received-content-type' (req.headers.'content-type')\n req.unshift 'received: '\n req.pipe(res)\n\n app.get '\/file' @(req, res)\n stream = fs.createReadStream (filename)\n res.header 'content-type' 'application\/blah'\n stream.pipe(res)\n\n afterEach\n fs.unlink (filename, ^)!\n\n itCanUploadAStreamWithContentType (contentType) =\n it \"can upload a stream with Content-Type: #(contentType)\"\n stream = fs.createReadStream (filename)\n response = httpism.post \"#(baseurl)\/file\" (stream, headers: {'content-type' = contentType})!\n response.headers.'received-content-type'.should.equal (contentType)\n response.body.should.equal 'received: some content'\n\n itCanUploadAStreamWithContentType 'application\/blah'\n itCanUploadAStreamWithContentType 'application\/json'\n itCanUploadAStreamWithContentType 'text\/plain'\n itCanUploadAStreamWithContentType 'application\/x-www-form-urlencoded'\n\n it 'can download a stream'\n response = httpism.get \"#(baseurl)\/file\"!\n response.headers.'content-type'.should.equal 'application\/blah'\n middleware.stream (response.body) toString!.should.equal 'some content'\n\n describe 'forcing response parsing'\n describeForcing (type) response (contentType: nil, content: nil, sendContent: nil) =\n describe (type)\n it \"can download a stream of content-type #(contentType)\"\n app.get '\/content' @(req, res)\n stream = fs.createReadStream (filename)\n res.header 'content-type' (contentType)\n stream.pipe(res)\n\n response = httpism.get \"#(baseurl)\/content\" (responseBody: 'stream')!\n response.headers.'content-type'.should.equal (contentType)\n middleware.stream (response.body) toString!.should.equal 'some content'\n\n it \"can force parse #(type) when content-type is application\/blah\"\n app.get '\/content' @(req, res)\n res.header 'content-type' 'application\/blah'\n res.send (sendContent @or content)\n\n response = httpism.get \"#(baseurl)\/content\" (responseBody: (type))!\n response.headers.'content-type'.should.equal 'application\/blah; charset=utf-8'\n response.body.should.eql (content)\n\n describeForcing 'text' response (contentType: 'text\/plain; charset=utf-8', content: 'some text content')\n describeForcing 'json' response (contentType: 'application\/json', content: { json = true})\n describeForcing 'form' response (contentType: 'application\/x-www-form-urlencoded', content: { json = \"true\"}, sendContent: qs.stringify { json = \"true\" })\n\n describe 'raw'\n it 'can be used to create new middleware pipelines'\n app.get \"\/\" @(req, res)\n res.status 400.send {blah = 'blah'}\n\n api = httpism.raw.api (baseurl) @(request, next)\n res = next()!\n res.body = middleware.stream (res.body) toString!\n res\n\n response = api.get (baseurl)!\n response.statusCode.should.equal 400\n JSON.parse (response.body).should.eql {blah = 'blah'}\n","old_contents":"httpism = require '..\/index'\nexpress = require 'express'\nbodyParser = require 'body-parser'\nshould = require 'chai'.should()\nassert = require 'chai'.assert\nhttps = require 'https'\nfs = require 'fs'\nqs = require 'qs'\nmiddleware = require '..\/middleware'\nbasicAuth = require 'basic-auth-connect'\n\ndescribe 'httpism'\n server = nil\n app = nil\n port = 12345\n baseurl = \"http:\/\/localhost:#(port)\"\n\n beforeEach\n app := express()\n server := app.listen (port)\n\n afterEach\n server.close()\n\n describe 'json'\n beforeEach\n app.use(bodyParser.json())\n\n itCanMake (method) requests =\n it \"can make #(method) requests\"\n app.(method.toLowerCase()) '\/' @(req, res)\n res.send {method = req.method, path = req.path, accept = req.headers.accept}\n\n response = httpism.(method.toLowerCase()) (baseurl)!\n response.body.should.eql {method = method, path = '\/', accept = 'application\/json'}\n\n it \"can make HEAD requests\"\n app.head '\/' @(req, res)\n res.header 'x-method' (req.method)\n res.header 'x-path' (req.path)\n res.end()\n\n response = httpism.head (baseurl)!\n response.headers.'x-method'.should.equal 'HEAD'\n response.headers.'x-path'.should.equal '\/'\n\n itCanMake (method) requestsWithBody =\n it \"can make #(method) requests with body\"\n app.(method.toLowerCase()) '\/' @(req, res)\n res.send {method = req.method, path = req.path, accept = req.headers.accept, body = req.body}\n\n response = httpism.(method.toLowerCase()) (baseurl, { joke = 'a chicken...' })!\n response.body.should.eql {method = method, path = '\/', accept = 'application\/json', body = { joke = 'a chicken...' }}\n\n itCanMake 'GET' requests\n itCanMake 'DELETE' requests\n itCanMake 'POST' requestsWithBody\n itCanMake 'PUT' requestsWithBody\n itCanMake 'PATCH' requestsWithBody\n itCanMake 'OPTIONS' requestsWithBody\n\n describe 'content type request header'\n beforeEach\n app.post '\/' @(req, res)\n res.header 'received-content-type' (req.headers.'content-type')\n res.header 'content-type' 'text\/plain'\n req.pipe(res)\n\n it 'can upload JSON as application\/custom'\n response = httpism.post (baseurl) { json = 'json' } (headers: { 'content-type' = 'application\/custom' })!\n JSON.parse (response.body).should.eql { json = 'json' }\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n it 'can upload form as application\/custom'\n response = httpism.post (baseurl) { json = 'json' } (form: true, headers: { 'content-type' = 'application\/custom' })!\n qs.parse (response.body).should.eql { json = 'json' }\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n it 'can upload string as application\/custom'\n response = httpism.post (baseurl) 'a string' (headers: { 'content-type' = 'application\/custom' })!\n response.body.should.eql 'a string'\n response.headers.'received-content-type'.should.eql 'application\/custom'\n\n describe 'content-length header'\n unicodeText = '\u266b\u266b\u266b\u266b\u266a \u263a'\n\n beforeEach\n app.post '\/' @(req, res)\n res.send {\n 'content-length' = req.headers.'content-length'\n 'transfer-encoding' = req.headers.'transfer-encoding'\n }\n\n\n it 'sends content-length, and not transfer-encoding: chunked, with JSON'\n response = httpism.post (baseurl) { json = unicodeText }!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(JSON.stringify { json = unicodeText }).toString()\n }\n\n it 'sends content-length, and not transfer-encoding: chunked, with plain text'\n response = httpism.post (baseurl, unicodeText)!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(unicodeText).toString()\n }\n\n it 'sends content-length, and not transfer-encoding: chunked, with form data'\n response = httpism.post (baseurl, { formData = unicodeText }, form: true)!\n response.body.should.eql {\n 'content-length' = Buffer.byteLength(qs.stringify { formData = unicodeText }).toString()\n }\n\n describe 'accept request header'\n beforeEach\n app.get '\/' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.send (req.headers.accept)\n\n it 'sends Accept: application\/json by default'\n response = httpism.get (baseurl)!\n response.body.should.eql 'application\/json'\n\n it 'can send a custom Accept header'\n response = httpism.get (baseurl, headers: {accept = 'application\/custom'})!\n response.body.should.eql 'application\/custom'\n\n describe 'request headers'\n it 'can specify headers for the request'\n app.get '\/' @(req, res)\n res.send {'x-header' = req.headers.'x-header'}\n\n response = httpism.get (baseurl, headers: {'x-header' = 'haha'})!\n response.body.'x-header'.should.equal 'haha'\n\n describe 'text'\n itReturnsAStringForContentType (mimeType) =\n it \"returns a string if the content-type is #(mimeType)\"\n app.get '\/' @(req, res)\n res.header 'content-type' (mimeType)\n res.send 'content as string'\n\n response = httpism.get (baseurl)!\n response.body.should.equal 'content as string'\n\n itReturnsAStringForContentType 'text\/plain'\n itReturnsAStringForContentType 'text\/html'\n itReturnsAStringForContentType 'text\/css'\n itReturnsAStringForContentType 'text\/javascript'\n itReturnsAStringForContentType 'application\/javascript'\n\n it 'will upload a string as text\/plain'\n app.post '\/text' @(req, res)\n res.header 'received-content-type' (req.headers.'content-type')\n res.header 'content-type' 'text\/plain'\n req.pipe(res)\n\n response = httpism.post \"#(baseurl)\/text\" 'content as string'!\n response.headers.'received-content-type'.should.equal 'text\/plain'\n response.body.should.equal 'content as string'\n\n describe 'query strings'\n beforeEach\n app.get '\/' @(req, res)\n res.send(req.query)\n\n it 'can set query string'\n response = httpism.get (baseurl, querystring = {a = 'a', b = 'b'}, log = true)!\n response.body.should.eql {a = 'a', b = 'b'}\n\n it 'can override query string in url'\n response = httpism.get (\"#(baseurl)\/?a=a&c=c\", querystring: {a = 'newa', b = 'b'})!\n response.body.should.eql {a = 'newa', b = 'b', c = 'c'}\n\n describe 'apis'\n it 'can make a new client that adds headers'\n app.get '\/' @(req, res)\n res.send {joke = req.headers.joke}\n\n client = httpism.api @(request, next)\n request.headers.joke = 'a chicken...'\n next (request)!\n\n response = client.get (baseurl)!\n\n response.body.should.eql {joke = 'a chicken...'}\n\n describe 'exceptions'\n beforeEach\n app.get '\/400' @(req, res)\n res.status 400.send {message = 'oh dear'}\n\n it 'throws exceptions on 400-500 status codes, by default'\n try\n httpism.api (baseurl).get '\/400'!\n assert.fail 'expected an exception to be thrown'\n catch (e)\n e.message.should.equal \"GET #(baseurl)\/400 => 400 Bad Request\"\n e.statusCode.should.equal 400\n e.body.message.should.equal 'oh dear'\n\n it \"doesn't throw exceptions on 400-500 status codes, when specified\"\n response = httpism.api (baseurl).get ('\/400', exceptions: false)!\n response.body.message.should.equal 'oh dear'\n\n describe 'options'\n client = nil\n beforeEach\n client := httpism.api @(request, next)\n request.body = request.options\n next (request)!\n (a: 'a')\n\n app.post '\/' @(req, res)\n res.send (req.body)\n\n it 'clients have options, which can be overwritten on each request'\n root = client.api (baseurl)\n response = root.post '' (nil, b: 'b')!\n response.body.should.eql {a = 'a', b = 'b'}\n response.post '' (nil, c: 'c')!.body.should.eql {a = 'a', c = 'c'}\n root.post '' (nil)!.body.should.eql {a = 'a'}\n\n describe 'responses act as clients'\n path = nil\n\n beforeEach\n pathResponse (req, res) =\n res.send {path = req.path}\n\n app.get '\/' (pathResponse)\n app.get '\/rootfile' (pathResponse)\n app.get '\/path\/' (pathResponse)\n app.get '\/path\/file' (pathResponse)\n\n api = httpism.api (baseurl)\n path := api.get '\/path\/'!\n\n it 'resources respond with their url'\n path.url.should.equal \"#(baseurl)\/path\/\"\n path.body.path.should.equal '\/path\/'\n\n it \"addresses original resource if url is ''\"\n path.get ''!.body.path.should.equal '\/path\/'\n\n it 'makes relative sub path'\n path.get 'file'!.body.path.should.equal '\/path\/file'\n\n it 'addresses root'\n path.get '\/'!.body.path.should.equal '\/'\n\n it 'can address ..\/ paths'\n path.get '..\/rootfile'!.body.path.should.equal '\/rootfile'\n\n it 'can create new apis from relative paths'\n path.api 'file'.get ''!.body.path.should.equal '\/path\/file'\n\n describe 'redirects'\n beforeEach\n app.get '\/redirecttoredirect' @(req, res)\n res.redirect '\/redirect'\n\n app.get '\/redirect' @(req, res)\n res.location '\/path\/'\n res.status 302.send {path = req.path}\n\n app.get '\/' @(req, res)\n res.send {path = req.path}\n\n app.get '\/path\/' @(req, res)\n res.send {path = req.path}\n\n app.get '\/path\/file' @(req, res)\n res.send {path = req.path}\n\n it 'follows redirects by default'\n response = httpism.get \"#(baseurl)\/redirect\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n itFollows (statusCode) redirects =\n it \"follows #(statusCode) redirects\"\n app.get \"\/#(statusCode)\" @(req, res)\n res.location '\/path\/'\n res.status (statusCode).send()\n\n response = httpism.get \"#(baseurl)\/#(statusCode)\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n describe 'redirects'\n itFollows 300 redirects\n itFollows 301 redirects\n itFollows 302 redirects\n itFollows 303 redirects\n itFollows 307 redirects\n\n it 'paths are relative to destination resource'\n response = httpism.get \"#(baseurl)\/redirect\"!\n response.get 'file'!.body.path.should.equal '\/path\/file'\n\n it 'follows a more than one redirect'\n response = httpism.get \"#(baseurl)\/redirecttoredirect\"!\n response.body.should.eql {path = '\/path\/'}\n response.url.should.eql \"#(baseurl)\/path\/\"\n\n it \"doesn't follow redirects when specified\"\n response = httpism.get \"#(baseurl)\/redirect\" (redirect: false)!\n response.body.should.eql {path = '\/redirect'}\n response.url.should.eql \"#(baseurl)\/redirect\"\n response.headers.location.should.equal '\/path\/'\n response.statusCode.should.equal 302\n\n describe 'https'\n httpsServer = nil\n httpsPort = 23456\n httpsBaseurl = \"https:\/\/localhost:#(httpsPort)\/\"\n\n beforeEach\n credentials = {\n key = fs.readFileSync \"#(__dirname)\/server.key\" 'utf-8'\n cert = fs.readFileSync \"#(__dirname)\/server.crt\" 'utf-8'\n }\n\n httpsServer := https.createServer (credentials, app)\n httpsServer.listen (httpsPort)\n\n afterEach\n httpsServer.close()\n\n it 'can make HTTPS requests' =>\n app.get '\/' @(req, res)\n res.send { protocol = req.protocol }\n\n httpism.get (httpsBaseurl, https: {rejectUnauthorized = false})!.body.protocol.should.equal 'https'\n\n describe 'forms'\n it 'can upload application\/x-www-form-urlencoded'\n app.post '\/form' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.header 'received-content-type' (req.headers.'content-type')\n req.pipe(res)\n\n response = httpism.post \"#(baseurl)\/form\" {name = 'Betty Boo', address = 'one & two'} (form: true)!\n response.body.should.equal 'name=Betty%20Boo&address=one%20%26%20two'\n response.headers.'received-content-type'.should.equal 'application\/x-www-form-urlencoded'\n\n it 'can download application\/x-www-form-urlencoded'\n app.get '\/form' @(req, res)\n res.header 'content-type' 'application\/x-www-form-urlencoded'\n res.send (qs.stringify {name = 'Betty Boo', address = 'one & two'})\n\n response = httpism.get \"#(baseurl)\/form\"!\n response.body.should.eql {name = 'Betty Boo', address = 'one & two'}\n response.headers.'content-type'.should.equal 'application\/x-www-form-urlencoded; charset=utf-8'\n\n describe 'basic authentication'\n beforeEach\n app.use(basicAuth @(user, pass)\n user == 'good user' @and pass == 'good password!'\n )\n\n app.get '\/secret' @(req, res)\n res.send 'this is secret'\n\n it 'can authenticate using username password'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good user', password = 'good password!'})!.body.should.equal 'this is secret'\n\n it 'can authenticate using username password encoded in URL'\n u = encodeURIComponent\n httpism.get \"http:\/\/#(u 'good user'):#(u 'good password!')@localhost:#(port)\/secret\"!.body.should.equal 'this is secret'\n\n it 'can authenticate using username with colons :'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good: :user', password = 'good password!'})!.body.should.equal 'this is secret'\n\n it 'fails to authenticate when password is incorrect'\n httpism.get \"#(baseurl)\/secret\" (basicAuth: {username = 'good user', password = 'bad password!'}, exceptions: false)!.statusCode.should.equal 401\n\n describe 'streams'\n filename = \"#(__dirname)\/afile.txt\"\n\n beforeEach\n fs.writeFile (filename, 'some content', ^)!\n\n app.post '\/file' @(req, res)\n res.header 'content-type' 'text\/plain'\n res.header 'received-content-type' (req.headers.'content-type')\n req.unshift 'received: '\n req.pipe(res)\n\n app.get '\/file' @(req, res)\n stream = fs.createReadStream (filename)\n res.header 'content-type' 'application\/blah'\n stream.pipe(res)\n\n afterEach\n fs.unlink (filename, ^)!\n\n itCanUploadAStreamWithContentType (contentType) =\n it \"can upload a stream with Content-Type: #(contentType)\"\n stream = fs.createReadStream (filename)\n response = httpism.post \"#(baseurl)\/file\" (stream, headers: {'content-type' = contentType})!\n response.headers.'received-content-type'.should.equal (contentType)\n response.body.should.equal 'received: some content'\n\n itCanUploadAStreamWithContentType 'application\/blah'\n itCanUploadAStreamWithContentType 'application\/json'\n itCanUploadAStreamWithContentType 'text\/plain'\n itCanUploadAStreamWithContentType 'application\/x-www-form-urlencoded'\n\n it 'can download a stream'\n response = httpism.get \"#(baseurl)\/file\"!\n response.headers.'content-type'.should.equal 'application\/blah'\n middleware.stream (response.body) toString!.should.equal 'some content'\n\n describe 'forcing response parsing'\n describeForcing (type) response (contentType: nil, content: nil, sendContent: nil) =\n describe (type)\n it \"can download a stream of content-type #(contentType)\"\n app.get '\/content' @(req, res)\n stream = fs.createReadStream (filename)\n res.header 'content-type' (contentType)\n stream.pipe(res)\n\n response = httpism.get \"#(baseurl)\/content\" (responseBody: 'stream')!\n response.headers.'content-type'.should.equal (contentType)\n middleware.stream (response.body) toString!.should.equal 'some content'\n\n it \"can force parse #(type) when content-type is application\/blah\"\n app.get '\/content' @(req, res)\n res.header 'content-type' 'application\/blah'\n res.send (sendContent @or content)\n\n response = httpism.get \"#(baseurl)\/content\" (responseBody: (type))!\n response.headers.'content-type'.should.equal 'application\/blah; charset=utf-8'\n response.body.should.eql (content)\n\n describeForcing 'text' response (contentType: 'text\/plain; charset=utf-8', content: 'some text content')\n describeForcing 'json' response (contentType: 'application\/json', content: { json = true})\n describeForcing 'form' response (contentType: 'application\/x-www-form-urlencoded', content: { json = \"true\"}, sendContent: qs.stringify { json = \"true\" })\n\n describe 'raw'\n it 'can be used to create new middleware pipelines'\n app.get \"\/\" @(req, res)\n res.status 400.send {blah = 'blah'}\n\n api = httpism.raw.api (baseurl) @(request, next)\n res = next()!\n res.body = middleware.stream (res.body) toString!\n res\n\n response = api.get (baseurl)!\n response.statusCode.should.equal 400\n JSON.parse (response.body).should.eql {blah = 'blah'}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"9c3ed8be278ff476e43f6eb67aa6d1f96c40650d","subject":"preparser specs for new preparser","message":"preparser specs for new preparser\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/preparserSpec.pogo","new_file":"src\/bootstrap\/preparserSpec.pogo","new_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\npreparser = require '.\/preparser.pogo'\n\nspec 'preparser'\n spec 'line parser'\n parse = preparser: new line parser?\n\n spec 'empty line'\n (parse ' ') should contain fields #{is empty, line ' ', is first line}\n\n spec 'first non emtpy line should be first line'\n (parse 'x') should contain fields #{is first line, line 'x'}\n\n spec 'line brackets'\n spec 'starts with square bracket'\n (parse ']') should contain fields #{starts with bracket}\n\n spec 'starts with brace'\n (parse '}') should contain fields #{starts with bracket}\n\n spec 'starts with paren'\n (parse ')') should contain fields #{starts with bracket}\n\n spec 'ends with square bracket'\n (parse '[') should contain fields #{ends with bracket}\n\n spec 'ends with brace'\n (parse '{') should contain fields #{ends with bracket}\n\n spec 'ends with paren'\n (parse '(') should contain fields #{ends with bracket}\n\n spec 'new line'\n (parse 'one') should contain fields #{code 'one', indentation '', is first line, line 'one'}\n\n spec 'and indented line'\n (parse ' two') should contain fields #{code 'two', indentation ' ', is indent, is first line @false, line ' two'}\n\n spec 'and unindented line'\n (parse 'three') should contain fields #{is unindent}\n\n spec 'and unindented line after empty line'\n parse ''\n (parse 'three') should contain fields #{is unindent}\n\n spec 'and line ending in bracket'\n (parse 'two {') should contain fields #{ends with bracket}\n\n spec 'and line ending in bracket'\n (parse '} three') should contain fields #{starts with bracket}\n\n spec 'indent stack'\n indent stack = preparser: new indent stack?\n \n spec 'with indent'\n indent stack: indent to ' '\n\n spec 'it unwinds with one bracket'\n (indent stack: count unindents while unwinding to '') should equal 1\n\n spec 'it unwinds with two brackets'\n indent stack: indent to ' '\n (indent stack: count unindents while unwinding to '') should equal 2\n\n spec 'source parser'\n parse = preparser: new file parser?\n\n spec 'new lines'\n spec 'new lines'\n (parse 'one\\ntwo\\nthree') should equal 'one\\\\.\\ntwo\\\\.\\nthree\\n'\n \n spec 'new lines with empty lines'\n (parse 'one\\n\\ntwo') should equal 'one\\n\\\\.\\ntwo\\n'\n \n spec 'starts with empty line'\n (parse '\\none\\ntwo') should equal '\\none\\\\.\\ntwo\\n'\n \n spec 'indentation'\n spec 'one level'\n (parse 'one\\n two\\n three') should equal 'one\\\\@{\\n two\\\\.\\n three\\\\}\\n'\n \n spec 'one level with empty lines'\n (parse 'one\\n two\\n\\n three') should equal 'one\\\\@{\\n two\\n\\\\.\\n three\\\\}\\n'\n \n spec 'one line indented'\n (parse 'one\\n two\\nthree') should equal 'one\\\\@{\\n two\\\\}\\nthree\\n'\n \n spec 'one line indented followed by another statement'\n (parse 'one\\n two\\n\\nthree') should equal 'one\\\\@{\\n two\\n\\\\}\\\\.\\nthree\\n'\n \n spec 'two levels'\n (parse 'one\\n two\\n three\\n') should equal 'one\\\\@{\\n two\\\\@{\\n three\\n\\\\}\\\\}\\n'\n \n spec 'two levels with following args'\n (parse 'one\\n two\\n three\\nfour') should equal 'one\\\\@{\\n two\\\\@{\\n three\\\\}\\\\}\\nfour\\n'\n\n spec 'indentation with brackets'\n spec 'doesnt insert brace if indent is in brackets'\n (parse 'one{\\n two\\n three\\n}\\nfour') should equal 'one{\\n two\\\\.\\n three\\n}\\\\.\\nfour\\n'\n\n spec 'still unwinds unindent, but not the last one because it has a bracket'\n (parse 'one{\\n two\\n three\\n four\\n}\\nfive') should equal 'one{\\n two\\\\.\\n three\\\\@{\\n four\\\\}\\n}\\\\.\\nfive\\n'\n\n spec 'list with items on each line'\n (parse 'list [\\n1\\n2\\n3\\n]') should equal 'list [\\n1\\\\.\\n2\\\\.\\n3\\n]\\n'\n\n spec 'list with items on each indented line'\n (parse 'list [\\n 1\\n 2\\n 3\\n]') should equal 'list [\\n 1\\\\.\\n 2\\\\.\\n 3\\n]\\n'\n","old_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\npreparser = require '.\/preparser.pogo'\n\nspec 'preparser'\n spec 'line parser'\n parse = preparser: new line parser?\n\n spec 'empty line'\n (parse ' ') should contain fields #{is empty, line ' ', is first line}\n\n spec 'first non emtpy line should be first line'\n (parse 'x') should contain fields #{is first line, line 'x'}\n\n spec 'line brackets'\n spec 'starts with square bracket'\n (parse ']') should contain fields #{starts with bracket}\n\n spec 'starts with brace'\n (parse '}') should contain fields #{starts with bracket}\n\n spec 'starts with paren'\n (parse ')') should contain fields #{starts with bracket}\n\n spec 'ends with square bracket'\n (parse '[') should contain fields #{ends with bracket}\n\n spec 'ends with brace'\n (parse '{') should contain fields #{ends with bracket}\n\n spec 'ends with paren'\n (parse '(') should contain fields #{ends with bracket}\n\n spec 'new line'\n (parse 'one') should contain fields #{code 'one', indentation '', is first line, line 'one'}\n\n spec 'and indented line'\n (parse ' two') should contain fields #{code 'two', indentation ' ', is indent, is first line @false, line ' two'}\n\n spec 'and unindented line'\n (parse 'three') should contain fields #{is unindent}\n\n spec 'and unindented line after empty line'\n parse ''\n (parse 'three') should contain fields #{is unindent}\n\n spec 'and line ending in bracket'\n (parse 'two {') should contain fields #{ends with bracket}\n\n spec 'and line ending in bracket'\n (parse '} three') should contain fields #{starts with bracket}\n\n spec 'indent stack'\n indent stack = preparser: new indent stack?\n \n spec 'with indent'\n indent stack: indent to ' '\n\n spec 'it unwinds with one bracket'\n (indent stack: count unindents while unwinding to '') should equal 1\n\n spec 'it unwinds with two brackets'\n indent stack: indent to ' '\n (indent stack: count unindents while unwinding to '') should equal 2\n\n spec 'source parser'\n parse = preparser: new file parser?\n\n spec 'new lines'\n spec 'new lines'\n (parse 'one\\ntwo\\nthree') should equal 'one \\\\.\\ntwo \\\\.\\nthree\\n'\n \n spec 'new lines with empty lines'\n (parse 'one\\n\\ntwo') should equal 'one\\n \\\\.\\ntwo\\n'\n \n spec 'starts with empty line'\n (parse '\\none\\ntwo') should equal '\\none \\\\.\\ntwo\\n'\n \n spec 'indentation'\n spec 'one level'\n (parse 'one\\n two\\n three') should equal 'one \\\\{\\n two \\\\.\\n three \\\\}\\n'\n \n spec 'one level with empty lines'\n (parse 'one\\n two\\n\\n three') should equal 'one \\\\{\\n two\\n \\\\.\\n three \\\\}\\n'\n \n spec 'one line indented'\n (parse 'one\\n two\\nthree') should equal 'one \\\\{\\n two \\\\}\\nthree\\n'\n \n spec 'one line indented followed by another statement'\n (parse 'one\\n two\\n\\nthree') should equal 'one \\\\{\\n two\\n \\\\}\\\\.\\nthree\\n'\n \n spec 'two levels'\n (parse 'one\\n two\\n three\\n') should equal 'one \\\\{\\n two \\\\{\\n three\\n \\\\}\\\\}\\n'\n \n spec 'two levels with following args'\n (parse 'one\\n two\\n three\\nfour') should equal 'one \\\\{\\n two \\\\{\\n three \\\\}\\\\}\\nfour\\n'\n\n spec 'indentation with brackets'\n spec 'doesnt insert brace if indent is in brackets'\n (parse 'one{\\n two\\n three\\n}\\nfour') should equal 'one{\\n two \\\\.\\n three\\n} \\\\.\\nfour\\n'\n\n spec 'still unwinds unindent, but not the last one because it has a bracket'\n (parse 'one{\\n two\\n three\\n four\\n}\\nfive') should equal 'one{\\n two \\\\.\\n three \\\\{\\n four \\\\}\\n} \\\\.\\nfive\\n'\n\n spec 'list with items on each line'\n (parse 'list [\\n1\\n2\\n3\\n]') should equal 'list [\\n1 \\\\.\\n2 \\\\.\\n3\\n]\\n'\n\n spec 'list with items on each indented line'\n (parse 'list [\\n 1\\n 2\\n 3\\n]') should equal 'list [\\n 1 \\\\.\\n 2 \\\\.\\n 3\\n]\\n'\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"}
{"commit":"e5b73498532a4f7f2b0d84d0ec2e184450d86454","subject":"removed a few @ symbols :)","message":"removed a few @ symbols :)\n","repos":"featurist\/pogo-examples","old_file":"index.pogo","new_file":"index.pogo","new_contents":"fs = require \"fs\"\nasync = require \"async\"\nhandlebars = require \"handlebars\"\nexec = require \"child_process\" : exec\nhighlight = require \"highlight\" : Highlight\n\nhtml = \"\n\n \n Pogo Examples<\/title>\n \n \n <\/head>\n \n
<\/a>\n PogoScript to JavaScript Examples<\/h1>\n \n {{#each examples}}\n - \n
{{this.name}}<\/h2>\n