{"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 Examples<\/title>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"samples.css\\\" \/>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"highlight.css\\\" \/>\n <\/head>\n <body>\n <a href=\\\"https:\/\/github.com\/featurist\/pogo-examples\\\"><img style=\\\"position: absolute; top: 0; right: 0; border: 0;\\\" src=\\\"http:\/\/s3.amazonaws.com\/github\/ribbons\/forkme_right_darkblue_121621.png\\\" alt=\\\"Fork me on GitHub\\\" \/><\/a>\n <h1>PogoScript to JavaScript Examples<\/h1>\n <ul>\n {{#each examples}}\n <li>\n <h2>{{this.name}}<\/h2>\n <div class=\\\"pogo\\\">\n <pre class=\\\"pogo\\\"><code>{{{pogo this}}}<\/code><\/pre>\n <\/div>\n <div class=\\\"javascript\\\">\n <pre class=\\\"javascript\\\"><code>{{{js this}}}<\/code><\/pre>\n <\/div>\n <hr \/>\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<html>\n <head>\n <title>Pogo Examples<\/title>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"samples.css\\\" \/>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"highlight.css\\\" \/>\n <\/head>\n <body>\n <a href=\\\"https:\/\/github.com\/featurist\/pogo-examples\\\"><img style=\\\"position: absolute; top: 0; right: 0; border: 0;\\\" src=\\\"http:\/\/s3.amazonaws.com\/github\/ribbons\/forkme_right_darkblue_121621.png\\\" alt=\\\"Fork me on GitHub\\\" \/><\/a>\n <h1>PogoScript to JavaScript Examples<\/h1>\n <ul>\n {{#each examples}}\n <li>\n <h2>{{this.name}}<\/h2>\n <div class=\\\"pogo\\\">\n <pre class=\\\"pogo\\\"><code>{{{pogo this}}}<\/code><\/pre>\n <\/div>\n <div class=\\\"javascript\\\">\n <pre class=\\\"javascript\\\"><code>{{{js this}}}<\/code><\/pre>\n <\/div>\n <hr \/>\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<html>\n <head>\n <title>Pogo Examples<\/title>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"samples.css\\\" \/>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"highlight.css\\\" \/>\n <\/head>\n <body>\n <a href=\\\"https:\/\/github.com\/featurist\/pogo-examples\\\"><img style=\\\"position: absolute; top: 0; right: 0; border: 0;\\\" src=\\\"http:\/\/s3.amazonaws.com\/github\/ribbons\/forkme_right_darkblue_121621.png\\\" alt=\\\"Fork me on GitHub\\\" \/><\/a>\n <h1>PogoScript to JavaScript Examples<\/h1>\n <ul>\n {{#each examples}}\n <li>\n <h2>{{this.name}}<\/h2>\n <div class=\\\"pogo\\\">\n <pre class=\\\"pogo\\\"><code>{{{pogo this}}}<\/code><\/pre>\n <\/div>\n <div class=\\\"javascript\\\">\n <pre class=\\\"javascript\\\"><code>{{{js this}}}<\/code><\/pre>\n <\/div>\n <hr \/>\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<html>\n <head>\n <title>Pogo Examples<\/title>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"samples.css\\\" \/>\n <link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"highlight.css\\\" \/>\n <\/head>\n <body>\n <a href=\\\"https:\/\/github.com\/featurist\/pogo-examples\\\"><img style=\\\"position: absolute; top: 0; right: 0; border: 0;\\\" src=\\\"http:\/\/s3.amazonaws.com\/github\/ribbons\/forkme_right_darkblue_121621.png\\\" alt=\\\"Fork me on GitHub\\\" \/><\/a>\n <h1>PogoScript to JavaScript Examples<\/h1>\n <ul>\n {{#each examples}}\n <li>\n <h2>{{this.name}}<\/h2>\n <div class=\\\"pogo\\\">\n <pre class=\\\"pogo\\\"><code>{{{pogo this}}}<\/code><\/pre>\n <\/div>\n <div class=\\\"javascript\\\">\n <pre class=\\\"javascript\\\"><code>{{{js this}}}<\/code><\/pre>\n <\/div>\n <hr \/>\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":"91a608fc578166ba22ab334e027e4305d5e67655","subject":"formatting","message":"formatting\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'\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\n:compile file = compile file (filename); ugly =\n js = js from pogo file (filename)\n if (!ugly)\n js = beautify (js)\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\n: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\n: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 console: log \"<@(token: 0)>\" (token: 1)\n\njs filename from pogo filename (pogo) =\n pogo: replace `\\.pogo$` '' + '.js'\n\n:run file (filename) =\n js = js from pogo file (filename)\n \n module: filename = fs: realpath sync (filename)\n process: argv: shift!\n process: argv: 0 = 'pogo'\n \n module: _compile (js, filename)\n\n:compile (pogo); filename =\n term = parse (pogo)\n\n code = generate code (term)\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\n:evaluate (pogo, definitions) =\n js = exports: compile (pogo)\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\njs from pogo file (filename) =\n contents = fs: read file sync (filename) 'utf-8'\n exports: compile (contents); filename (filename)\n \nsource location printer; filename; source =\n object =>\n :lines in range (range) =\n lines = source: split `\\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'\nms = require '..\/lib\/memorystream'\nparser = require '.\/parser'\nparse = parser: parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\n_ = require 'underscore'\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\n:compile file = compile file (filename); ugly =\n js = js from pogo file (filename)\n if (!ugly)\n js = beautify (js)\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\n: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\n: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 console: log \"<@(token: 0)>\" (token: 1)\n\njs filename from pogo filename (pogo) =\n pogo: replace `\\.pogo$` '' + '.js'\n\n:run file (filename) =\n js = js from pogo file (filename)\n \n module: filename = fs: realpath sync (filename)\n process: argv: shift!\n process: argv: 0 = 'pogo'\n \n module: _compile (js, filename)\n\n:compile (pogo); filename =\n term = parse (pogo)\n\n code = generate code (term)\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\n:evaluate (pogo, definitions) =\n js = exports: compile (pogo)\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\njs from pogo file (filename) =\n contents = fs: read file sync (filename) 'utf-8'\n exports: compile (contents); filename (filename)\n \nsource location printer; filename; source =\n object =>\n :lines in range (range) =\n lines = source: split `\\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","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"0d655a17c60beb6a788d585cccb4ce947cd34c73","subject":"fixed test","message":"fixed test\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parserSpec.pogo","new_file":"src\/bootstrap\/parserSpec.pogo","new_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 function call\n function {\n is block\n body {\n statements [{\n is variable\n variable ['stuff']\n }]\n }\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 '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","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 function call\n function {\n is block\n body {\n statements [{\n is variable\n variable ['stuff']\n }]\n }\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 '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":"f570ec96cc011a81807182732faaf6f5c78397ff","subject":"better example","message":"better example\n","repos":"featurist\/httpism","old_file":"example.pogo","new_file":"example.pogo","new_contents":"httpism = require '.\/index'\n\ngoogle = httpism.resource 'http:\/\/google.com\/'\nsearch results = google.get! 'search?q=httpism'\nconsole.log (search results.body)\n\nprocess.exit 0\n","old_contents":"httpism = require '.\/index'\n\nconsole.log (httpism ('http:\/\/google.com\/').get! ().get! ('\/asdf'))\nconsole.log (httpism ('http:\/\/google.com\/').get! ().body)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"587dc4ec4d325777cf04f7b204a999ccd5e3f73a","subject":"updating pogoscript tests for the updated zombie.js library","message":"updating pogoscript tests for the updated zombie.js library\n","repos":"kosicki123\/oauth-signature-js,7digital\/oauth-reference-page,kosicki123\/oauth-signature-js,7digital\/oauth-reference-page,bettiolo\/oauth-signature-js,bettiolo\/oauth-signature-js","old_file":"test\/spec.pogo","new_file":"test\/spec.pogo","new_contents":"browser = require 'zombie'\nexpress = require 'express'\n\nport = 4001\n\nserve directory (dir) over http (port: 4000) =\n app = express.create server ()\n app.use (express.static (dir))\n \n app.listen (port)\n\nserve directory \"#(__dirname)\/..\" over http (port: port)\n\nobject (o) as array =\n a = []\n \n for @(field) in (o)\n if (o.has own property (field))\n a.push {name = field, value = o.(field)}\n \n a\n\ndescribe 'OAuth'\n b = nil\n\n before each\n b := new (browser)\n\n oauth parameters (params) should produce (results) (done) =\n b.visit \"http:\/\/localhost:#(port)\/\"\n b.fill 'url' (params.url)\n b.select 'method' (params.method || 'GET')\n b.fill 'consumer key' (params.consumer key)\n b.fill 'consumer secret' (params.consumer secret)\n b.fill '#token' (params.token)\n b.fill '#token-secret' (params.token secret)\n b.fill 'nonce' (params.nonce)\n b.fill 'timestamp' (params.timestamp)\n \n if (params.body)\n b.fill '#body' (params.body)\n \n if (params.body encoding)\n b.select 'body encoding' (params.body encoding)\n \n add field (name, value, then) =\n b.press button '#add-parameter'\n b.wait\n then\n b.fill '.field-name:last' (name)\n b.fill '.field-value:last' (value)\n \n then ()\n \n sign (then) =\n b.wait\n (b.text '#query-string').should.equal (results.query string)\n (b.text '#base-string').should.equal (results.base string)\n (b.field '#hmac-key'.value).should.equal (results.hmac key)\n (b.field '#base64-signature'.value).should.equal (results.base64 signature)\n (b.field '#signature'.value).should.equal (results.signature)\n (b.field '#authorization-header'.value).should.equal (results.authorization header)\n (b.field '#curl'.value).should.equal (results.curl)\n \n then ()\n \n add fields (fields, then) =\n if (fields.length > 0)\n field = fields.pop ()\n \n add field (field.name, field.value)\n add fields (fields, then)\n else\n then ()\n\n add fields (object (params.fields) as array)\n \/\/console.log (b.html 'body')\n sign (done)\n\n it 'produces the OAuth 1.0a reference sample' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"tR3+Ty81lMeYAr\/Fid0kMTYa\/WM=\"\n signature \"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"'\n curl \"curl 'http:\/\/photos.example.net\/photos?file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D'\"\n } (done)\n\n\n it 'signs signed POST for application\/x-www-form-urlencoded' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos' -d 'file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D'\"\n } (done)\n\n it 'signs signed POST for application\/json' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields {\n file 'vacation.jpg'\n size 'original'\n }\n body '{\"x\": \"eks\", \"y\": \"why\"}'\n body encoding 'application\/json'\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos?size=original&file=vacation.jpg' -d '{\\\"x\\\": \\\"eks\\\", \\\"y\\\": \\\"why\\\"}' -H 'Authorization: oauth_consumer_key=\\\"dpf43f3p2l4k3l03\\\", oauth_nonce=\\\"kllo9940pd9333jh\\\", oauth_timestamp=\\\"1191242096\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_token=\\\"nnch734d00sl2jdk\\\", oauth_version=\\\"1.0\\\", oauth_signature=\\\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\\\"' -H 'Content-Type: application\/json'\"\n } (done)\n","old_contents":"browser = require 'zombie'\nexpress = require 'express'\n\nport = 4001\n\nserve directory (dir) over http (port: 4000) =\n app = express.create server ()\n app.use (express.static (dir))\n \n app.listen (port)\n\nserve directory \"#(__dirname)\/..\" over http (port: port)\n\nobject (o) as array =\n a = []\n \n for @(field) in (o)\n if (o.has own property (field))\n a.push {name = field, value = o.(field)}\n \n a\n\ndescribe 'OAuth'\n b = nil\n\n before each\n b := new (browser)\n\n oauth parameters (params) should produce (results) (done) =\n b.visit \"http:\/\/localhost:#(port)\/\"\n b.fill 'url' (params.url)\n b.select 'method' (params.method || 'GET')\n b.fill 'consumer key' (params.consumer key)\n b.fill 'consumer secret' (params.consumer secret)\n b.fill '#token' (params.token)\n b.fill '#token-secret' (params.token secret)\n b.fill 'nonce' (params.nonce)\n b.fill 'timestamp' (params.timestamp)\n \n if (params.body)\n b.fill '#body' (params.body)\n \n if (params.body encoding)\n b.select 'body encoding' (params.body encoding)\n \n add field (name, value, then) =\n b.press button '#add-parameter'\n b.fill '.field-name:last' (name)\n b.fill '.field-value:last' (value)\n \n then ()\n \n sign (then) =\n b.wait\n (b.text '#query-string').should.equal (results.query string)\n (b.text '#base-string').should.equal (results.base string)\n (b.field '#hmac-key'.value).should.equal (results.hmac key)\n (b.field '#base64-signature'.value).should.equal (results.base64 signature)\n (b.field '#signature'.value).should.equal (results.signature)\n (b.field '#authorization-header'.value).should.equal (results.authorization header)\n (b.field '#curl'.value).should.equal (results.curl)\n \n then ()\n \n add fields (fields, then) =\n if (fields.length > 0)\n field = fields.pop ()\n \n add field (field.name, field.value)\n add fields (fields, then)\n else\n then ()\n\n add fields (object (params.fields) as array)\n \/\/console.log (b.html 'body')\n sign (done)\n\n it 'produces the OAuth 1.0a reference sample' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"tR3+Ty81lMeYAr\/Fid0kMTYa\/WM=\"\n signature \"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"'\n curl \"curl 'http:\/\/photos.example.net\/photos?file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D'\"\n } (done)\n\n\n it 'signs signed POST for application\/x-www-form-urlencoded' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos' -d 'file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D'\"\n } (done)\n\n it 'signs signed POST for application\/json' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields {\n file 'vacation.jpg'\n size 'original'\n }\n body '{\"x\": \"eks\", \"y\": \"why\"}'\n body encoding 'application\/json'\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos?size=original&file=vacation.jpg' -d '{\\\"x\\\": \\\"eks\\\", \\\"y\\\": \\\"why\\\"}' -H 'Authorization: oauth_consumer_key=\\\"dpf43f3p2l4k3l03\\\", oauth_nonce=\\\"kllo9940pd9333jh\\\", oauth_timestamp=\\\"1191242096\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_token=\\\"nnch734d00sl2jdk\\\", oauth_version=\\\"1.0\\\", oauth_signature=\\\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\\\"' -H 'Content-Type: application\/json'\"\n } (done)\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"PogoScript"} {"commit":"0b0cad77381711d75ac83ff7888b09f8e297ff18","subject":"whitespace","message":"whitespace\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 = fs: read file sync \".\/index.handlebars\": to string !\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: javascript @js\n pogo = @highlight: pogoscript @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 = fs : read file sync \".\/index.handlebars\" : to string !\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 : javascript @js\n pogo = @highlight : pogoscript @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":"562dfdf36e5eb30ccc3da9708609ee04f65c6b40","subject":"test returns inside functions inside for loops work","message":"test returns inside functions inside for loops work\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/scriptSpec.pogo","new_file":"test\/scriptSpec.pogo","new_contents":"script = require '.\/scriptAssertions.pogo'\nassert = require 'assert'\npath = require 'path'\n\nshould output = script.should output\nwith args should output = script.with args should output\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')\n done!\n\ndescribe 'script'\n describe 'integers'\n it 'can denote an integer literally'\n 'print 1' should output '1'\n\n describe 'new operator'\n it 'can be called with no arguments'\n 'print (new (Array))' should output '[]'\n \n it 'new operator can be called with 1 argument'\n 'print (new (Date 2010 10 9).value of())' should output '1289260800000'\n \n describe '== has semantics equivalent to === in JS'\n it 'returns false for equality of \"\" with 0'\n 'print (\"\" == 0)' should output 'false'\n \n it 'returns true for identical strings'\n 'print (\"something\" == \"something\")' should output 'true'\n \n describe 'lists'\n it 'an empty list is just []'\n 'print []' should output '[]'\n \n it 'list entries can be delimited with a comma \",\"'\n 'print [1, 2]' should output '[ 1, 2 ]'\n \n it 'list entries can be delimited with a newline'\n 'print [\n 1\n 2\n ]' should output '[ 1, 2 ]'\n \n describe 'functions'\n describe 'definitions'\n it 'functions can be defined by placing the arguments to the left of the equals sign \"=\"'\n 'succ (n) =\n n + 1\n \n print (succ (1))' should output '2'\n \n describe 'functions with no arguments'\n it 'a function can be defined to have no parameters with the exclamation mark \"!\"'\n 'say hi! =\n print \"hi\"\n \n say hi!' should output \"'hi'\"\n \n it 'a function can be defined to have no parameters with empty parens \"()\"'\n 'say hi () =\n print \"hi\"\n \n say hi ()' should output \"'hi'\"\n \n it \"a function's parameters shadow variables in outer scope\"\n 'foo (a) =\n print (a)\n \n a = \"outer a\"\n foo \"inner a\"\n print (a)' should output \"'inner a'\n 'outer a'\"\n \n describe 'splats'\n it 'a function can be defined with a single splat parameter'\n 'foo (args, ...) =\n print (args)\n \n foo 1 2' should output '[ 1, 2 ]'\n \n it 'a function can be called with more than one splat argument'\n 'foo (args, ...) =\n print (args)\n \n foo 1 [2, 3] ... [4, 5] ... 6' should output '[ 1, 2, 3, 4, 5, 6 ]'\n \n it \"a function's splat parameter shadows variables in outer scope\"\n 'foo (a, ...) =\n print (a.0)\n \n a = \"outer a\"\n \n foo \"inner a\"\n print (a)' should output \"'inner a'\n 'outer a'\"\n \n describe 'optional arguments'\n it 'functions can take optional arguments'\n 'print (size: 10)' should output '{ size: 10 }'\n \n it 'a function can be defined to take an optional argument'\n 'open tcp connection (host: nil, port: nil) =\n print (host)\n print (port)\n \n open tcp connection (host: \"pogoscript.org\", port: 80)' should output \"'pogoscript.org'\n 80\"\n \n it 'if the optional parameter has a default value\n and no optional arguments are passed by the caller,\n then that default value is used'\n \n 'open tcp connection (port: 80) =\n print (port)\n \n open tcp connection!' should output \"80\"\n \n it 'if the optional parameter has a default value\n and other optional arguments are passed by the caller\n but not that one, then that default value is used'\n \n 'open tcp connection (port: 80) =\n print (port)\n \n open tcp connection (host: \"pogoscript.org\")' should output \"80\"\n \n it \"a function's optional parameter shadows variables in outer scope\"\n 'foo (bar: nil) =\n print (bar)\n \n bar = \"outer bar\"\n foo (bar: \"inner bar\")\n print (bar)' should output \"'inner bar'\n 'outer bar'\"\n \n it \"a function's optional parameter shadows variables in outer scope,\n even if it has a default value\"\n \n 'foo (bar: 80) =\n print (bar)\n \n bar = \"outer bar\"\n foo (bar: \"inner bar\")\n print (bar)' should output \"'inner bar'\n 'outer bar'\"\n\n describe 'for'\n it 'can be returned from'\n 'count to three () =\n for (n = 0, n < 10, n = n + 1)\n if (n > 2)\n return \"three\"\n\n print (count to three ())' should output '''three'''\n \n it 'can be returned from'\n '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 ())' should output '3\n 2\n 1'\n \n it 'can loop'\n 'count to three () =\n for (n = 0, n < 10, n = n + 1)\n print (n)\n\n count to three ()' should output '0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9'\n \n","old_contents":"script = require '.\/scriptAssertions.pogo'\nassert = require 'assert'\npath = require 'path'\n\nshould output = script.should output\nwith args should output = script.with args should output\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')\n done!\n\ndescribe 'script'\n describe 'integers'\n it 'can denote an integer literally'\n 'print 1' should output '1'\n\n describe 'new operator'\n it 'can be called with no arguments'\n 'print (new (Array))' should output '[]'\n \n it 'new operator can be called with 1 argument'\n 'print (new (Date 2010 10 9).value of())' should output '1289260800000'\n \n describe '== has semantics equivalent to === in JS'\n it 'returns false for equality of \"\" with 0'\n 'print (\"\" == 0)' should output 'false'\n \n it 'returns true for identical strings'\n 'print (\"something\" == \"something\")' should output 'true'\n \n describe 'lists'\n it 'an empty list is just []'\n 'print []' should output '[]'\n \n it 'list entries can be delimited with a comma \",\"'\n 'print [1, 2]' should output '[ 1, 2 ]'\n \n it 'list entries can be delimited with a newline'\n 'print [\n 1\n 2\n ]' should output '[ 1, 2 ]'\n \n describe 'functions'\n describe 'definitions'\n it 'functions can be defined by placing the arguments to the left of the equals sign \"=\"'\n 'succ (n) =\n n + 1\n \n print (succ (1))' should output '2'\n \n describe 'functions with no arguments'\n it 'a function can be defined to have no parameters with the exclamation mark \"!\"'\n 'say hi! =\n print \"hi\"\n \n say hi!' should output \"'hi'\"\n \n it 'a function can be defined to have no parameters with empty parens \"()\"'\n 'say hi () =\n print \"hi\"\n \n say hi ()' should output \"'hi'\"\n \n it \"a function's parameters shadow variables in outer scope\"\n 'foo (a) =\n print (a)\n \n a = \"outer a\"\n foo \"inner a\"\n print (a)' should output \"'inner a'\n 'outer a'\"\n \n describe 'splats'\n it 'a function can be defined with a single splat parameter'\n 'foo (args, ...) =\n print (args)\n \n foo 1 2' should output '[ 1, 2 ]'\n \n it 'a function can be called with more than one splat argument'\n 'foo (args, ...) =\n print (args)\n \n foo 1 [2, 3] ... [4, 5] ... 6' should output '[ 1, 2, 3, 4, 5, 6 ]'\n \n it \"a function's splat parameter shadows variables in outer scope\"\n 'foo (a, ...) =\n print (a.0)\n \n a = \"outer a\"\n \n foo \"inner a\"\n print (a)' should output \"'inner a'\n 'outer a'\"\n \n describe 'optional arguments'\n it 'functions can take optional arguments'\n 'print (size: 10)' should output '{ size: 10 }'\n \n it 'a function can be defined to take an optional argument'\n 'open tcp connection (host: nil, port: nil) =\n print (host)\n print (port)\n \n open tcp connection (host: \"pogoscript.org\", port: 80)' should output \"'pogoscript.org'\n 80\"\n \n it 'if the optional parameter has a default value\n and no optional arguments are passed by the caller,\n then that default value is used'\n \n 'open tcp connection (port: 80) =\n print (port)\n \n open tcp connection!' should output \"80\"\n \n it 'if the optional parameter has a default value\n and other optional arguments are passed by the caller\n but not that one, then that default value is used'\n \n 'open tcp connection (port: 80) =\n print (port)\n \n open tcp connection (host: \"pogoscript.org\")' should output \"80\"\n \n it \"a function's optional parameter shadows variables in outer scope\"\n 'foo (bar: nil) =\n print (bar)\n \n bar = \"outer bar\"\n foo (bar: \"inner bar\")\n print (bar)' should output \"'inner bar'\n 'outer bar'\"\n \n it \"a function's optional parameter shadows variables in outer scope,\n even if it has a default value\"\n \n 'foo (bar: 80) =\n print (bar)\n \n bar = \"outer bar\"\n foo (bar: \"inner bar\")\n print (bar)' should output \"'inner bar'\n 'outer bar'\"\n\n describe 'for'\n it 'can be returned from'\n 'count to three () =\n for (n = 0, n < 10, n = n + 1)\n if (n > 2)\n return \"three\"\n\n print (count to three ())' should output '''three'''\n \n it 'can loop'\n 'count to three () =\n for (n = 0, n < 10, n = n + 1)\n print (n)\n\n count to three ()' should output '0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9'\n \n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"4c5d5e6b9deed45acdd63943468ea9614489282e","subject":"complex expression spec using mocha","message":"complex expression spec using mocha\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/complexExpressionSpec.pogo","new_file":"src\/bootstrap\/complexExpressionSpec.pogo","new_contents":"cg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nint (n) =\n cg: integer (n)\n\nloc = {first line 1, last line 1, first column 7, last column 13}\n\nid (name) = cg: loc (cg: identifier (name), loc)\n\nvariable (name) = cg: variable [name]\n\nparameter (name) = cg: parameter [name]\n\nblock = cg: block [] (cg: statements [variable 'x'])\n\nstring (value) = cg: string (value)\n\nno arg punctuation = cg: no arg suffix?\n\ndescribe 'complex expression'\n describe 'has arguments'\n expression (e) should have arguments =\n (cg: complex expression (e): has arguments?) should be truthy\n \n it 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments\n \n it 'with no arg arguments'\n expression [[id 'a', no arg punctuation]] should have arguments\n \n it 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments\n \n describe 'arguments'\n expression (e) should have arguments (a) =\n (cg: complex expression (e): arguments?) should contain fields (a)\n \n it 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments [{integer 10}]\n \n it 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments [\n {is block}\n ]\n\n describe 'expression'\n expression (e) should contain fields (f) =\n (cg: complex expression (e): expression?) should contain fields (f)\n\n it 'with just one argument is that argument'\n expression [[int 9]] should contain fields {\n is integer\n integer 9\n }\n\n it 'all arguments is function call, first argument is function'\n expression [[variable 'z', int 9]] should contain fields {\n is function call\n function {variable ['z']}\n arguments [{integer 9}]\n }\n\n it 'one argument and call punctuation is function call'\n expression [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {variable ['z']}\n arguments []\n }\n\n it 'with name is variable'\n expression [[id 'a', id 'variable']] should contain fields {\n is variable\n variable ['a', 'variable']\n }\n\n it 'with name and argument is function call'\n expression [[id 'a', id 'variable', int 10]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [{integer 10}]\n }\n\n it 'finds macro'\n expression [[id 'if', variable 'x', block]] should contain fields {\n is if expression\n }\n\n it 'with name and optional args is function call with optional args'\n expression [[id 'a', id 'variable'], [id 'port', int 80]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments []\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n it 'with block after optional arguments'\n expression [[id 'a', id 'variable'], [id 'port', int 80, block]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['x']}\n ]\n }\n }\n ]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n describe 'object operation -> expression'\n expression (object, operation) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): expression?) should contain fields (fields)\n \n it 'method call'\n expression (variable 'a') [[id 'method', int 10]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n }\n \n it 'method call with optional arguments'\n expression (variable 'a') [[id 'method', int 10], [id 'port', int 80]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n it 'index'\n expression (variable 'a') [[int 10]] should contain fields {\n is indexer\n object {variable ['a']}\n indexer {integer 10}\n }\n\n it 'index call with arguments'\n expression (variable 'a') [[variable 'z', int 10]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments [{integer 10}]\n }\n\n it 'index call with no arguments'\n expression (variable 'a') [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments []\n }\n\n it 'field reference'\n expression (variable 'a') [[id 'field']] should contain fields {\n is field reference\n object {variable ['a']}\n name ['field']\n }\n\n describe 'hash entry'\n hash entry (expression) should contain fields (fields) =\n (cg: complex expression (expression): hash entry?) should contain fields (fields)\n \n it 'if contains one component that is the hash entry'\n hash entry [[id 'field']] should contain fields {\n is hash entry\n field ['field']\n value = undefined\n }\n \n it 'if contains more than component then semantic error'\n hash entry [[id 'field'], [id 'secondField']] should contain fields {\n is semantic failure\n }\n\n describe 'definition -> hash entry'\n it 'string key'\n hash entry = cg: complex expression [[string 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n it 'identifier key'\n hash entry = cg: complex expression [[id 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n it \"field's value can be on a new indented line\"\n hash entry = cg: complex expression [[id 'port']]: definition (cg: block ([], cg: statements [cg: variable ['a']])): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {\n is scope\n statements [variable ['a']]\n }\n }\n \n it 'can define a method as a hash key'\n hash entry = cg: complex expression [[id 'name', variable 'name']]: definition (cg: variable ['name']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['name']\n value {\n is block\n\n body {\n statements [\n {variable ['name']}\n ]\n }\n\n parameters [{variable ['name']}]\n\n redefines self\n }\n }\n\n describe 'object operation -> definition'\n definition (object, operation, source) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): definition (source): expression?) should contain fields (fields)\n \n it 'method definition'\n definition (variable 'object') [[id 'method', variable 'x']] (block) should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n }\n }\n \n it 'method definition without block'\n definition (variable 'object') [[id 'method', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n redefines self\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n it 'field definition'\n definition (variable 'object') [[id 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['x']\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n it 'index definition'\n definition (variable 'object') [[variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {variable ['x']}\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n it 'index method definition'\n definition (variable 'object') [[cg: string 'xyz', variable 'p']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n {variable ['p']}\n ]\n }\n }\n \n it 'index method definition with no args'\n definition (variable 'object') [[cg: string 'xyz', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n ]\n }\n }\n\n describe 'definition'\n definition (target, source) should contain fields (fields) =\n (cg: complex expression (target): definition (source): expression?) should contain fields (fields)\n \n it 'function definition'\n definition [[id 'function', variable 'x']] (block) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n \n it 'function definition with optional parameter'\n definition [[id 'function', variable 'x'], [id 'port', int 80], [id 'name']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n optional parameters [\n {field ['port'], value {integer 80}}\n {field ['name'], value = undefined}\n ]\n body {statements [{variable ['y']}]}\n }\n }\n \n it 'function definition without block'\n definition [[id 'function', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n it 'no arg function definition'\n definition [[id 'function', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n it 'function definition with empty param list'\n definition [[id 'function', cg: argument list []]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n it 'variable definition'\n definition [[id 'function']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n\n it 'variable definition with scope'\n definition [[id 'function']] (cg: block [] (cg: statements [variable 'y'])) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is scope\n statements [{variable ['y']}]\n }\n }\n\n describe 'parameter'\n parameter (p) should contain fields (fields) =\n (cg: complex expression (p): expression? : parameter?) should contain fields (fields)\n \n it 'variable'\n parameter [[id 'a']] should contain fields {variable ['a']}\n","old_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nint (n) =\n cg: integer (n)\n\nloc = {first line 1, last line 1, first column 7, last column 13}\n\nid (name) = cg: loc (cg: identifier (name), loc)\n\nvariable (name) = cg: variable [name]\n\nparameter (name) = cg: parameter [name]\n\nblock = cg: block [] (cg: statements [variable 'x'])\n\nstring (value) = cg: string (value)\n\nno arg punctuation = cg: no arg suffix?\n\nexpression (e) should contain fields (f) =\n (cg: complex expression (e): expression?) should contain fields (f)\n\nspec 'complex expression'\n spec 'has arguments'\n expression (e) should have arguments =\n (cg: complex expression (e): has arguments?) should be truthy\n \n spec 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments\n \n spec 'with no arg arguments'\n expression [[id 'a', no arg punctuation]] should have arguments\n \n spec 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments\n \n spec 'arguments'\n expression (e) should have arguments (a) =\n (cg: complex expression (e): arguments?) should contain fields (a)\n \n spec 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments [{integer 10}]\n \n spec 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments [\n {is block}\n ]\n\n spec 'expression'\n spec 'with just one argument is that argument'\n expression [[int 9]] should contain fields {\n is integer\n integer 9\n }\n\n spec 'all arguments is function call, first argument is function'\n expression [[variable 'z', int 9]] should contain fields {\n is function call\n function {variable ['z']}\n arguments [{integer 9}]\n }\n\n spec 'one argument and call punctuation is function call'\n expression [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {variable ['z']}\n arguments []\n }\n\n spec 'with name is variable'\n expression [[id 'a', id 'variable']] should contain fields {\n is variable\n variable ['a', 'variable']\n }\n\n spec 'with name and argument is function call'\n expression [[id 'a', id 'variable', int 10]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [{integer 10}]\n }\n\n spec 'finds macro'\n expression [[id 'if', variable 'x', block]] should contain fields {\n is if expression\n }\n\n spec 'with name and optional args is function call with optional args'\n expression [[id 'a', id 'variable'], [id 'port', int 80]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments []\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'with block after optional arguments'\n expression [[id 'a', id 'variable'], [id 'port', int 80, block]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['x']}\n ]\n }\n }\n ]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'object operation -> expression'\n expression (object, operation) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): expression?) should contain fields (fields)\n \n spec 'method call'\n expression (variable 'a') [[id 'method', int 10]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n }\n \n spec 'method call with optional arguments'\n expression (variable 'a') [[id 'method', int 10], [id 'port', int 80]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'index'\n expression (variable 'a') [[int 10]] should contain fields {\n is indexer\n object {variable ['a']}\n indexer {integer 10}\n }\n\n spec 'index call with arguments'\n expression (variable 'a') [[variable 'z', int 10]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments [{integer 10}]\n }\n\n spec 'index call with no arguments'\n expression (variable 'a') [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments []\n }\n\n spec 'field reference'\n expression (variable 'a') [[id 'field']] should contain fields {\n is field reference\n object {variable ['a']}\n name ['field']\n }\n\n spec 'hash entry'\n hash entry (expression) should contain fields (fields) =\n (cg: complex expression (expression): hash entry?) should contain fields (fields)\n \n spec 'if contains one component that is the hash entry'\n hash entry [[id 'field']] should contain fields {\n is hash entry\n field ['field']\n value = undefined\n }\n \n spec 'if contains more than component then semantic error'\n hash entry [[id 'field'], [id 'secondField']] should contain fields {\n is semantic failure\n }\n\n spec 'definition -> hash entry'\n spec 'string key'\n hash entry = cg: complex expression [[string 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec 'identifier key'\n hash entry = cg: complex expression [[id 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec \"field's value can be on a new indented line\"\n hash entry = cg: complex expression [[id 'port']]: definition (cg: block ([], cg: statements [cg: variable ['a']])): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {\n is scope\n statements [variable ['a']]\n }\n }\n \n spec 'can define a method as a hash key'\n hash entry = cg: complex expression [[id 'name', variable 'name']]: definition (cg: variable ['name']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['name']\n value {\n is block\n\n body {\n statements [\n {variable ['name']}\n ]\n }\n\n parameters [{variable ['name']}]\n\n redefines self\n }\n }\n\n spec 'object operation -> definition'\n definition (object, operation, source) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): definition (source): expression?) should contain fields (fields)\n \n spec 'method definition'\n definition (variable 'object') [[id 'method', variable 'x']] (block) should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n }\n }\n \n spec 'method definition without block'\n definition (variable 'object') [[id 'method', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n redefines self\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'field definition'\n definition (variable 'object') [[id 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['x']\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index definition'\n definition (variable 'object') [[variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {variable ['x']}\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index method definition'\n definition (variable 'object') [[cg: string 'xyz', variable 'p']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n {variable ['p']}\n ]\n }\n }\n \n spec 'index method definition with no args'\n definition (variable 'object') [[cg: string 'xyz', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n ]\n }\n }\n\n spec 'definition'\n definition (target, source) should contain fields (fields) =\n (cg: complex expression (target): definition (source): expression?) should contain fields (fields)\n \n spec 'function definition'\n definition [[id 'function', variable 'x']] (block) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n \n spec 'function definition with optional parameter'\n definition [[id 'function', variable 'x'], [id 'port', int 80], [id 'name']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n optional parameters [\n {field ['port'], value {integer 80}}\n {field ['name'], value = undefined}\n ]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition without block'\n definition [[id 'function', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'no arg function definition'\n definition [[id 'function', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition with empty param list'\n definition [[id 'function', cg: argument list []]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'variable definition'\n definition [[id 'function']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n\n spec 'variable definition with scope'\n definition [[id 'function']] (cg: block [] (cg: statements [variable 'y'])) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is scope\n statements [{variable ['y']}]\n }\n }\n\n spec 'parameter'\n parameter (p) should contain fields (fields) =\n (cg: complex expression (p): expression? : parameter?) should contain fields (fields)\n \n spec 'variable'\n parameter [[id 'a']] should contain fields {variable ['a']}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"a016c2e26121bc51f70aaef008ce68edc006f6fb","subject":"code style","message":"code style\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\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\n:compile file = 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\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\n: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\n: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 console: log \"<@token>\"\n\njs filename from pogo filename @pogo =\n pogo: replace `\\.pogo$` '' + '.js'\n\n:run file @filename =\n js = js from pogo file @filename\n \n module: filename = fs: realpath sync @filename\n process: argv: shift!\n process: argv: 0 = 'pogo'\n \n module: _compile @js @filename\n\njs from pogo file @filename =\n contents = fs: read file sync @filename 'utf-8'\n term = parse @contents\n \n code = generate code @term\n\n if (errors: has errors?)\n errors: print errors (source location printer, filename @filename, source @contents)\n process: exit 1\n else\n code\n \nsource location printer, filename, source =\n object =>\n :lines in range @range =\n lines = source: split `\\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'\nms = require '..\/lib\/memorystream'\nparser = require '.\/parser'\nparse = parser: parse\nuglify = require 'uglify-js'\nerrors = require '.\/codeGenerator\/errors'\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\n:compile file = 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\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\n: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\n: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 console: log \"<@token>\"\n\njs filename from pogo filename @pogo =\n pogo : replace `\\.pogo$` '' + '.js'\n\n:run file @filename =\n js = js from pogo file @filename\n \n module : filename = fs : realpath sync @filename\n process : argv : shift!\n process : argv : 0 = 'pogo'\n \n module : _compile @js @filename\n\njs from pogo file @filename =\n contents = fs : read file sync @filename 'utf-8'\n term = parse @contents\n \n code = generate code @term\n\n if (errors : has errors?)\n errors : print errors (source location printer, filename @filename, source @contents)\n process : exit 1\n else\n code\n \nsource location printer, filename, source =\n object =>\n : lines in range @range =\n lines = source : split `\\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","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"43ab5cafd0d51227626e29c3bf225e0660349214","subject":"test for not returning last expression in promise","message":"test for not returning last expression in promise\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/promisesSpec.pogo","new_file":"test\/promisesSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\n\nshouldOutput = script.shouldOutput\n\ndescribe 'promises'\n it 'can resolve a promise'\n 'print (p 6!)' shouldOutput \"6\"\n\n it 'only exits once'\n 'a() =\n p ()!\n\n a()!\n print \"finished\"' shouldOutput \"'finished'\"\n\n describe 'callbacks'\n it 'converts callback style to a promise'\n 'f (cb) =\n setTimeout\n cb (nil, \"result\")\n 1\n \n print (f ^!)' shouldOutput \"'result'\"\n\n it '^!. can be used'\n 'f (cb) =\n setTimeout\n cb (nil, {result = \"result\"})\n 1\n \n print (f ^!.result)' shouldOutput \"'result'\"\n\n describe 'explicit promises'\n it 'can create explicit promises'\n 'x = promise @(success)\n success \"result\"\n\n print (x!)' shouldOutput \"'result'\"\n\n it 'an exception inside promise causes the promise to fail'\n 'x = promise @(success)\n throw (new (Error \"uh oh\"))\n\n try\n x!\n catch (e)\n print (e.message)' shouldOutput \"'uh oh'\"\n\n it 'calling the error inside the promise causes the promise to fail'\n 'x = promise @(success, error)\n error (new (Error \"uh oh\"))\n\n try\n x!\n catch (e)\n print (e.message)' shouldOutput \"'uh oh'\"\n\n it 'can resolve other promises inside the promise, but must call success'\n 'x = promise @(success)\n setTimeout ^ 1!\n success(\"result\")\n\n print (x!)' shouldOutput \"'result'\"\n\n it \"doesn't take the last expression as the result\"\n 'x = promise @(success)\n setTimeout\n success(\"result\")\n 1!\n \"uh oh\"\n\n print (x!)' shouldOutput \"'result'\"\n","old_contents":"script = require '.\/scriptAssertions'\n\nshouldOutput = script.shouldOutput\n\ndescribe 'promises'\n it 'can resolve a promise'\n 'print (p 6!)' shouldOutput \"6\"\n\n it 'only exits once'\n 'a() =\n p ()!\n\n a()!\n print \"finished\"' shouldOutput \"'finished'\"\n\n describe 'callbacks'\n it 'converts callback style to a promise'\n 'f (cb) =\n setTimeout\n cb (nil, \"result\")\n 1\n \n print (f ^!)' shouldOutput \"'result'\"\n\n it '^!. can be used'\n 'f (cb) =\n setTimeout\n cb (nil, {result = \"result\"})\n 1\n \n print (f ^!.result)' shouldOutput \"'result'\"\n\n describe 'explicit promises'\n it 'can create explicit promises'\n 'x = promise @(success)\n success \"result\"\n\n print (x!)' shouldOutput \"'result'\"\n\n it 'an exception inside promise causes the promise to fail'\n 'x = promise @(success)\n throw (new (Error \"uh oh\"))\n\n try\n x!\n catch (e)\n print (e.message)' shouldOutput \"'uh oh'\"\n\n it 'calling the error inside the promise causes the promise to fail'\n 'x = promise @(success, error)\n error (new (Error \"uh oh\"))\n\n try\n x!\n catch (e)\n print (e.message)' shouldOutput \"'uh oh'\"\n\n it 'can resolve other promises inside the promise, but must call success'\n 'x = promise @(success)\n setTimeout ^ 1!\n success(\"result\")\n\n print (x!)' shouldOutput \"'result'\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"b4f573de2f930607bbeb5a6c3aeaf4711be0b590","subject":"random clean up","message":"random clean up\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"lib\/terms\/ifExpression.pogo","new_file":"lib\/terms\/ifExpression.pogo","new_contents":"codegen utils = require \".\/codegenUtils\"\n_ = require 'underscore'\nasync control = require '..\/asyncControl'\n\nmodule.exports (terms) =\n if expression term = terms.term {\n constructor (cases, else body) =\n self.is if expression = true \n self.cases = cases\n self.else body = else body\n\n generate java script statement (buffer, scope) =\n codegen utils.write to buffer with delimiter (self.cases, 'else ', buffer) @(case_)\n buffer.write ('if(')\n case_.condition.generate java script (buffer, scope)\n buffer.write ('){')\n case_.body.generate java script statements (buffer, scope)\n buffer.write ('}')\n\n if (self.else body)\n buffer.write ('else{')\n self.else body.generate java script statements (buffer, scope)\n buffer.write ('}')\n\n generate java script (buffer, scope) =\n self.rewrite result term @(term) into\n terms.return statement (term)\n \n buffer.write '(function(){'\n self.generate java script statement (buffer, scope)\n buffer.write '})()'\n\n rewrite result term into (return term, async: false) =\n for each @(_case) in (self.cases)\n _case.body.rewrite result term into (return term)\n\n if (self.else body)\n self.else body.rewrite result term into (return term)\n else if (async)\n self.else body = terms.statements [\n terms.function call (terms.callback function, [])\n ]\n\n self\n }\n\n if expression (cases, else body) =\n any async cases = _.any (cases) @(_case)\n _case.body.is async\n\n if (any async cases @or else body @and else body.is async)\n if (cases.length > 1)\n case for condition (condition) and body (body) =\n terms.hash [\n terms.hash entry (\n ['condition']\n condition\n )\n terms.hash entry (\n ['body']\n terms.argument utils.asyncify body (body)\n )\n ]\n\n cases list =\n _.map (cases) @(_case)\n case for condition (_case.condition) and body (_case.body)\n\n if (else body)\n cases list.push (\n case for condition (terms.boolean (true)) and body (else body)\n )\n\n async if else if else function =\n terms.module constants.define ['async', 'if', 'else', 'if', 'else'] as (\n terms.javascript (async control.if else if else.to string ())\n )\n\n terms.function call (async if else if else function, [terms.list (cases list)], async: true)\n else if (else body)\n async if else function =\n terms.module constants.define ['async', 'if', 'else'] as (\n terms.javascript (async control.if else.to string ())\n )\n\n terms.function call (\n async if else function\n [\n cases.0.condition\n terms.argument utils.asyncify body (cases.0.body)\n terms.argument utils.asyncify body (else body)\n ]\n async: true\n )\n else\n async if function =\n terms.module constants.define ['async', 'if'] as (\n terms.javascript (async control.if.to string ())\n )\n\n terms.function call (\n async if function\n [\n cases.0.condition\n terms.argument utils.asyncify body (cases.0.body)\n ]\n async: true\n )\n else\n if expression term (cases, else body)\n","old_contents":"codegen utils = require \".\/codegenUtils\"\n_ = require 'underscore'\nasync control = require '..\/asyncControl'\n\nmodule.exports (terms) =\n if expression term = terms.term {\n constructor (cases, else body) =\n self.is if expression = true \n self.cases = cases\n self.else body = else body\n\n generate java script statement (buffer, scope) =\n codegen utils.write to buffer with delimiter (self.cases, 'else ', buffer) @(case_)\n buffer.write ('if(')\n case_.condition.generate java script (buffer, scope)\n buffer.write ('){')\n case_.body.generate java script statements (buffer, scope)\n buffer.write ('}')\n\n if (self.else body)\n buffer.write ('else{')\n self.else body.generate java script statements (buffer, scope)\n buffer.write ('}')\n\n generate java script (buffer, scope) =\n self.rewrite result term @(term) into\n terms.return statement (term)\n \n buffer.write '(function(){'\n self.generate java script statement (buffer, scope)\n buffer.write '})()'\n\n rewrite result term into (return term, async: false) =\n for each @(_case) in (self.cases)\n _case.body.rewrite result term into (return term)\n\n if (self.else body)\n self.else body.rewrite result term into (return term)\n else if (async)\n self.else body = terms.statements [\n terms.function call (terms.callback function, [])\n ]\n\n self\n }\n\n if expression (cases, else body) =\n any async cases = _.any (cases) @(_case)\n _case.body.is async\n\n if (any async cases || (else body && else body.is async))\n if (cases.length > 1)\n case for condition (condition) and body (body) =\n terms.hash [\n terms.hash entry (\n ['condition']\n condition\n )\n terms.hash entry (\n ['body']\n terms.argument utils.asyncify body (body)\n )\n ]\n\n cases list =\n _.map (cases) @(_case)\n case for condition (_case.condition) and body (_case.body)\n\n if (else body)\n cases list.push (\n case for condition (terms.boolean (true)) and body (else body)\n )\n\n async if else if else function =\n terms.module constants.define ['async', 'if', 'else', 'if', 'else'] as (\n terms.javascript (async control.if else if else.to string ())\n )\n\n terms.function call (async if else if else function, [terms.list (cases list)], async: true)\n else if (else body)\n async if else function =\n terms.module constants.define ['async', 'if', 'else'] as (\n terms.javascript (async control.if else.to string ())\n )\n\n terms.function call (\n async if else function\n [\n cases.0.condition\n terms.argument utils.asyncify body (cases.0.body)\n terms.argument utils.asyncify body (else body)\n ]\n async: true\n )\n else\n async if function =\n terms.module constants.define ['async', 'if'] as (\n terms.javascript (async control.if.to string ())\n )\n\n terms.function call (\n async if function\n [\n cases.0.condition\n terms.argument utils.asyncify body (cases.0.body)\n ]\n async: true\n )\n else\n if expression term (cases, else body)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"905620412689a288847bb5f5b676d521065d806e","subject":"some style touches to mongodb.pogo","message":"some style touches to 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\nmongodb named (name, address: '127.0.0.1', port: 27017) =\n new (mongodb.Db (name, new (mongodb.Server (address, port))))\n\ntest db = mongodb named '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, 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","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"4ee49a894e47e6771b4df679188f9d37c1283e76","subject":"removed some whitespace","message":"removed some whitespace\n","repos":"kosicki123\/oauth-signature-js,kosicki123\/oauth-signature-js,7digital\/oauth-reference-page,bettiolo\/oauth-signature-js,7digital\/oauth-reference-page,bettiolo\/oauth-signature-js","old_file":"test\/spec.pogo","new_file":"test\/spec.pogo","new_contents":"browser = require 'zombie'\nexpress = require 'express'\n\nport = 4001\n\nserve directory (dir) over http (port: 4000) =\n app = express.create server ()\n app.use (express.static (dir))\n \n app.listen (port)\n\nserve directory \"#(__dirname)\/..\" over http (port: port)\n\nobject (o) as array =\n a = []\n \n for @(field) in (o)\n if (o.has own property (field))\n a.push {name = field, value = o.(field)}\n \n a\n\ndescribe 'OAuth'\n b = nil\n\n before each\n b := new (browser)\n\n oauth parameters (params) should produce (results) (done) =\n b.visit \"http:\/\/localhost:#(port)\/\"\n b.fill 'url' (params.url)\n b.select 'method' (params.method || 'GET')\n b.fill 'consumer key' (params.consumer key)\n b.fill 'consumer secret' (params.consumer secret)\n b.fill '#token' (params.token)\n b.fill '#token-secret' (params.token secret)\n b.fill 'nonce' (params.nonce)\n b.fill 'timestamp' (params.timestamp)\n \n if (params.body)\n b.fill '#body' (params.body)\n \n if (params.body encoding)\n b.select 'body encoding' (params.body encoding)\n \n add field (name, value, then) =\n b.press button 'add'\n b.fill '.field-name:last' (name)\n b.fill '.field-value:last' (value)\n then ()\n \n sign (then) =\n b.wait\n (b.text '#query-string').should.equal (results.query string)\n (b.text '#base-string').should.equal (results.base string)\n (b.field '#hmac-key'.value).should.equal (results.hmac key)\n (b.field '#base64-signature'.value).should.equal (results.base64 signature)\n (b.field '#signature'.value).should.equal (results.signature)\n (b.field '#authorization-header'.value).should.equal (results.authorization header)\n (b.field '#curl'.value).should.equal (results.curl)\n \n then ()\n \n add fields (fields, then) =\n if (fields.length > 0)\n field = fields.pop ()\n add field (field.name, field.value)\n add fields (fields, then)\n else\n then ()\n\n add fields (object (params.fields) as array)\n \/\/console.log (b.html 'body')\n sign (done)\n\n it 'produces the OAuth 1.0a reference sample' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"tR3+Ty81lMeYAr\/Fid0kMTYa\/WM=\"\n signature \"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"'\n curl \"curl 'http:\/\/photos.example.net\/photos?file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D'\"\n } (done)\n\n\n it 'signs signed POST for application\/x-www-form-urlencoded' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos' -d 'file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D'\"\n } (done)\n\n it 'signs signed POST for application\/json' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields {\n file 'vacation.jpg'\n size 'original'\n }\n body '{\"x\": \"eks\", \"y\": \"why\"}'\n body encoding 'application\/json'\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos?size=original&file=vacation.jpg' -d '{\\\"x\\\": \\\"eks\\\", \\\"y\\\": \\\"why\\\"}' -H 'Authorization: oauth_consumer_key=\\\"dpf43f3p2l4k3l03\\\", oauth_nonce=\\\"kllo9940pd9333jh\\\", oauth_timestamp=\\\"1191242096\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_token=\\\"nnch734d00sl2jdk\\\", oauth_version=\\\"1.0\\\", oauth_signature=\\\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\\\"' -H 'Content-Type: application\/json'\"\n } (done)\n","old_contents":"browser = require 'zombie'\nexpress = require 'express'\n\nport = 4001\n\nserve directory (dir) over http (port: 4000) =\n app = express.create server ()\n app.use (express.static (dir))\n \n app.listen (port)\n\nserve directory \"#(__dirname)\/..\" over http (port: port)\n\nobject (o) as array =\n a = []\n \n for @(field) in (o)\n if (o.has own property (field))\n a.push {name = field, value = o.(field)}\n \n a\n\ndescribe 'OAuth'\n b = nil\n\n before each\n b := new (browser) \n\n oauth parameters (params) should produce (results) (done) =\n b.visit \"http:\/\/localhost:#(port)\/\"\n b.fill 'url' (params.url)\n b.select 'method' (params.method || 'GET')\n b.fill 'consumer key' (params.consumer key)\n b.fill 'consumer secret' (params.consumer secret)\n b.fill '#token' (params.token)\n b.fill '#token-secret' (params.token secret)\n b.fill 'nonce' (params.nonce)\n b.fill 'timestamp' (params.timestamp)\n \n if (params.body)\n b.fill '#body' (params.body)\n \n if (params.body encoding)\n b.select 'body encoding' (params.body encoding)\n \n add field (name, value, then) =\n b.press button 'add'\n b.fill '.field-name:last' (name)\n b.fill '.field-value:last' (value)\n then ()\n \n sign (then) =\n b.wait\n (b.text '#query-string').should.equal (results.query string)\n (b.text '#base-string').should.equal (results.base string)\n (b.field '#hmac-key'.value).should.equal (results.hmac key)\n (b.field '#base64-signature'.value).should.equal (results.base64 signature)\n (b.field '#signature'.value).should.equal (results.signature)\n (b.field '#authorization-header'.value).should.equal (results.authorization header)\n (b.field '#curl'.value).should.equal (results.curl)\n \n then ()\n \n add fields (fields, then) =\n if (fields.length > 0)\n field = fields.pop ()\n add field (field.name, field.value)\n add fields (fields, then)\n else\n then ()\n\n add fields (object (params.fields) as array)\n \/\/console.log (b.html 'body')\n sign (done)\n\n it 'produces the OAuth 1.0a reference sample' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"tR3+Ty81lMeYAr\/Fid0kMTYa\/WM=\"\n signature \"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D\"'\n curl \"curl 'http:\/\/photos.example.net\/photos?file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D'\"\n } (done)\n\n\n it 'signs signed POST for application\/x-www-form-urlencoded' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields = {\n file 'vacation.jpg'\n size 'original'\n }\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos' -d 'file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original&oauth_signature=wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D'\"\n } (done)\n\n it 'signs signed POST for application\/json' @(done)\n oauth parameters {\n url 'http:\/\/photos.example.net\/photos'\n method 'POST'\n consumer key 'dpf43f3p2l4k3l03'\n consumer secret 'kd94hf93k423kf44'\n token 'nnch734d00sl2jdk'\n token secret 'pfkkdhi9sl3r4s00'\n nonce 'kllo9940pd9333jh'\n timestamp '1191242096'\n fields {\n file 'vacation.jpg'\n size 'original'\n }\n body '{\"x\": \"eks\", \"y\": \"why\"}'\n body encoding 'application\/json'\n } should produce {\n query string \"file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original\"\n base string \"POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal\"\n hmac key \"kd94hf93k423kf44&pfkkdhi9sl3r4s00\"\n base64 signature \"wPkvxykrw+BTdCcGqKr+3I+PsiM=\"\n signature \"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"\n authorization header 'oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"kllo9940pd9333jh\", oauth_timestamp=\"1191242096\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"nnch734d00sl2jdk\", oauth_version=\"1.0\", oauth_signature=\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\"'\n curl \"curl -X POST 'http:\/\/photos.example.net\/photos?size=original&file=vacation.jpg' -d '{\\\"x\\\": \\\"eks\\\", \\\"y\\\": \\\"why\\\"}' -H 'Authorization: oauth_consumer_key=\\\"dpf43f3p2l4k3l03\\\", oauth_nonce=\\\"kllo9940pd9333jh\\\", oauth_timestamp=\\\"1191242096\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_token=\\\"nnch734d00sl2jdk\\\", oauth_version=\\\"1.0\\\", oauth_signature=\\\"wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D\\\"' -H 'Content-Type: application\/json'\"\n } (done)\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"PogoScript"} {"commit":"ea316a483dbddf7f6d71474252cc782a7277d60e","subject":"new regexp syntax for scriptAssertions.pogo","message":"new regexp syntax for scriptAssertions.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/scriptAssertions.pogo","new_file":"src\/bootstrap\/scriptAssertions.pogo","new_contents":"fs = require 'fs'\nspawn = require 'child_process'.spawn\nassert = require 'assert'\ncrypto = require 'crypto'\ncommand line = require '.\/commandLine'\nutil = require 'util'\n_ = require 'underscore'\n\nexecute script (script) with args (args, callback, script filename: filename for (script)) =\n fs.write file (script filename, script) @(error)\n if (error)\n callback (error)\n \n pogo = spawn '..\/..\/bin\/pogo' ([script filename].concat (args))\n \n all output = ''\n \n pogo.stdout.set encoding 'utf-8'\n pogo.stdout.on 'data' @(output)\n all output = all output + output\n \n pogo.on 'exit' @(code)\n fs.unlink (script filename) @(code)\n callback (undefined, all output)\n\nfilename for (script) =\n hash = crypto.create hash 'sha1'\n hash.update (script)\n hash.digest 'hex' + '.pogo'\n\nchomp (s) =\n s.to string ().replace r\/\\n$\/ ''\n\nexports.(script) with args (args) should output (expected output, done, script filename: nil) =\n execute script (script) with args (args, script filename: script filename) @(error, actual output)\n if (error)\n assert.fail (error)\n else\n assert.equal (chomp (actual output), chomp (expected output))\n \n done ()\n\nexports.evaluate script (script) =\n printed items = []\n \n print (arg) =\n printed items.push (arg)\n \n command line.evaluate (script, definitions: {print = print})\n \n _.map (printed items) @(item)\n util.inspect (item)\n .join \"\\n\"\n\nexports.(script) should output (expected output) =\n assert.equal (chomp (exports.evaluate script (script)), chomp (expected output))\n\nexports.(script) should throw (expected error) =\n failed = false\n \n try\n exports.evaluate script (script)\n failed = true\n catch @(ex)\n assert.equal (ex.to string () , expected error)\n \n if (failed)\n assert.fail \"expected #(expected error)\"\n \n","old_contents":"fs = require 'fs'\nspawn = require 'child_process'.spawn\nassert = require 'assert'\ncrypto = require 'crypto'\ncommand line = require '.\/commandLine'\nutil = require 'util'\n_ = require 'underscore'\n\nexecute script (script) with args (args, callback, script filename: filename for (script)) =\n fs.write file (script filename, script) @(error)\n if (error)\n callback (error)\n \n pogo = spawn '..\/..\/bin\/pogo' ([script filename].concat (args))\n \n all output = ''\n \n pogo.stdout.set encoding 'utf-8'\n pogo.stdout.on 'data' @(output)\n all output = all output + output\n \n pogo.on 'exit' @(code)\n fs.unlink (script filename) @(code)\n callback (undefined, all output)\n\nfilename for (script) =\n hash = crypto.create hash 'sha1'\n hash.update (script)\n hash.digest 'hex' + '.pogo'\n\nchomp (s) =\n s.to string ().replace `\\n$` ''\n\nexports.(script) with args (args) should output (expected output, done, script filename: nil) =\n execute script (script) with args (args, script filename: script filename) @(error, actual output)\n if (error)\n assert.fail (error)\n else\n assert.equal (chomp (actual output), chomp (expected output))\n \n done ()\n\nexports.evaluate script (script) =\n printed items = []\n \n print (arg) =\n printed items.push (arg)\n \n command line.evaluate (script, definitions: {print = print})\n \n _.map (printed items) @(item)\n util.inspect (item)\n .join \"\\n\"\n\nexports.(script) should output (expected output) =\n assert.equal (chomp (exports.evaluate script (script)), chomp (expected output))\n\nexports.(script) should throw (expected error) =\n failed = false\n \n try\n exports.evaluate script (script)\n failed = true\n catch @(ex)\n assert.equal (ex.to string () , expected error)\n \n if (failed)\n assert.fail \"expected #(expected error)\"\n \n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"280be385a515bdf8f3041a63e293da2e398a6845","subject":"4 space indentation in statements.pogo","message":"4 space indentation in statements.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"lib\/statements.pogo","new_file":"lib\/statements.pogo","new_contents":"_ = require 'underscore'\ncodegen utils = require('.\/codegenUtils')\n\nhas scope (s) =\n if (!s)\n console.log '---------------- NO SCOPE! -----------------'\n throw (new (Error('no scope')))\n\nmodule.exports (cg) = cg.term {\n constructor (statements, expression: false) =\n self.is statements = true\n self.statements = statements\n self.is expression statements = expression\n\n generate statements (statements, buffer, scope, global) =\n has scope (scope)\n\n names defined = _(self.statements).chain ().reduce @(list, statement)\n defs = statement.definitions(scope)\n list.concat(defs)\n [].uniq ().value ()\n\n if (names defined.length > 0)\n _(names defined).each @(name)\n scope.define (name)\n\n if (!global)\n buffer.write ('var ')\n\n codegen utils.write to buffer with delimiter (names defined, ',', buffer) @(item)\n buffer.write (item)\n\n buffer.write (';')\n\n _(statements).each @(statement)\n self.write sub statements for all sub terms (statement, buffer, scope)\n statement.generate java script statement (buffer, scope)\n \n write sub statements (subterm, buffer, scope) =\n if (subterm.is expression statements)\n statements = subterm\n if (statements.statements.length > 0)\n statements.generate statements (statements.statements.slice (0, statements.statements.length - 1), buffer, scope)\n \n write sub statements for all sub terms (statement, buffer, scope) =\n self.write sub statements (statement, buffer, scope)\n\n statement.walk descendants @(subterm)\n self.write sub statements (subterm, buffer, scope)\n not below @(subterm) if\n subterm.is statements && !subterm.is expression statements\n\n generate java script statements (buffer, scope, global) =\n self.generate statements (self.statements, buffer, scope, global)\n\n blockify (parameters, optionalParameters) =\n statements = if (self.is expression statements)\n self.cg.statements ([self])\n else\n self\n\n b = self.cg.block (parameters, statements)\n b.optional parameters = optional parameters\n b\n\n scopify () =\n self.cg.function call (self.cg.block([], self), [])\n\n generate java script statements return (buffer, scope, global) =\n if (self.statements.length > 0)\n self.generate statements (self.statements.slice (0, self.statements.length - 1), buffer, scope, global)\n return statement = self.statements.(self.statements.length - 1)\n self.write sub statements for all sub terms(return statement, buffer, scope)\n return statement.generate java script return (buffer, scope)\n\n generate java script (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script (buffer, scope)\n\n generate java script statement (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script statement (buffer, scope)\n\n generate java script return (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script return (buffer, scope)\n\n definitions (scope) =\n _(self.statements).reduce @(list, statement)\n defs = statement.definitions(scope)\n list.concat (defs)\n []\n}\n","old_contents":"_ = require 'underscore'\ncodegen utils = require('.\/codegenUtils')\n\nhas scope (s) =\n if (!s)\n console.log '---------------- NO SCOPE! -----------------'\n throw (new (Error('no scope')))\n\nmodule.exports (cg) = cg.term {\n constructor (statements, expression: false) =\n self.is statements = true\n self.statements = statements\n self.is expression statements = expression\n\n generate statements (statements, buffer, scope, global) =\n has scope (scope)\n\n names defined = _(self.statements).chain ().reduce @(list, statement)\n defs = statement.definitions(scope)\n list.concat(defs)\n [].uniq ().value ()\n\n if (names defined.length > 0)\n _(names defined).each @(name)\n scope.define (name)\n\n if (!global)\n buffer.write ('var ')\n\n codegen utils.write to buffer with delimiter (names defined, ',', buffer) @(item)\n buffer.write (item)\n\n buffer.write (';')\n\n _(statements).each @(statement)\n self.write sub statements for all sub terms (statement, buffer, scope)\n statement.generate java script statement (buffer, scope)\n \n write sub statements (subterm, buffer, scope) =\n if (subterm.is expression statements)\n statements = subterm\n if (statements.statements.length > 0)\n statements.generate statements (statements.statements.slice (0, statements.statements.length - 1), buffer, scope)\n \n write sub statements for all sub terms (statement, buffer, scope) =\n self.write sub statements (statement, buffer, scope)\n\n statement.walk descendants @(subterm)\n self.write sub statements (subterm, buffer, scope)\n not below @(subterm) if\n subterm.is statements && !subterm.is expression statements\n\n generate java script statements (buffer, scope, global) =\n self.generate statements (self.statements, buffer, scope, global)\n\n blockify (parameters, optionalParameters) =\n statements = if (self.is expression statements)\n self.cg.statements ([self])\n else\n self\n\n b = self.cg.block (parameters, statements)\n b.optional parameters = optional parameters\n b\n\n scopify () =\n self.cg.function call (self.cg.block([], self), [])\n\n generate java script statements return (buffer, scope, global) =\n if (self.statements.length > 0)\n self.generate statements (self.statements.slice (0, self.statements.length - 1), buffer, scope, global)\n return statement = self.statements.(self.statements.length - 1)\n self.write sub statements for all sub terms(return statement, buffer, scope)\n return statement.generate java script return (buffer, scope)\n\n generate java script (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script (buffer, scope)\n\n generate java script statement (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script statement (buffer, scope)\n\n generate java script return (buffer, scope) =\n if (self.statements.length > 0)\n self.statements.(self.statements.length - 1).generate java script return (buffer, scope)\n\n definitions (scope) =\n _(self.statements).reduce @(list, statement)\n defs = statement.definitions(scope)\n list.concat (defs)\n []\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"050735a8b09d688f942ce5a0b7c731eaf5c99590","subject":"basic expression spec using mocha","message":"basic expression spec using mocha\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/basicExpressionSpec.pogo","new_file":"src\/bootstrap\/basicExpressionSpec.pogo","new_contents":"cg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\nassert = require 'assert'\n\ndescribe '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 describe 'has arguments'\n it 'with one variable'\n with terminals [variable] should have arguments\n \n it 'with a block'\n with terminals [block] should have arguments\n \n it 'with name and a block'\n with terminals [id 'c', block] should have arguments\n \n it 'with name, no arguments but a no arg punctuation'\n with terminals [id 'c', no arg punctuation] should have arguments\n \n it 'with name and empty argument list'\n with terminals [id 'c', cg: argument list []] should have arguments\n \n describe 'doesnt have arguments'\n it 'with just an identifier'\n with terminals [id 'a'] should not have arguments\n \n it 'with two identifiers'\n with terminals [id 'a', id 'b'] should not have arguments\n\n describe 'arguments'\n terminals (terminals) should have arguments (arguments) =\n (cg: basic expression (terminals): arguments?) should contain fields (arguments)\n \n it 'single variable'\n terminals [variable] should have arguments [variable]\n \n it 'variable with name'\n terminals [id 'move', variable] should have arguments [variable]\n \n it 'with name and empty argument list'\n terminals [id 'c', cg: argument list []] should have arguments []\n \n it 'block'\n terminals [block] should have arguments [{\n is block\n body {\n statements [{is variable, variable ['a']}]\n }\n }]\n \n it 'block with a parameter'\n terminals [cg: parameters ([cg: variable ['x']]), block] should have arguments [{\n is block\n parameters [{variable ['x']}]\n body {\n statements [{is variable, variable ['a']}]\n }\n }]\n\n describe '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 it 'single name'\n target [id 'car'] doesnt have some parameters\n \n describe 'name and variable'\n it 'has parameters'\n target [id 'car', variable] has some parameters\n\n it 'parameters'\n target [id 'car', variable] has parameters [{variable ['a']}]\n \n describe 'no arg punctuation'\n it 'has parameters'\n target [id 'car', no arg punctuation] has some parameters\n \n it 'parameters'\n target [id 'car', no arg punctuation] has parameters []\n \n describe 'empty argument list'\n it 'has parameters'\n target [id 'car', cg: argument list []] has some parameters\n \n it 'parameters'\n target [id 'car', cg: argument list []] has parameters []\n \n describe 'has name'\n terminals (terminals) should have a name =\n (cg: basic expression (terminals): has name?) should be truthy\n\n it 'with two identifiers'\n terminals [id 'car', id 'idle'] should have a name\n\n describe 'name'\n terminals (terminals) should have name (name) =\n (cg: basic expression (terminals): name?) should contain fields (name)\n \n it 'with two identifiers'\n terminals [id 'car', id 'idle'] should have name ['car', 'idle']\n \n it 'with two identifiers and arg'\n terminals [id 'car', cg: variable ['car'], id 'idle'] should have name ['car', 'idle']\n\n describe 'hash entry'\n hash entry (terminals) should contain fields (f) =\n (cg: basic expression (terminals): hash entry?) should contain fields (f)\n \n it '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 it 'without an argument'\n hash entry [id 'port'] should contain fields {\n is hash entry\n field ['port']\n value = undefined\n }\n \n it '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 describe '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 it '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 it 'without arguments'\n hash entry [id 'port'] should contain fields {\n is hash entry\n field ['port']\n value = undefined\n }\n\n describe '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 it '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 it 'without block'\n assert: (cg: basic expression [id 'port', int 10]: hash entry block?) equal (undefined)\n\n it 'without hash'\n assert: (cg: basic expression [id 'port']: hash entry block?) equal (undefined)\n\n describe 'hash key'\n it 'if string then should return array containing string'\n key = cg: basic expression [string 'port']: hash key?\n \n (key) should contain fields ['port']\n \n it 'if variable then should return array containing string'\n key = cg: basic expression [id 'port']: hash key?\n \n (key) should contain fields ['port']\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 'with name and empty argument list'\n with terminals [id 'c', cg: argument list []] 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 'with name and empty argument list'\n terminals [id 'c', cg: argument list []] should have arguments []\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: parameters ([cg: variable ['x']]), block] should have arguments [{\n is block\n parameters [{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 [{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 'empty argument list'\n spec 'has parameters'\n target [id 'car', cg: argument list []] has some parameters\n \n spec 'parameters'\n target [id 'car', cg: argument list []] 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\n spec 'hash key'\n spec 'if string then should return array containing string'\n key = cg: basic expression [string 'port']: hash key?\n \n (key) should contain fields ['port']\n \n spec 'if variable then should return array containing string'\n key = cg: basic expression [id 'port']: hash key?\n \n (key) should contain fields ['port']\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"8cf4d6d6afe7a46d16417dadf6b8689f6e38cf5c","subject":"formatting","message":"formatting\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/complexExpressionSpec.pogo","new_file":"src\/bootstrap\/complexExpressionSpec.pogo","new_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nint (n) =\n cg: integer (n)\n\nloc = {first line 1, last line 1, first column 7, last column 13}\n\nid (name) = cg: loc (cg: identifier (name), loc)\n\nvariable (name) = cg: variable [name]\n\nparameter (name) = cg: parameter [name]\n\nblock = cg: block [] (cg: statements [variable 'x'])\n\nstring (value) = cg: string (value)\n\nno arg punctuation = cg: no arg suffix?\n\nexpression (e) should contain fields (f) =\n (cg: complex expression (e): expression?) should contain fields (f)\n\nspec 'complex expression'\n spec 'has arguments'\n expression (e) should have arguments =\n (cg: complex expression (e): has arguments?) should be truthy\n \n spec 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments\n \n spec 'with no arg arguments'\n expression [[id 'a', no arg punctuation]] should have arguments\n \n spec 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments\n \n spec 'arguments'\n expression (e) should have arguments (a) =\n (cg: complex expression (e): arguments?) should contain fields (a)\n \n spec 'with arguments in head'\n expression [[id 'a', int 10]] should have arguments [{integer 10}]\n \n spec 'with tail block'\n expression [[id 'a'], [id 'readonly', block]] should have arguments [\n {is block}\n ]\n\n spec 'expression'\n spec 'with just one argument is that argument'\n expression [[int 9]] should contain fields {\n is integer\n integer 9\n }\n\n spec 'all arguments is function call, first argument is function'\n expression [[variable 'z', int 9]] should contain fields {\n is function call\n function {variable ['z']}\n arguments [{integer 9}]\n }\n\n spec 'one argument and call punctuation is function call'\n expression [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {variable ['z']}\n arguments []\n }\n\n spec 'with name is variable'\n expression [[id 'a', id 'variable']] should contain fields {\n is variable\n variable ['a', 'variable']\n }\n\n spec 'with name and argument is function call'\n expression [[id 'a', id 'variable', int 10]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [{integer 10}]\n }\n\n spec 'finds macro'\n expression [[id 'if', variable 'x', block]] should contain fields {\n is if expression\n }\n\n spec 'with name and optional args is function call with optional args'\n expression [[id 'a', id 'variable'], [id 'port', int 80]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments []\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'with block after optional arguments'\n expression [[id 'a', id 'variable'], [id 'port', int 80, block]] should contain fields {\n is function call\n function {is variable, variable ['a', 'variable']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['x']}\n ]\n }\n }\n ]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'object operation -> expression'\n expression (object, operation) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): expression?) should contain fields (fields)\n \n spec 'method call'\n expression (variable 'a') [[id 'method', int 10]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n }\n \n spec 'method call with optional arguments'\n expression (variable 'a') [[id 'method', int 10], [id 'port', int 80]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n optional arguments [{field ['port'], value {integer 80}}]\n }\n\n spec 'index'\n expression (variable 'a') [[int 10]] should contain fields {\n is indexer\n object {variable ['a']}\n indexer {integer 10}\n }\n\n spec 'index call with arguments'\n expression (variable 'a') [[variable 'z', int 10]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments [{integer 10}]\n }\n\n spec 'index call with no arguments'\n expression (variable 'a') [[variable 'z', no arg punctuation]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments []\n }\n\n spec 'field reference'\n expression (variable 'a') [[id 'field']] should contain fields {\n is field reference\n object {variable ['a']}\n name ['field']\n }\n\n spec 'hash entry'\n hash entry (expression) should contain fields (fields) =\n (cg: complex expression (expression): hash entry?) should contain fields (fields)\n \n spec 'if contains one component that is the hash entry'\n hash entry [[id 'field']] should contain fields {\n is hash entry\n field ['field']\n value = undefined\n }\n \n spec 'if contains more than component then semantic error'\n hash entry [[id 'field'], [id 'secondField']] should contain fields {\n is semantic failure\n }\n\n spec 'definition -> hash entry'\n spec 'string key'\n hash entry = cg: complex expression [[string 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec 'identifier key'\n hash entry = cg: complex expression [[id 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec 'can define a method as a hash key'\n hash entry = cg: complex expression [[id 'name', variable 'name']]: definition (cg: variable ['name']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['name']\n value {\n is block\n\n body {\n statements [\n {variable ['name']}\n ]\n }\n\n parameters [{variable ['name']}]\n\n redefines self\n }\n }\n\n spec 'object operation -> definition'\n definition (object, operation, source) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): definition (source): expression?) should contain fields (fields)\n \n spec 'method definition'\n definition (variable 'object') [[id 'method', variable 'x']] (block) should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n }\n }\n \n spec 'method definition without block'\n definition (variable 'object') [[id 'method', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n redefines self\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'field definition'\n definition (variable 'object') [[id 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['x']\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index definition'\n definition (variable 'object') [[variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {variable ['x']}\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index method definition'\n definition (variable 'object') [[cg: string 'xyz', variable 'p']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n {variable ['p']}\n ]\n }\n }\n \n spec 'index method definition with no args'\n definition (variable 'object') [[cg: string 'xyz', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n ]\n }\n }\n\n spec 'definition'\n definition (target, source) should contain fields (fields) =\n (cg: complex expression (target): definition (source): expression?) should contain fields (fields)\n \n spec 'function definition'\n definition [[id 'function', variable 'x']] (block) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n \n spec 'function definition with optional parameter'\n definition [[id 'function', variable 'x'], [id 'port', int 80], [id 'name']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n optional parameters [\n {field ['port'], value {integer 80}}\n {field ['name'], value = undefined}\n ]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition without block'\n definition [[id 'function', variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'no arg function definition'\n definition [[id 'function', no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition with empty param list'\n definition [[id 'function', cg: argument list []]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'variable definition'\n definition [[id 'function']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n\n spec 'variable definition with scope'\n definition [[id 'function']] (cg: block [] (cg: statements [variable 'y'])) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is function call\n function {\n is block\n parameters []\n body {\n statements [{variable ['y']}]\n }\n }\n \n arguments []\n }\n }\n\n spec 'parameter'\n parameter (p) should contain fields (fields) =\n (cg: complex expression (p): expression? : parameter?) should contain fields (fields)\n \n spec 'variable'\n parameter [[id 'a']] should contain fields {variable ['a']}\n","old_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nint (n) =\n cg: integer (n)\n\nloc = {first line 1. last line 1. first column 7. last column 13}\n\nid (name) = cg: loc (cg: identifier (name), loc)\n\nvariable (name) = cg: variable [name]\n\nparameter (name) = cg: parameter [name]\n\nblock = cg: block [] (cg: statements [variable 'x'])\n\nstring (value) = cg: string (value)\n\nno arg punctuation = cg: no arg suffix?\n\nexpression (e) should contain fields (f) =\n (cg: complex expression (e): expression?) should contain fields (f)\n\nspec 'complex expression'\n spec 'has arguments'\n expression (e) should have arguments =\n (cg: complex expression (e): has arguments?) should be truthy\n \n spec 'with arguments in head'\n expression [[id 'a'. int 10]] should have arguments\n \n spec 'with no arg arguments'\n expression [[id 'a'. no arg punctuation]] should have arguments\n \n spec 'with tail block'\n expression [[id 'a']. [id 'readonly'. block]] should have arguments\n \n spec 'arguments'\n expression (e) should have arguments (a) =\n (cg: complex expression (e): arguments?) should contain fields (a)\n \n spec 'with arguments in head'\n expression [[id 'a'. int 10]] should have arguments [{integer 10}]\n \n spec 'with tail block'\n expression [[id 'a']. [id 'readonly'. block]] should have arguments [\n {is block}\n ]\n\n spec 'expression'\n spec 'with just one argument is that argument'\n expression [[int 9]] should contain fields {\n is integer\n integer 9\n }\n\n spec 'all arguments is function call, first argument is function'\n expression [[variable 'z'. int 9]] should contain fields {\n is function call\n function {variable ['z']}\n arguments [{integer 9}]\n }\n\n spec 'one argument and call punctuation is function call'\n expression [[variable 'z'. no arg punctuation]] should contain fields {\n is function call\n function {variable ['z']}\n arguments []\n }\n\n spec 'with name is variable'\n expression [[id 'a'. id 'variable']] should contain fields {\n is variable\n variable ['a'. 'variable']\n }\n\n spec 'with name and argument is function call'\n expression [[id 'a'. id 'variable'. int 10]] should contain fields {\n is function call\n function {is variable. variable ['a'. 'variable']}\n arguments [{integer 10}]\n }\n\n spec 'finds macro'\n expression [[id 'if'. variable 'x'. block]] should contain fields {\n is if expression\n }\n\n spec 'with name and optional args is function call with optional args'\n expression [[id 'a'. id 'variable']. [id 'port'. int 80]] should contain fields {\n is function call\n function {is variable. variable ['a'. 'variable']}\n arguments []\n optional arguments [{field ['port']. value {integer 80}}]\n }\n\n spec 'with block after optional arguments'\n expression [[id 'a'. id 'variable']. [id 'port'. int 80. block]] should contain fields {\n is function call\n function {is variable. variable ['a'. 'variable']}\n arguments [\n {\n is block\n body {\n statements [\n {variable ['x']}\n ]\n }\n }\n ]\n optional arguments [{field ['port']. value {integer 80}}]\n }\n\n spec 'object operation -> expression'\n expression (object, operation) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): expression?) should contain fields (fields)\n \n spec 'method call'\n expression (variable 'a') [[id 'method'. int 10]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n }\n \n spec 'method call with optional arguments'\n expression (variable 'a') [[id 'method'. int 10]. [id 'port'. int 80]] should contain fields {\n is method call\n object {variable ['a']}\n name ['method']\n arguments [{integer 10}]\n optional arguments [{field ['port']. value {integer 80}}]\n }\n\n spec 'index'\n expression (variable 'a') [[int 10]] should contain fields {\n is indexer\n object {variable ['a']}\n indexer {integer 10}\n }\n\n spec 'index call with arguments'\n expression (variable 'a') [[variable 'z'. int 10]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments [{integer 10}]\n }\n\n spec 'index call with no arguments'\n expression (variable 'a') [[variable 'z'. no arg punctuation]] should contain fields {\n is function call\n function {\n is indexer\n object {variable ['a']}\n indexer {variable ['z']}\n }\n \n arguments []\n }\n\n spec 'field reference'\n expression (variable 'a') [[id 'field']] should contain fields {\n is field reference\n object {variable ['a']}\n name ['field']\n }\n\n spec 'hash entry'\n hash entry (expression) should contain fields (fields) =\n (cg: complex expression (expression): hash entry?) should contain fields (fields)\n \n spec 'if contains one component that is the hash entry'\n hash entry [[id 'field']] should contain fields {\n is hash entry\n field ['field']\n value = undefined\n }\n \n spec 'if contains more than component then semantic error'\n hash entry [[id 'field']. [id 'secondField']] should contain fields {\n is semantic failure\n }\n\n spec 'definition -> hash entry'\n spec 'string key'\n hash entry = cg: complex expression [[string 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec 'identifier key'\n hash entry = cg: complex expression [[id 'port']]: definition (cg: variable ['a']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['port']\n value {variable ['a']}\n }\n \n spec 'can define a method as a hash key'\n hash entry = cg: complex expression [[id 'name'. variable 'name']]: definition (cg: variable ['name']): hash entry?\n \n (hashEntry) should contain fields {\n is hash entry\n field ['name']\n value {\n is block\n\n body {\n statements [\n {variable ['name']}\n ]\n }\n\n parameters [{variable ['name']}]\n\n redefines self\n }\n }\n\n spec 'object operation -> definition'\n definition (object, operation, source) should contain fields (fields) =\n (cg: complex expression (operation): object operation (object): definition (source): expression?) should contain fields (fields)\n \n spec 'method definition'\n definition (variable 'object') [[id 'method'. variable 'x']] (block) should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n }\n }\n \n spec 'method definition without block'\n definition (variable 'object') [[id 'method'. variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['method']\n object {variable ['object']}\n }\n \n source {\n is block\n redefines self\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'field definition'\n definition (variable 'object') [[id 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is field reference\n name ['x']\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index definition'\n definition (variable 'object') [[variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {variable ['x']}\n object {variable ['object']}\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n \n spec 'index method definition'\n definition (variable 'object') [[cg: string 'xyz'. variable 'p']] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n {variable ['p']}\n ]\n }\n }\n \n spec 'index method definition with no args'\n definition (variable 'object') [[cg: string 'xyz'. no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is indexer\n indexer {string 'xyz'}\n object {variable ['object']}\n }\n \n source {\n is block\n body {\n statements [\n {\n is variable\n variable ['y']\n }\n ]\n }\n \n parameters [\n ]\n }\n }\n\n spec 'definition'\n definition (target, source) should contain fields (fields) =\n (cg: complex expression (target): definition (source): expression?) should contain fields (fields)\n \n spec 'function definition'\n definition [[id 'function'. variable 'x']] (block) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['x']}]}\n }\n }\n \n spec 'function definition with optional parameter'\n definition [[id 'function'. variable 'x']. [id 'port'. int 80]. [id 'name']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n optional parameters [\n {field ['port']. value {integer 80}}\n {field ['name']. value = undefined}\n ]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition without block'\n definition [[id 'function'. variable 'x']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters [{variable ['x']}]\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'no arg function definition'\n definition [[id 'function'. no arg punctuation]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'function definition with empty param list'\n definition [[id 'function'. cg: argument list []]] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is block\n parameters []\n body {statements [{variable ['y']}]}\n }\n }\n \n spec 'variable definition'\n definition [[id 'function']] (variable 'y') should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is variable\n variable ['y']\n }\n }\n\n spec 'variable definition with scope'\n definition [[id 'function']] (cg: block [] (cg: statements [variable 'y'])) should contain fields {\n is definition\n target {\n is variable\n variable ['function']\n }\n \n source {\n is function call\n function {\n is block\n parameters []\n body {\n statements [{variable ['y']}]\n }\n }\n \n arguments []\n }\n }\n\n spec 'parameter'\n parameter (p) should contain fields (fields) =\n (cg: complex expression (p): expression? : parameter?) should contain fields (fields)\n \n spec 'variable'\n parameter [[id 'a']] should contain fields {variable ['a']}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"8a19742d0e6c02a52b1b02672f293c02da3437db","subject":"test for $","message":"test for $\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parserSpec.pogo","new_file":"src\/bootstrap\/parserSpec.pogo","new_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparser = require '.\/parser.pogo'\nparse = parser: parse\n\nassume @term is module with statements @action =\n if (term: is module)\n action (term: statements)\n else\n throw (new (Error ('expected module, but found ' + term)))\n\nassume @statements has just one statement @action =\n if (statements: statements: length == 1)\n action (statements: statements: 0)\n else\n throw (new (Error ('expected statements to have just one statement, found ' + statements: statements: length)))\n\nexpression @source =\n assume (statements @source) has just one statement #statement\n statement\n\nstatements @source =\n term = parse @source\n assume @term is module with statements #statements\n statements\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 '$'\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 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n spec 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'with indentation'\n (expression '\"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\n two\"}\n ]\n }\n\n spec 'indented string'\n (expression ' \"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'null string'\n (expression '\"\"') should contain fields {\n is interpolated string\n components [\n ]\n }\n\n spec 'with single identifier variable'\n (expression '\"a boat @length meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['length']}\n {string ' meters in length'}\n ]\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 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 function call\n function {\n is block\n body {\n statements [{\n is variable\n variable ['stuff']\n }]\n }\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 '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 '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 '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 [{\n is parameter\n expression {variable ['name']}\n }]\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 self argument'\n (expression 'touch @: file') should contain fields {\n function {variable ['touch']}\n arguments [\n {\n is field reference\n object {variable ['self']}\n name ['file']\n }\n ]\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 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 [{\n is parameter\n expression {variable ['stream']}\n }]\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 {\n is parameter\n expression {variable ['database'. 'connection']}\n }\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 [{\n is parameter\n expression {variable ['x']}\n }]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{\n is parameter\n expression {variable ['y']}\n }]\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 [{is parameter. expression {variable ['x']}}]\n redefines self @false\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n spec 'block with parameter, redefining self'\n (expression '#x => @{x.y}') should contain fields {\n is block\n parameters [{is parameter. expression {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 [{is parameter. expression {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 [{is parameter. expression {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 '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 allow one-line C++ style comments, as in: \/\/ this is a comment'\n spec 'when between lines'\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 '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 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 {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 ['a'. 'identifier'. 51]\n ['b'. 'identifier'. 51]\n [''. undefined. 'eof']\n ]\n","old_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparser = require '.\/parser.pogo'\nparse = parser: parse\n\nassume @term is module with statements @action =\n if (term: is module)\n action (term: statements)\n else\n throw (new (Error ('expected module, but found ' + term)))\n\nassume @statements has just one statement @action =\n if (statements: statements: length == 1)\n action (statements: statements: 0)\n else\n throw (new (Error ('expected statements to have just one statement, found ' + statements: statements: length)))\n\nexpression @source =\n assume (statements @source) has just one statement #statement\n statement\n\nstatements @source =\n term = parse @source\n assume @term is module with statements #statements\n statements\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 '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 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields {\n is string\n string 'a string'\n }\n\n spec 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'with indentation'\n (expression '\"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\n two\"}\n ]\n }\n\n spec 'indented string'\n (expression ' \"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'null string'\n (expression '\"\"') should contain fields {\n is interpolated string\n components [\n ]\n }\n\n spec 'with single identifier variable'\n (expression '\"a boat @length meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['length']}\n {string ' meters in length'}\n ]\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 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 function call\n function {\n is block\n body {\n statements [{\n is variable\n variable ['stuff']\n }]\n }\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 '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 '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 '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 [{\n is parameter\n expression {variable ['name']}\n }]\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 self argument'\n (expression 'touch @: file') should contain fields {\n function {variable ['touch']}\n arguments [\n {\n is field reference\n object {variable ['self']}\n name ['file']\n }\n ]\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 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 [{\n is parameter\n expression {variable ['stream']}\n }]\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 {\n is parameter\n expression {variable ['database'. 'connection']}\n }\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 [{\n is parameter\n expression {variable ['x']}\n }]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{\n is parameter\n expression {variable ['y']}\n }]\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 [{is parameter. expression {variable ['x']}}]\n redefines self @false\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n spec 'block with parameter, redefining self'\n (expression '#x => @{x.y}') should contain fields {\n is block\n parameters [{is parameter. expression {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 [{is parameter. expression {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 [{is parameter. expression {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 '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 allow one-line C++ style comments, as in: \/\/ this is a comment'\n spec 'when between lines'\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 '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 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 {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 ['a'. 'identifier'. 51]\n ['b'. 'identifier'. 51]\n [''. undefined. 'eof']\n ]\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"388f4efa9e240779b3bd9cceec6fd534bc486e7e","subject":"removed unused line","message":"removed unused line\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/indentStack.pogo","new_file":"src\/bootstrap\/indentStack.pogo","new_contents":"require '.\/runtime'\n\nexports: create indent stack = create indent stack! =\n object =>\n :indents = [0]\n :indentation regex = new (RegExp '\\n( *)$')\n :multi new line regex = new (RegExp '\\n *\\n')\n :new line regex = new (RegExp '\\n')\n \n :is @text multi new line =\n :multi new line regex: test @text\n \n : @text has new line? =\n :new line regex: test @text\n \n :indentation (new line) =\n :indentation regex: exec (new line): 1: length\n \n :current indentation? =\n :indents: 0\n \n :set indentation @text =\n if (: @text has new line?)\n :indents:unshift (:indentation @text)\n else\n :indents:unshift (:current indentation?)\n \n :unset indentation! =\n :indents:shift!\n \n :tokens for eof? =\n tokens = []\n indents = :indents: length\n\n while @{indents > 1}\n tokens: push '}'\n indents = indents - 1\n \n tokens: push 'eof'\n \n tokens\n \n \n :tokens for new line @text =\n current indentation = :current indentation?\n indentation = :indentation @text\n \n if (current indentation == indentation)\n ['.']\n else if (current indentation < indentation)\n :indents: unshift @indentation\n ['@{']\n else\n tokens = []\n \n while @{:indents: 0 > indentation}\n tokens: push '}'\n :indents: shift!\n \n if (:is @text multi new line)\n tokens: push '.'\n \n if (:indents: 0 < indentation)\n tokens: push '@{'\n :indents: unshift @indentation\n \n tokens\n","old_contents":"require '.\/runtime'\n\nexports: create indent stack = create indent stack! =\n peek @array = array: (array: length - 1)\n\n object =>\n :indents = [0]\n :indentation regex = new (RegExp '\\n( *)$')\n :multi new line regex = new (RegExp '\\n *\\n')\n :new line regex = new (RegExp '\\n')\n \n :is @text multi new line =\n :multi new line regex: test @text\n \n : @text has new line? =\n :new line regex: test @text\n \n :indentation (new line) =\n :indentation regex: exec (new line): 1: length\n \n :current indentation? =\n :indents: 0\n \n :set indentation @text =\n if (: @text has new line?)\n :indents:unshift (:indentation @text)\n else\n :indents:unshift (:current indentation?)\n \n :unset indentation! =\n :indents:shift!\n \n :tokens for eof? =\n tokens = []\n indents = :indents: length\n\n while @{indents > 1}\n tokens: push '}'\n indents = indents - 1\n \n tokens: push 'eof'\n \n tokens\n \n \n :tokens for new line @text =\n current indentation = :current indentation?\n indentation = :indentation @text\n \n if (current indentation == indentation)\n ['.']\n else if (current indentation < indentation)\n :indents: unshift @indentation\n ['@{']\n else\n tokens = []\n \n while @{:indents: 0 > indentation}\n tokens: push '}'\n :indents: shift!\n \n if (:is @text multi new line)\n tokens: push '.'\n \n if (:indents: 0 < indentation)\n tokens: push '@{'\n :indents: unshift @indentation\n \n tokens\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"b1b4283d51095a838ff0cf081d05521f00ca1387","subject":"refactoring","message":"refactoring\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/fib.pogo","new_file":"src\/samples\/fib.pogo","new_contents":"fib @i =\n if ((i == 0) || (i == 1))\n 1\n else\n fib (i - 1) + fib (i - 2)\n\nprint fib @n = console : log \"fib @n: @(fib @n)\"\n\nprint fib 6\n","old_contents":"fib @i =\n if (i == 0)\n 1\n else if (i == 1)\n 1\n else\n fib (i - 1) + fib (i - 2)\n\nprint fib @n = console : log \"fib @n: @(fib @n)\"\n\nprint fib 6\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"befc1717f1ffd4fb86bf1932ffcde04b6b10cb75","subject":"old term spec no longer needed","message":"old term spec no longer needed\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/oldTermSpec.pogo","new_file":"test\/oldTermSpec.pogo","new_contents":"","old_contents":"cg = require '..\/src\/bootstrap\/codeGenerator\/codeGenerator'.code generator ()\nrequire '.\/assertions'\n\nterms (subterms) ... =\n cg.term =>\n self.terms = subterms\n \n self.subterms 'terms'\n \nbranch (left, right) =\n cg.term =>\n self.left = left\n self.right = right\n \n self.subterms 'left' 'right'\n\nleaf (name) =\n cg.term =>\n self.name = name\n\nlocation (fl, ll, fc, lc) = {\n first_line = fl\n last_line = ll\n first_column = fc\n last_column = lc\n}\n\ndescribe 'old terms'\n it 'subterms'\n term = cg.term =>\n self.a = cg.identifier 'a'\n self.b = cg.identifier 'b'\n self.subterms 'a' 'b'\n \n (term.all subterms ()) should contain fields [\n {identifier 'a'}\n {identifier 'b'}\n ]\n\n describe 'rewriting'\n it 'can rewrite subterms'\n term = cg.term =>\n self.a = cg.identifier 'a'\n self.b = cg.identifier 'b'\n\n self.subterms 'a' 'b'\n\n term.rewrite @(term)\n if (term.is identifier && (term.identifier == 'b'))\n cg.identifier 'z'\n\n (term) should contain fields {\n a {identifier 'a'}\n b {identifier 'z'}\n }\n\n it 'can rewrite subterms in lists'\n term = cg.term =>\n self.things = [cg.identifier 'a', cg.identifier 'b']\n\n self.subterms 'things'\n\n term.rewrite @(term)\n if (term.is identifier && (term.identifier == 'b'))\n cg.identifier 'z'\n\n (term) should contain fields {\n things [{identifier 'a'}, {identifier 'z'}]\n }\n\n it \"doesn't rewrite subterms that aren't objects\"\n term = cg.term =>\n self.things = [cg.identifier 'a', null, nil, 0, 1.1, \"one\", \"\"]\n self.a = 6\n self.b = {x = 5}\n\n self.subterms 'things' 'a' 'b'\n\n terms rewritten = []\n\n term.rewrite @(term)\n terms rewritten.push (term)\n\n (terms rewritten) should contain fields [\n {identifier 'a'}\n {x = 5}\n ]\n\n it \"rewrites lists of lists of terms\"\n term = cg.term =>\n self.things = [cg.identifier 'a', [cg.identifier 'b', [cg.identifier 'c']]]\n\n self.subterms 'things'\n\n term.rewrite @(term)\n if (term.is identifier && (term.identifier == 'c'))\n cg.identifier 'z'\n\n (term) should contain fields {\n things [{identifier 'a'}, [{identifier 'b'}, [{identifier 'z'}]]]\n }\n\n it 'rewrites deep into the graph'\n subterm = cg.term =>\n self.a = cg.identifier 'a'\n self.subterms 'a'\n\n term = cg.term =>\n self.thing = subterm\n self.subterms 'thing'\n\n term.rewrite @(term)\n if (term.is identifier && (term.identifier == 'a'))\n cg.identifier 'z'\n\n (term) should contain fields {\n thing {\n a = {identifier 'z'}\n }\n }\n\n it \"doesn't rewrite beyond limit\"\n subterm = cg.term =>\n self.is subterm = true\n self.a = cg.identifier 'a'\n self.subterms 'a'\n\n term = cg.term =>\n self.thing = subterm\n self.b = cg.identifier 'b'\n self.subterms 'thing' 'b'\n\n term.rewrite (limit (term) if: term.is subterm) @(term)\n if (term.is identifier)\n cg.identifier 'z'\n\n (term) should contain fields {\n thing {\n a = {identifier 'a'}\n }\n b = {identifier 'z'}\n }\n \n describe 'locations'\n it 'location'\n id = cg.loc (cg.identifier 'a', location 1 2 3 4)\n \n (id.location ()) should contain fields {\n first line 1\n last line 2\n first column 3\n last column 4\n }\n \n it \"aggregates locations of subterms if it doesn't have a location itself\"\n term = cg.term\n this.a = cg.loc (cg.identifier 'a', location 1 1 3 10)\n this.b = cg.loc (cg.identifier 'b', location 1 1 2 12)\n this.subterms 'a' 'b'\n\n (term.location ()) should contain fields {\n first line 1\n last line 1\n first column 2\n last column 12\n }\n \n it 'derived term'\n a = cg.loc (leaf 'a', location 1 1 2 8)\n b = cg.loc (leaf 'b', location 2 2 2 8)\n\n term = branch (a, b)\n c = term.derived term (leaf 'c')\n\n (c.location ()) should contain fields {\n first line 1\n last line 2\n first column 2\n last column 8\n }\n\n describe 'depth first walk'\n root = terms (branch (leaf 'a', leaf 'b'), branch (leaf 'c', branch (leaf 'd', leaf 'e')))\n \n it 'walks all terms depth first'\n leaf terms = []\n \n root.walk descendants @(term)\n if (term.name)\n leaf terms.push (term.name)\n\n (leaf terms) should contain fields ['a', 'b', 'c', 'd', 'e']\n\n it \"doesn't walk undefined subterms\"\n term = branch (leaf 'a', undefined)\n \n leaf terms = []\n \n term.walk descendants @(term)\n leaf terms.push (term)\n \n (leaf terms) should contain fields [{name 'a'}]\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"b1ef764283b73242399fdb65d369dd0e030aa097","subject":"printing hosting url on webServer.pogo","message":"printing hosting url on webServer.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/webServer.pogo","new_file":"src\/samples\/webServer.pogo","new_contents":"express = require 'express'\nrequire '..\/bootstrap\/runtime.pogo'\n\nweb server @methods, port 3000 =\n app = express: create server?\n\n app context = object =>\n :get @path @action =\n app: get @path #req #res\n request context = object =>\n :request = req\n :response = res\n :stuff = 'stuff'\n \n res: send (action: call (request context))\n \n methods: call (app context)\n app: listen @port\n console: log \"hosting at http:\/\/localhost:@port\/\"\n\nweb server, port 4567 =>\n :get '\/' =>\n \"Hello World\\n\"\n","old_contents":"express = require 'express'\nrequire '..\/bootstrap\/runtime.pogo'\n\nweb server @methods, port 3000 =\n app = express: create server?\n\n app context = object =>\n :get @path @action =\n app: get @path #req #res\n request context = object =>\n :request = req\n :response = res\n :stuff = 'stuff'\n \n res: send (action: call (request context))\n \n methods: call (app context)\n app: listen @port\n\nweb server, port 4567 =>\n :get '\/' =>\n \"Hello World\\n\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"d9562536044a067c2a2610adccfa7c3dea0db135","subject":"new syntax for preparser.pogo","message":"new syntax for preparser.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/preparser.pogo","new_file":"src\/bootstrap\/preparser.pogo","new_contents":"fs = require 'fs'\nms = require '..\/lib\/memorystream'\nrequire '.\/runtime.pogo'\n\nexports: new line parser = new line parser? =\n last indentation = ''\n indentation pattern = new (RegExp '^( *)(.*)$')\n is empty line pattern = new (RegExp '^\\s*$')\n line ends with bracket pattern = new (RegExp '[{([]\\s*$')\n line starts with bracket pattern = new (RegExp '^\\s*[\\])}]')\n is first line = true\n \n @line is empty =\n is empty line pattern: test @line\n\n @line starts with bracket =\n line starts with bracket pattern: test @line\n\n @line ends with bracket =\n line ends with bracket pattern: test @line\n\n ?line\n if (@line is empty)\n line = {is empty, line @line, is first line (is first line)}\n line\n else\n indentation match = indentation pattern: exec @line\n indentation = indentation match: 1\n code = indentation match: 2\n\n line = {\n line @line\n code @code\n indentation @indentation\n is indent (indentation > last indentation)\n is unindent (indentation < last indentation)\n is new line (indentation == last indentation)\n ends with bracket (@line ends with bracket)\n starts with bracket (@line starts with bracket)\n is first line (is first line)\n }\n\n is first line = false\n last indentation = indentation\n\n line\n\nexports: new indent stack = new indent stack? =\n indents = ['']\n peek @array = array: (array: length - 1)\n\n object =>\n this: indent to @i =\n indents: push @i\n\n this: count unindents while unwinding to @i =\n unindent count = 0\n\n while @{peek @indents != i}\n unindent count = unindent count + 1\n indents: pop!\n\n unindent count\n\nexports: new file parser? =\n ?source\n lines = source: split \"\\n\"\n last line = {no line}\n parse = new line parser?\n\n stream = new (ms: MemoryStream!)\n\n indent stack = new indent stack?\n\n @s plus @a if @c =\n if @c\n s + a\n else\n s\n\n write @l =\n if (not (l: no line))\n stream: write (l: line: replace (new (RegExp '\\\\' 'g')) '\\\\' + \"\\n\")\n\n write @l appending @s =\n if (not (l: no line))\n stream: write (l: line: replace (new (RegExp '\\\\' 'g')) '\\\\' + s + \"\\n\")\n\n concat @s @n times =\n r = ''\n while @{n > 0}\n r = r + s\n n = n - 1\n\n r\n \n for each ?sline in @lines\n line = parse @sline\n\n if (line: is new line)\n write (last line) appending ('' plus '\\.' if (not (((line: is first line) or (last line: ends with bracket)) or (line: starts with bracket))))\n\n if (line: is empty)\n write (last line)\n\n if (line: is indent)\n write (last line) appending ('' plus '\\@{' if (not (last line: ends with bracket)))\n indent stack: indent to (line: indentation)\n\n if (line: is unindent)\n number of unwind brackets = indent stack: count unindents while unwinding to (line: indentation)\n\n if (line: starts with bracket)\n number of unwind brackets = number of unwind brackets - 1\n\n last line ending = concat '\\}' (number of unwind brackets) times\n\n write (last line) appending ((last line ending) plus '\\.' if (last line: is empty))\n\n last line = line\n\n number of unwind brackets = indent stack: count unindents while unwinding to ''\n write (last line) appending (concat '\\}' (number of unwind brackets) times)\n\n stream: to string?\n","old_contents":"fs = require 'fs'\nms = require '..\/lib\/memorystream'\nrequire '.\/runtime.pogo'\n\nexports: new line parser = new line parser? =\n last indentation = ''\n indentation pattern = new (RegExp '^( *)(.*)$')\n is empty line pattern = new (RegExp '^\\\\s*$')\n line ends with bracket pattern = new (RegExp '[{([]\\\\s*$')\n line starts with bracket pattern = new (RegExp '^\\\\s*[\\\\])}]')\n is first line = true\n \n @line is empty =\n is empty line pattern: test @line\n\n @line starts with bracket =\n line starts with bracket pattern: test @line\n\n @line ends with bracket =\n line ends with bracket pattern: test @line\n\n ?line\n if (@line is empty)\n line = #{is empty, line @line, is first line (is first line)}\n line\n else\n indentation match = indentation pattern: exec @line\n indentation = indentation match: 1\n code = indentation match: 2\n\n line = #\n line @line\n code @code\n indentation @indentation\n is indent (indentation > last indentation)\n is unindent (indentation < last indentation)\n is new line (indentation == last indentation)\n ends with bracket (@line ends with bracket)\n starts with bracket (@line starts with bracket)\n is first line (is first line)\n\n is first line = false\n last indentation = indentation\n\n line\n\nexports: new indent stack = new indent stack? =\n indents = ['']\n peek @array = array: (array: length - 1)\n\n object =>\n this: indent to @i =\n indents: push @i\n\n this: count unindents while unwinding to @i =\n unindent count = 0\n\n while {peek @indents != i}\n unindent count = unindent count + 1\n indents: pop!\n\n unindent count\n\nexports: new file parser? =\n ?source\n lines = source: split '\\n'\n last line = #{no line}\n parse = new line parser?\n\n stream = new (ms: MemoryStream!)\n\n indent stack = new indent stack?\n\n @s plus @a if @c =\n if @c\n s + a\n else\n s\n\n write @l =\n if (not (l: no line))\n stream: write (l: line: replace (new (RegExp '\\\\\\\\' 'g')) '\\\\\\\\' + '\\n')\n\n write @l appending @s =\n if (not (l: no line))\n stream: write (l: line: replace (new (RegExp '\\\\\\\\' 'g')) '\\\\\\\\' + s + '\\n')\n\n concat @s @n times =\n r = ''\n while {n > 0}\n r = r + s\n n = n - 1\n\n r\n \n for each ?sline in @lines\n line = parse @sline\n\n if (line: is new line)\n write (last line) appending ('' plus '\\\\.' if (not (((line: is first line) or (last line: ends with bracket)) or (line: starts with bracket))))\n\n if (line: is empty)\n write (last line)\n\n if (line: is indent)\n write (last line) appending ('' plus '\\\\@{' if (not (last line: ends with bracket)))\n indent stack: indent to (line: indentation)\n\n if (line: is unindent)\n number of unwind brackets = indent stack: count unindents while unwinding to (line: indentation)\n\n if (line: starts with bracket)\n number of unwind brackets = number of unwind brackets - 1\n\n last line ending = concat '\\\\}' (number of unwind brackets) times\n\n write (last line) appending ((last line ending) plus '\\\\.' if (last line: is empty))\n\n last line = line\n\n number of unwind brackets = indent stack: count unindents while unwinding to ''\n write (last line) appending (concat '\\\\}' (number of unwind brackets) times)\n\n stream: to string?\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"958368192bb41a04b889b9492c3d0fb763ab5771","subject":"removed failing list parser test","message":"removed failing list parser test\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 '..\/lib\/parser\/parser'\nrequire '.\/parserAssertions'\ncreate terms () = require '..\/lib\/parser\/codeGenerator'.code generator ()\n\ndescribe 'parser'\n terms = nil\n\n before\n terms := create terms ()\n\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 string with empty lines'\n (expression \" 'one\\n\\n two\\n\\n three'\") should contain fields {\n is string\n string \"one\\n\\ntwo\\n\\nthree\"\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 variable\n variable ['stuff']\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 {integer 80}\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 {\n is function call\n function {variable ['print']}\n }\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 splat argument'\n (expression 'copy (files, ..., dir)') should contain fields {\n function {variable ['copy']}\n function arguments [\n {variable ['files']}\n {is splat}\n {variable ['dir']}\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 terms.async statements [\n terms.function call (terms.variable ['delete', 'everything'], [], async: true)\n ].statements.0\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 terms.async statements [\n terms.field reference (\n terms.method call (\n terms.variable ['object']\n ['method']\n []\n async: true\n )\n ['field']\n )\n ].statements.0\n )\n \n it 'parses no argument method with ! and field'\n (expression 'object.method!.field') should contain fields (\n terms.async statements [\n terms.field reference (\n terms.method call (\n terms.variable ['object']\n ['method']\n []\n async: true\n )\n ['field']\n )\n ].statements.0\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 operator\n operator '*'\n\n operator arguments [\n {\n is method call\n object {variable ['o']}\n name ['m']\n method arguments [{integer 2}]\n }\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\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 'definition and assignment'\n it 'definition'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n it 'assignment'\n (expression 'x := y') should contain fields {\n is definition\n is assignment\n target {variable ['x']}\n source {variable ['y']}\n }\n\n it 'assignment on next line'\n (expression \"x =\\n 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 async function'\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 [\n {integer 8}\n ]\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 '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 create parser = require '..\/lib\/parser\/parser'.create parser\n lex parser = create parser (terms: terms)\n tokens = lex 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 terms.async statements [\n terms.variable ['a']\n terms.variable ['b']\n ]\n )\n","old_contents":"require '.\/assertions'\n\nparser = require '..\/lib\/parser\/parser'\nrequire '.\/parserAssertions'\ncreate terms () = require '..\/lib\/parser\/codeGenerator'.code generator ()\n\ndescribe 'parser'\n terms = nil\n\n before\n terms := create terms ()\n\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 string with empty lines'\n (expression \" 'one\\n\\n two\\n\\n three'\") should contain fields {\n is string\n string \"one\\n\\ntwo\\n\\nthree\"\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 variable\n variable ['stuff']\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 'a hash entry'\n (expression '[x, width: 10]') should contain fields {\n is list\n items [\n {variable ['x']}\n {is hash entry, field ['width'], value {integer 10}}\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 {integer 80}\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 {\n is function call\n function {variable ['print']}\n }\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 splat argument'\n (expression 'copy (files, ..., dir)') should contain fields {\n function {variable ['copy']}\n function arguments [\n {variable ['files']}\n {is splat}\n {variable ['dir']}\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 terms.async statements [\n terms.function call (terms.variable ['delete', 'everything'], [], async: true)\n ].statements.0\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 terms.async statements [\n terms.field reference (\n terms.method call (\n terms.variable ['object']\n ['method']\n []\n async: true\n )\n ['field']\n )\n ].statements.0\n )\n \n it 'parses no argument method with ! and field'\n (expression 'object.method!.field') should contain fields (\n terms.async statements [\n terms.field reference (\n terms.method call (\n terms.variable ['object']\n ['method']\n []\n async: true\n )\n ['field']\n )\n ].statements.0\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 operator\n operator '*'\n\n operator arguments [\n {\n is method call\n object {variable ['o']}\n name ['m']\n method arguments [{integer 2}]\n }\n {\n is field reference\n object {variable ['o']}\n name ['x']\n }\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 'definition and assignment'\n it 'definition'\n (expression 'x = y') should contain fields {\n is definition\n target {variable ['x']}\n source {variable ['y']}\n }\n\n it 'assignment'\n (expression 'x := y') should contain fields {\n is definition\n is assignment\n target {variable ['x']}\n source {variable ['y']}\n }\n\n it 'assignment on next line'\n (expression \"x =\\n 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 async function'\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 [\n {integer 8}\n ]\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 '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 create parser = require '..\/lib\/parser\/parser'.create parser\n lex parser = create parser (terms: terms)\n tokens = lex 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 terms.async statements [\n terms.variable ['a']\n terms.variable ['b']\n ]\n )\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6e1483bb4ddbd868eabe5492ab7b5d51dc898e71","subject":"async test for async fn as arg","message":"async test for async fn as arg\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/asyncSpec.pogo","new_file":"test\/asyncSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\n\nasync should output = script.async should output\n\ndescribe 'async'\n it 'can make one async call in statements' @(done)\n async 'f (callback) =\n set timeout\n callback (nil, \"result\")\n 0\n \n x = f ()!\n print (x)\n done ()' should output (\"'result'\", done)\n\n it 'can make one async call as argument to another function' @(done)\n async 'f (callback) =\n set timeout\n callback (nil, \"result\")\n 0\n \n print (f ()!)\n done ()' should output (\"'result'\", done)\n","old_contents":"script = require '.\/scriptAssertions'\n\nasync should output = script.async should output\n\ndescribe 'async'\n it 'can make one async call in statements' @(done)\n async 'f (callback) =\n set timeout\n callback (nil, \"result\")\n 0\n \n x = f ()!\n print (x)\n done ()' should output (\"'result'\", done)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"38ad876f18626fab8f87f63985c79cc64f009cee","subject":"nested functions test","message":"nested functions test\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 'takes and returns JavaScript strings'\n scream it (nice word) =\n scream (nice word, global value)\n\n scream it string = scream it.to string()\n\n transformed = dslify.transform(scream it string, as string: true)\n transformed.should.be.a String\n\n it 'does not rewrite local variables'\n scream it (nice word) =\n opts = 123\n scream (opts, nice word, global value)\n\n scream it string = scream it.to string()\n\n transformed = dslify.transform(scream it string, as string: true)\n transformed.should.not.match(r\/var ;\/g)\n transformed.should.not.match(r\/_dsl.opts\/g)\n transformed.should.not.match(r\/_dsl.niceWord\/g)\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 'does not bind 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 'rewrites global accessors in nested scopes'\n fn (x) =\n a (y) =\n b (z)\n fn (o) = p (o)\n fn (x)\n\n a 123\n\n (fn) rewrites as @(_dsl, x)\n a (y) =\n _dsl.b (_dsl.z)\n fn (o) = _dsl.p (o)\n fn (x)\n\n a 123\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 'takes and returns JavaScript strings'\n scream it (nice word) =\n scream (nice word, global value)\n\n scream it string = scream it.to string()\n\n transformed = dslify.transform(scream it string, as string: true)\n transformed.should.be.a String\n\n it 'does not rewrite local variables'\n scream it (nice word) =\n opts = 123\n scream (opts, nice word, global value)\n\n scream it string = scream it.to string()\n\n transformed = dslify.transform(scream it string, as string: true)\n transformed.should.not.match(r\/var ;\/g)\n transformed.should.not.match(r\/_dsl.opts\/g)\n transformed.should.not.match(r\/_dsl.niceWord\/g)\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 'does not bind 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","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"3b5c8feeb0550c207aab0ed648cfd31c5a86916b","subject":"new syntax for interpolation.pogo","message":"new syntax for interpolation.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/interpolation.pogo","new_file":"src\/bootstrap\/interpolation.pogo","new_contents":"exports.create interpolation () = {\n stack = []\n\n start interpolation () =\n self.stack.unshift {brackets = 0}\n\n open bracket () =\n self.stack.0.brackets = self.stack.0.brackets + 1\n\n close bracket () =\n self.stack.0.brackets = self.stack.0.brackets - 1\n\n finished interpolation () =\n self.stack.0.brackets < 0\n\n stop interpolation () =\n self.stack.shift ()\n\n interpolating () =\n self.stack.length > 0\n}\n","old_contents":"exports: create interpolation! = {\n stack = []\n\n start interpolation! =\n :stack: unshift {brackets = 0}\n\n open bracket! =\n :stack: 0: brackets = :stack: 0: brackets + 1\n\n close bracket! =\n :stack: 0: brackets = :stack: 0: brackets - 1\n\n finished interpolation? =\n :stack: 0: brackets < 0\n\n stop interpolation! =\n :stack: shift!\n\n interpolating? =\n :stack: length > 0\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"8202aaea2fa09d863209664ced51245cc7896ea3","subject":"macrosSpec with new syntax","message":"macrosSpec with new syntax\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/macrosSpec.pogo","new_file":"src\/bootstrap\/macrosSpec.pogo","new_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nexpression @e =\n cg: complex expression [e]: expression?\n\nid @name = cg: identifier @name\nvariable @name = cg: variable [name]\nblock @name = cg: block [] (cg: statements [variable @name])\n\nspec 'macros'\n spec 'if'\n spec 'if'\n (expression [id 'if'. variable 'true'. block 'a']) should contain fields {\n is if expression\n cases [\n {\n condition {variable ['true']}\n action {statements [{variable ['a']}]}\n }\n ]\n }\n \n spec 'if else'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. block 'b']) should contain fields {\n is if expression\n _else {statements [{variable ['b']}]}\n cases [\n {\n condition {variable ['true']}\n action {statements [{variable ['a']}]}\n }\n ]\n }\n \n spec 'if else if'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. id 'if'. variable 'false'. block 'b']) should contain fields {\n is if expression\n _else @undefined\n cases [\n {\n condition {variable ['true']}\n action {statements [{variable ['a']}]}\n }\n {\n condition {variable ['false']}\n action {statements [{variable ['b']}]}\n }\n ]\n }\n \n spec 'if else if else'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. id 'if'. variable 'false'. block 'b'. id 'else'. block 'c']) should contain fields {\n is if expression\n _else {statements [{variable ['c']}]}\n cases [\n {\n condition {variable ['true']}\n action {statements [{variable ['a']}]}\n }\n {\n condition {variable ['false']}\n action {statements [{variable ['b']}]}\n }\n ]\n }\n\n spec 'operators'\n spec 'a + b'\n op = cg: operator expression (cg: complex expression [[id 'a']])\n op: add operator '+' expression (cg: complex expression [[id 'b']])\n \n (op: expression?) should contain fields {\n is operator\n operator '+'\n arguments [\n {variable ['a']}\n {variable ['b']}\n ]\n }\n \n spec 'a + b + c'\n op = cg: operator expression (cg: complex expression [[id 'a']])\n op: add operator '+' expression (cg: complex expression [[id 'b']])\n op: add operator '+' expression (cg: complex expression [[id 'c']])\n \n (op: expression?) should contain fields {\n is operator\n operator '+'\n arguments [\n {variable ['a']}\n {variable ['b']}\n {variable ['c']}\n ]\n }\n","old_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nexpression @e =\n cg: complex expression [e]: expression?\n\nid @name = cg: identifier @name\nvariable @name = cg: variable [name]\nblock @name = cg: block [] (cg: statements [variable @name])\n\nspec 'macros'\n spec 'if'\n spec 'if'\n (expression [id 'if'. variable 'true'. block 'a']) should contain fields #\n is if expression\n cases [\n #\n condition #{variable ['true']}\n action #{statements [#{variable ['a']}]}\n ]\n \n spec 'if else'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. block 'b']) should contain fields #\n is if expression\n _else #{statements [#{variable ['b']}]}\n cases [\n #\n condition #{variable ['true']}\n action #{statements [#{variable ['a']}]}\n ]\n \n spec 'if else if'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. id 'if'. variable 'false'. block 'b']) should contain fields #\n is if expression\n _else @undefined\n cases [\n #\n condition #{variable ['true']}\n action #{statements [#{variable ['a']}]}\n \n #\n condition #{variable ['false']}\n action #{statements [#{variable ['b']}]}\n ]\n \n spec 'if else if else'\n (expression [id 'if'. variable 'true'. block 'a'. id 'else'. id 'if'. variable 'false'. block 'b'. id 'else'. block 'c']) should contain fields #\n is if expression\n _else #{statements [#{variable ['c']}]}\n cases [\n #\n condition #{variable ['true']}\n action #{statements [#{variable ['a']}]}\n \n #\n condition #{variable ['false']}\n action #{statements [#{variable ['b']}]}\n ]\n\n spec 'operators'\n spec 'a + b'\n op = cg: operator expression (cg: complex expression [[id 'a']])\n op: add operator '+' expression (cg: complex expression [[id 'b']])\n \n (op: expression?) should contain fields #\n is operator\n operator '+'\n arguments [\n #{variable ['a']}\n #{variable ['b']}\n ]\n \n spec 'a + b + c'\n op = cg: operator expression (cg: complex expression [[id 'a']])\n op: add operator '+' expression (cg: complex expression [[id 'b']])\n op: add operator '+' expression (cg: complex expression [[id 'c']])\n \n (op: expression?) should contain fields #\n is operator\n operator '+'\n arguments [\n #{variable ['a']}\n #{variable ['b']}\n #{variable ['c']}\n ]\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"ca79375430fee972303962ce67c2d94e729b29a8","subject":"added test for --help","message":"added test for --help\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 '..\/scriptAssertions'\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\nafter (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 after! (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 after! (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","old_contents":"path = require 'path'\nfs = require 'fs'\nscript = require '..\/scriptAssertions'\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\non success callback for (callback) =\n @(on success, always do)\n @(error, args, ...)\n if (error)\n callback (error)\n else\n on success (args, ...)\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, done) =\n expanded command = expand pogo command (command)\n child process.exec (expanded command, {cwd = __dirname}, done)\n\ndescribe 'pogo --compile'\n it 'can compile a script' @(done)\n on success = on success callback for (done)\n\n write file \"toCompile.pogo\" \"console.log 'hi'\" (on success\n run \"pogo -c toCompile.pogo\" (on success @(stdout, stderr)\n stdout.should.equal ''\n stderr.should.equal ''\n\n run \"node toCompile.js\" (on success @(stdout, stderr)\n stdout.should.equal \"hi\\n\"\n stderr.should.equal ''\n\n fs.unlink \"#(__dirname)\/toCompile.pogo\"\n fs.unlink \"#(__dirname)\/toCompile.js\"\n done ()\n )\n )\n )\n\n(n)ms = n\n(n)s = n * 1000\n\nafter (milliseconds, do something) =\n set timeout (do something, milliseconds)\n\ndescribe 'pogo --compile --if-stale'\n it 'compiles a pogo script if the js is missing' @(done)\n on success = on success callback for (done)\n\n fs.unlink \"#(__dirname)\/toCompile.js\"\n write file \"toCompile.pogo\" \"console.log 'hi'\" (on success\n run \"pogo -cs toCompile.pogo\" (on success @(stdout, stderr)\n stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n stderr.should.equal ''\n\n run \"node toCompile.js\" (on success @(stdout, stderr)\n stdout.should.equal \"hi\\n\"\n stderr.should.equal ''\n\n fs.unlink \"#(__dirname)\/toCompile.pogo\"\n fs.unlink \"#(__dirname)\/toCompile.js\"\n done ()\n )\n )\n )\n\n it 'compiles a pogo script if the js is out of date' @(done)\n on success = on success callback for (done)\n\n write file \"toCompile.js\" \"console.log('old')\" (on success\n after (1s)\n write file \"toCompile.pogo\" \"console.log 'new'\" (on success\n run \"pogo -cs toCompile.pogo\" (on success @(stdout, stderr)\n stdout.should.equal \"compiling toCompile.pogo => toCompile.js\\n\"\n stderr.should.equal ''\n\n run \"node toCompile.js\" (on success @(stdout, stderr)\n stdout.should.equal \"new\\n\"\n stderr.should.equal ''\n\n fs.unlink \"#(__dirname)\/toCompile.pogo\"\n fs.unlink \"#(__dirname)\/toCompile.js\"\n done ()\n )\n )\n )\n )\n\n it \"doesn't recompile the js if it the pogo is older\" @(done)\n on success = on success callback for (done)\n\n write file \"toCompile.pogo\" \"console.log 'pogo'\" (on success\n after (1s)\n write file \"toCompile.js\" \"console.log('js')\" (on success\n run \"pogo -cs toCompile.pogo\" (on success @(stdout, stderr)\n stdout.should.equal ''\n stderr.should.equal ''\n\n run \"node toCompile.js\" (on success @(stdout, stderr)\n stdout.should.equal \"js\\n\"\n stderr.should.equal ''\n\n fs.unlink \"#(__dirname)\/toCompile.pogo\"\n fs.unlink \"#(__dirname)\/toCompile.js\"\n done ()\n )\n )\n )\n )\n\ndescribe 'debugging'\n describe '--debug'\n it 'starts remote debugging' @(done)\n on success = on success callback for (done)\n\n write file \"toDebug.pogo\" \"console.log 'bug!'\" (on success\n run 'pogo --debug toDebug.pogo' (on success @(stdout, stderr)\n stderr.should.equal \"debugger listening on port 5858\\n\"\n stdout.should.equal \"bug!\\n\"\n\n done ()\n )\n )\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"3f87302f1c827226edbb8b53aaa6f71cfaf3654c","subject":"fixed failing test","message":"fixed failing test\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parserSpec.pogo","new_file":"src\/bootstrap\/parserSpec.pogo","new_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparse = require '.\/parser.pogo': parse\n\nassume @term is module with statements @action =\n if (term: is module)\n action (term: statements)\n else\n throw (new (Error ('expected module, but found ' + term)))\n\nassume @statements has just one statement @action =\n if (statements: statements: length == 1)\n action (statements: statements: 0)\n else\n throw (new (Error ('expected statements to have just one statement, found ' + statements: statements: length)))\n\nexpression @source =\n term = parse @source\n assume @term is module with statements #statements\n assume @statements has just one statement #s\n s\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 '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 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields {\n is interpolated string\n components [\n {string 'a string'}\n ]\n }\n\n spec 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'with indentation'\n (expression '\"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\n two\"}\n ]\n }\n\n spec 'null string'\n (expression '\"\"') should contain fields {\n is interpolated string\n components [\n ]\n }\n\n spec 'with single identifier variable'\n (expression '\"a boat @length meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['length']}\n {string ' meters in length'}\n ]\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 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 '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 '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 '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. 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 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 self argument'\n (expression 'touch @:file') should contain fields {\n function {variable ['touch']}\n arguments [\n {\n is field reference\n object {variable ['self']}\n name ['file']\n }\n ]\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 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 [{\n is parameter\n expression {variable ['stream']}\n }]\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 {\n is parameter\n expression {variable ['database'. 'connection']}\n }\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 [{\n is parameter\n expression {variable ['x']}\n }]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{\n is parameter\n expression {variable ['y']}\n }]\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 [{is parameter, expression {variable ['x']}}]\n redefines self @false\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n spec 'block with parameter, redefining self'\n (expression '#x => @{x.y}') should contain fields {\n is block\n parameters [{is parameter, expression {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 [{is parameter, expression {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 [{is parameter, expression {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 '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","old_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparse = require '.\/parser.pogo': parse\npreparse = require '.\/preparser.pogo': new file parser?\n\nassume @term is module with statements @action =\n if (term: is module)\n action (term: statements)\n else\n throw (new (Error ('expected module, but found ' + term)))\n\nassume @statements has just one statement @action =\n if (statements: statements: length == 1)\n action (statements: statements: 0)\n else\n throw (new (Error ('expected statements to have just one statement, found ' + statements: statements: length)))\n\nexpression @source =\n term = parse (preparse @source)\n assume @term is module with statements #statements\n assume @statements has just one statement #s\n s\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 '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 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields {\n is interpolated string\n components [\n {string 'a string'}\n ]\n }\n\n spec 'with newline'\n (expression '\"one\\ntwo\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\ntwo\"}\n ]\n }\n\n spec 'with indentation'\n (expression '\"one\\n two\"') should contain fields {\n is interpolated string\n components [\n {string \"one\\n two\"}\n ]\n }\n\n spec 'null string'\n (expression '\"\"') should contain fields {\n is interpolated string\n components [\n ]\n }\n\n spec 'with single identifier variable'\n (expression '\"a boat @length meters in length\"') should contain fields {\n is interpolated string\n components [\n {string 'a boat '}\n {variable ['length']}\n {string ' meters in length'}\n ]\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 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 '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 '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 '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. 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 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 self argument'\n (expression 'touch @:file') should contain fields {\n function {variable ['touch']}\n arguments [\n {\n is field reference\n object {variable ['self']}\n name ['file']\n }\n ]\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 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 [{\n is parameter\n expression {variable ['stream']}\n }]\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 {\n is parameter\n expression {variable ['database'. 'connection']}\n }\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 [{\n is parameter\n expression {variable ['x']}\n }]\n }\n {\n body {statements [{variable ['y']}]}\n parameters [{\n is parameter\n expression {variable ['y']}\n }]\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 [{is parameter, expression {variable ['x']}}]\n redefines self @false\n body {\n statements [\n {variable ['x']}\n {variable ['y']}\n ]\n }\n }\n\n spec 'block with parameter, redefining self'\n (expression '#x => @{x.y}') should contain fields {\n is block\n parameters [{is parameter, expression {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 [{is parameter, expression {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 [{is parameter, expression {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 '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","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"ec325cffbf6f479cff6815c7a18249f185ff763f","subject":"walking terms specs","message":"walking terms specs\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/termSpec.pogo","new_file":"src\/bootstrap\/termSpec.pogo","new_contents":"require 'cupoftea'\ncg = require '..\/lib\/codeGenerator'\ncg new = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nspec 'term'\n spec 'subterms'\n term = cg: term =>\n :a = cg: identifier 'a'\n :b = cg: identifier 'b'\n :subterms 'a' 'b'\n \n (term: all subterms?) should contain fields [\n {identifier 'a'}\n {identifier 'b'}\n ]\n \n spec 'locations'\n location @fl @ll @fc @lc = {\n first_line @fl\n last_line @ll\n first_column @fc\n last_column @lc\n }\n \n spec 'location'\n id = cg new: loc (cg: identifier 'a') (location 1 2 3 4)\n \n (id: location?) should contain fields {\n first line 1\n last line 2\n first column 3\n last column 4\n }\n \n spec 'subterm location'\n term = cg: term\n this: a = cg new: loc (cg: identifier 'a') (location 1 1 3 10)\n this: b = cg new: loc (cg: identifier 'b') (location 1 1 2 12)\n this: subterms 'a' 'b'\n\n (term: location?) should contain fields {\n first line 1\n last line 1\n first column 2\n last column 12\n }\n\n spec 'depth first walk'\n terms @terms ... =\n cg: term =>\n :terms = terms\n \n :subterms 'terms'\n \n branch @left @right =\n cg: term =>\n :left = left\n :right = right\n \n :subterms 'left' 'right'\n \n leaf @name =\n cg: term =>\n :name = name\n \n root = terms (branch (leaf 'a') (leaf 'b')) (branch (leaf 'c') (branch (leaf 'd') (leaf 'e')))\n \n spec 'walks all terms depth first'\n leaf terms = []\n \n root: walk each subterm #term\n if (term: name)\n leaf terms: push (term: name)\n\n (leaf terms) should contain fields ['a'. 'b'. 'c'. 'd'. 'e']\n\n spec \"doesn't walk undefined subterms\"\n term = branch (leaf 'a') @undefined\n \n leaf terms = []\n \n term: walk each subterm #term\n leaf terms: push @term\n \n (leaf terms) should contain fields [{name 'a'}]","old_contents":"require 'cupoftea'\ncg = require '..\/lib\/codeGenerator'\ncg new = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nspec 'term'\n spec 'subterms'\n term = cg: term\n this: a = cg: identifier 'a'\n this: b = cg: identifier 'b'\n this: subterms 'a' 'b'\n \n (term: all subterms?) should contain fields [\n {identifier 'a'}\n {identifier 'b'}\n ]\n \n spec 'locations'\n location @fl @ll @fc @lc = {\n first_line @fl\n last_line @ll\n first_column @fc\n last_column @lc\n }\n \n spec 'location'\n id = cg new: loc (cg: identifier 'a') (location 1 2 3 4)\n \n (id: location?) should contain fields {\n first line 1\n last line 2\n first column 3\n last column 4\n }\n \n spec 'subterm location'\n term = cg: term\n this: a = cg new: loc (cg: identifier 'a') (location 1 1 3 10)\n this: b = cg new: loc (cg: identifier 'b') (location 1 1 2 12)\n this: subterms 'a' 'b'\n\n (term: location?) should contain fields {\n first line 1\n last line 1\n first column 2\n last column 12\n }\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"5e43e2e4d5b21cd84c52d5ff3a8d06472ccf3bb2","subject":"new syntax for indentStack.pogo","message":"new syntax for indentStack.pogo\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/indentStack.pogo","new_file":"src\/bootstrap\/indentStack.pogo","new_contents":"require '.\/runtime'\n\nexports.create indent stack = create indent stack () =\n object =>\n self.indents = [0]\n self.indentation regex = new (RegExp '\\n( *)$')\n self.multi new line regex = new (RegExp '\\n *\\n')\n \n self.is (text) multi new line =\n self.multi new line regex.test (text)\n \n self.(text) has new line () =\n self.indentation regex.test (text)\n \n self.indentation (new line) =\n self.indentation regex.exec (new line).1.length\n \n self.current indentation () =\n self.indents.0\n \n self.set indentation (text) =\n if (self.(text) has new line ())\n self.indents.unshift 'bracket'\n self.indents.unshift (self.indentation (text))\n else\n current = self.current indentation ()\n self.indents.unshift 'bracket'\n self.indents.unshift (current)\n \n self.unset indentation () =\n self.indents.shift ()\n\n tokens = []\n while (self.indents.0 != 'bracket')\n tokens.push '}'\n self.indents.shift ()\n \n self.indents.shift ()\n tokens\n \n self.tokens for eof () =\n tokens = []\n indents = self.indents.length\n\n while (indents > 1)\n tokens.push '}'\n indents = indents - 1\n \n tokens.push 'eof'\n \n tokens\n \n \n self.tokens for new line (text) =\n if (self.(text) has new line ())\n current indentation = self.current indentation ()\n indentation = self.indentation (text)\n \n if (current indentation == indentation)\n [',']\n else if (current indentation < indentation)\n self.indents.unshift (indentation)\n ['@{']\n else\n tokens = []\n \n while (self.indents.0 > indentation)\n tokens.push '}'\n self.indents.shift ()\n \n if (self.is (text) multi new line)\n tokens.push ','\n \n if (self.indents.0 < indentation)\n tokens.push '@{'\n self.indents.unshift (indentation)\n \n tokens\n else\n []\n","old_contents":"require '.\/runtime'\n\nexports: create indent stack = create indent stack! =\n object =>\n :indents = [0]\n :indentation regex = new (RegExp '\\n( *)$')\n :multi new line regex = new (RegExp '\\n *\\n')\n \n :is (text) multi new line =\n :multi new line regex: test (text)\n \n :(text) has new line? =\n :indentation regex: test (text)\n \n :indentation (new line) =\n :indentation regex: exec (new line): 1: length\n \n :current indentation? =\n :indents: 0\n \n :set indentation (text) =\n if (:(text) has new line?)\n :indents:unshift 'bracket'\n :indents:unshift (:indentation (text))\n else\n current = :current indentation?\n :indents:unshift 'bracket'\n :indents:unshift (current)\n \n :unset indentation! =\n :indents: shift!\n\n tokens = []\n while (:indents: 0 != 'bracket')\n tokens: push '}'\n :indents: shift!\n \n :indents: shift!\n tokens\n \n :tokens for eof? =\n tokens = []\n indents = :indents: length\n\n while (indents > 1)\n tokens: push '}'\n indents = indents - 1\n \n tokens: push 'eof'\n \n tokens\n \n \n :tokens for new line (text) =\n if (:(text) has new line?)\n current indentation = :current indentation?\n indentation = :indentation (text)\n \n if (current indentation == indentation)\n [',']\n else if (current indentation < indentation)\n :indents: unshift (indentation)\n ['@{']\n else\n tokens = []\n \n while (:indents: 0 > indentation)\n tokens: push '}'\n :indents: shift!\n \n if (:is (text) multi new line)\n tokens: push ','\n \n if (:indents: 0 < indentation)\n tokens: push '@{'\n :indents: unshift (indentation)\n \n tokens\n else\n []\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6c3d0b515fae9c9455adf06ab07a8a57644ce907","subject":"class","message":"class\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/lib\/class.pogo","new_file":"src\/lib\/class.pogo","new_contents":"window = window || global\n\nwindow.$class (prototype) =\n constructor (args, ...) = =>\n prototype.constructor.apply (self, args)\n nil\n\n constructor.prototype = prototype\n constructor\n\nwindow.$class extending (base constructor, prototype members) =\n prototype constructor () = =>\n for @(field) in (prototype members)\n if (prototype members.has own property (field))\n self.(field) = prototype members.(field)\n \n prototype constructor.prototype = base constructor.prototype\n prototype = new (prototype constructor ())\n constructor (args, ...) = =>\n prototype members.constructor.apply (self, args)\n nil\n \n constructor.prototype = prototype\n constructor\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/lib\/class.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"c2e228b1f680ac9b789d855b562715cda9ee1f3f","subject":"should have added this ages ago","message":"should have added this ages ago\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/unaryOperatorExpressionSpec.pogo","new_file":"src\/bootstrap\/unaryOperatorExpressionSpec.pogo","new_contents":"require 'cupoftea'\ncg = require '.\/codeGenerator\/codeGenerator'\nrequire '.\/assertions.pogo'\n\nspec 'unary operator expression'\n spec 'as expression'\n op expr = cg: new unary operator expression, operator '%', expression {variable ['a']}\n\n (op expr: expression?) should contain fields {\n is method call\n object {variable ['a']}\n name ['%']\n arguments []\n }\n \n spec 'as expression with macro'\n op expr = cg: new unary operator expression, operator '!', expression {variable ['a']}\n \n (op expr: expression?) should contain fields {\n is operator\n operator '!'\n arguments [{variable ['a']}]\n }\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/bootstrap\/unaryOperatorExpressionSpec.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"9e3499afcfd96f6e903c309516b4e99f2ea8125c","subject":"coroutines sample","message":"coroutines sample\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/coroutines.pogo","new_file":"src\/samples\/coroutines.pogo","new_contents":"last yield continuation = nil\nlast result continuation = nil\n\nyield (n, yield continuation) =\n last yield continuation = yield continuation\n last result continuation (nil, n)\n\ncoroutine (block) =\n run (result continuation) =\n last result continuation = result continuation\n\n if (last yield continuation)\n last yield continuation ()\n else\n block\n last yield continuation = nil\n last result continuation = nil\n\nstrings = coroutine\n yield! 1\n yield! 2\n yield! 3\n\nconsole.log (strings!)\nconsole.log (strings!)\nconsole.log (strings!)\nconsole.log 'finished'\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/coroutines.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"aafb3ab7eee56d5dbf7b72ec8aaeaf3974878707","subject":"fork sample","message":"fork sample\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/fork.pogo","new_file":"src\/samples\/fork.pogo","new_contents":"fs = require 'fs'\n\nfork (block) = block @{}\n\nfork\n console.log \"reading contents of file #(__filename)\"\n contents = fs.read file (__filename, 'utf-8')!\n console.log (\"contents of #(__filename):\")\n process.stdout.write (contents)\n\nconsole.log 'processing other stuff'\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/fork.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"2adc07f78a100a7d1d4929aa4d76be4e1191bb66","subject":"continuation example","message":"continuation example\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/continuations.pogo","new_file":"src\/samples\/continuations.pogo","new_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)\nn = n + 1\n\nif (n < 10)\n cont ()\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/continuations.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"8bea3c85a939aae996810594e62545369edf467e","subject":"multi-methods?","message":"multi-methods?\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/multimethods.pogo","new_file":"src\/samples\/multimethods.pogo","new_contents":"require '..\/bootstrap\/runtime'\n\ngeneric method =\n generic method id = 0\n\n with last non nil constructor and index (constructors, block) =\n find last non nil constructor index () =\n for (n = constructors.length - 1, n >= 0, --n)\n if (constructors.(n))\n return (n)\n \n last index = find last non nil constructor index ()\n last constructor = constructors.(last index)\n if (last constructor)\n block (last constructor, last index)\n\n for each constructor index next index in (constructors, block) =\n find next non nil constructor index after (n) =\n for (i = n + 1, i < constructors.length, ++i)\n if (constructors.(i))\n return (i)\n\n for (n = 0, n < constructors.length - 1, ++n)\n constructor = constructors.(n)\n if (constructor)\n block (constructor, n, find next non nil constructor index after (n))\n\n gm () =\n name = \"genericMethod$#(++generic method id)\"\n body = \"var method = void 0;\n for (var n = 0; n < arguments.length; n++) {\n if (method = arguments[n][\\\"#(name)$\\\" + n]) {\n break;\n }\n }\n if (method) {\n return method.apply(void 0, arguments);\n }\n throw new Error(\\\"no such method for arguments\\\")\"\n fn = @new Function (body)\n\n fn.add method (constructors, ... , method) =\n for each constructor @(constructor) index @(index) next index @(next index) in (constructors)\n debugger\n body = \"return arguments[#(next index)][\\\"#(name)$#(next index)\\\"].apply(void 0, arguments);\"\n constructor.prototype.\"#(name)$#(index)\" = @new Function (body)\n\n with last non nil constructor @(constructor) and index @(index) (constructors)\n constructor.prototype.\"#(name)$#(index)\" = method\n \n fn\n\npoint = class {\n to string () = \"(#(self.x), #(self.y))\"\n\n constructor (x, y) =\n self.x = x\n self.y = y\n}\n\ncircle = class {\n to string () = \"#(self.center) radius #(self.radius)\"\n\n constructor (center: center, radius: radius) =\n self.center = center\n self.radius = radius\n}\n\nfile = class {\n to string () = \"`#(self.name)'\"\n\n constructor (name) =\n self.name = name\n}\n\nmove to = generic method ()\n\nmove to.add method @(w) (circle) @(p) (point)\n console.log \"moving circle #(w), to point #(p)\"\n\nmove (@new circle (center: @new point (0, 0), radius: 30)) to (@new point (3, 4))\n\nmove to.add method @(f) (file) @(dir) (nil)\n console.log \"moving file #(f) to dir `#(dir)'\"\n\nmove (@new file 'stuff.txt') to 'dir'\n\nmove to.add method @(a) (nil) @(f) (file)\n console.log \"moving #(a) into file #(f)\"\n\nmove (7) to (@new file '7.txt')\n\n\/\/ is this a good idea?\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/multimethods.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"4e026c6cee604e70cccd0c0ba1c16b25e5169b73","subject":"tests for instanceof","message":"tests for instanceof\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/instanceof.pogo","new_file":"test\/instanceof.pogo","new_contents":"script = require '.\/scriptAssertions.pogo'\n\ndescribe 'instanceof operator (::)'\n it \"returns true when an object is an instance of a constructor\"\n script.'print ([] :: Array)' should output 'true'\n\n it \"returns false when an object is not an instance of a constructor\"\n script.'print ({} :: Array)' should output 'false'\n\n it \"returns true when an object is an instance of a distant constructor\"\n script.'print ([] :: Object)' should output 'true'\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'test\/instanceof.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"551130faf1565718e3773d7e86d146853b37f157","subject":"spec for futures","message":"spec for futures\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"test\/futureSpec.pogo","new_file":"test\/futureSpec.pogo","new_contents":"script = require '.\/scriptAssertions'\n\nasync should output = script.async should output\nshould output = script.should output\n\ndescribe 'futures'\n it 'can defer the result of an asynchronous call'\n async! 'x! = 5\n f = x?\n print (f!)\n done ()' should output '5'\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'test\/futureSpec.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"d3455840b625689b543e35a4080836da6162c032","subject":"start on atoms","message":"start on atoms\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/atoms.pogo","new_file":"src\/bootstrap\/atoms.pogo","new_contents":"require '.\/runtime.pogo'\n\natom prototype = object {\n arguments? = []\n block parameters? = []\n word? = null\n block? = null\n}\n\nexports: atom (members) = object extending (atom prototype) (members)\n\nexports: argument atom (argument) = atom {\n arguments? = [argument]\n}\n\nexports: block atom (block) = atom {\n block? = block\n}\n\nexports: word atom (word) = atom {\n word? = word\n}\n\nexports: block parameters atom (parameters) = atom {\n block parameters? = parameters\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/bootstrap\/atoms.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"6947d02a6841f441dc657b77c99b620832642120","subject":"accounts example from SICP","message":"accounts example from SICP\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/account.pogo","new_file":"src\/samples\/account.pogo","new_contents":"create account, balance = {\n withdraw @amount =\n if (balance >= amount)\n balance = balance - amount\n else\n throw 'insufficient funds'\n\n deposit @amount =\n balance = balance + amount\n \n balance? =\n balance\n}\n\naccount = create account, balance 100\n\naccount: withdraw 30\naccount: deposit 100\nconsole: log (account: balance?)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/account.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"3a8949b761491810da13492a76fb548d232c7ef7","subject":"pogo rewrite of parserSpec","message":"pogo rewrite of parserSpec\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/parserSpec.pogo","new_file":"src\/bootstrap\/parserSpec.pogo","new_contents":"require 'cupoftea'\nrequire '.\/assertions.pogo'\n\nparse = require '.\/parser.pogo': parse\n\nassume @term is module with statements @action =\n if (term: is module)\n action (term: statements)\n else\n throw (new (Error ('expected module, but found ' + term)))\n\nassume @statements has just one statement @action =\n if (statements: statements: length == 1)\n action (statements: statements: 0)\n else\n throw (new (Error ('expected statements to have just one statement, found ' + statements: statements: length)))\n\nexpression @source =\n term = parse @source\n assume @term is module with statements ?statements\n assume @statements has just one statement ?s\n s\n\nspec 'parser'\n spec 'terminals'\n spec 'integer'\n (expression '5') should contain fields #\n integer 5\n\n spec 'float'\n (expression '5.6') should contain fields #\n float 5.6\n\n spec 'variables'\n spec 'simple'\n (expression 'total weight') should contain fields #\n variable ['total'. 'weight']\n \n spec 'strings'\n spec 'simple string'\n (expression '''a string''') should contain fields #\n is string\n string 'a string'\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 spec 'interpolated strings'\n spec 'simple'\n (expression '\"a string\"') should contain fields #\n is interpolated string\n components [\n #{string 'a string'}\n ]\n\n spec 'null string'\n (expression '\"\"') should contain fields #\n is interpolated string\n components [\n ]\n\n spec 'with single identifier variable'\n (expression '\"a boat @length meters in length\"') should contain fields #\n is interpolated string\n components [\n #{string 'a boat '}\n #{variable ['length']}\n #{string ' meters in length'}\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 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 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 spec 'lists'\n spec 'empty'\n (expression '[]') should contain fields #\n is list\n items []\n \n spec 'one item'\n (expression '[1]') should contain fields #\n is list\n items [#{integer 1}]\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 spec 'hashes'\n spec 'empty hash'\n (expression '#{}') should contain fields #\n is hash\n entries []\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 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 spec 'hash with two entries on different lines'\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 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 spec 'function calls'\n spec 'function call'\n (expression 'touch @file') should contain fields #\n function #{variable ['touch']}\n arguments [#{variable ['file']}]\n\n spec 'function call with self argument'\n (expression 'touch @:file') should contain fields #\n function #{variable ['touch']}\n arguments [\n #\n is field reference\n object #{variable ['self']}\n name ['file']\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 spec 'function call with block with parameters'\n (expression 'with file @file ?stream {stream}') should contain fields #\n function #{variable ['with'. 'file']}\n arguments [\n #{variable ['file']}\n #\n body #{statements [#{variable ['stream']}]}\n parameters [#{parameter ['stream']}]\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 [#{parameter ['x']}]\n\n #\n body #{statements [#{variable ['y']}]}\n parameters [#{parameter ['y']}]\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 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 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 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 spec 'field reference'\n (expression 'object: field') should contain fields #\n is field reference\n object #{variable ['object']}\n name ['field']\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 spec 'indexer'\n (expression 'object: @x') should contain fields #\n is indexer\n object #{variable ['object']}\n indexer #{variable ['x']}\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 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 spec 'block with parameter'\n (expression '?x {x.y}') should contain fields #\n is block\n parameters [#{parameter ['x']}]\n redefines self @false\n body #\n statements [\n #{variable ['x']}\n #{variable ['y']}\n ]\n\n spec 'block with parameter, redefining self'\n (expression '?x => {x.y}') should contain fields #\n is block\n parameters [#{parameter ['x']}]\n redefines self @true\n body #\n statements [\n #{variable ['x']}\n #{variable ['y']}\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 name ['+-']\n arguments [\n #\n is field reference\n object #{variable ['o']}\n name ['x']\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 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 [#{parameter ['x']}]\n body #{statements [#{variable ['x']}]}\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 [#{parameter ['x']}]\n optional parameters [#{field ['port'], value #{integer 80}}]\n body #{statements [#{variable ['x']}]}\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 source #{variable ['y']}\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 source #{variable ['y']}\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 name ['z']\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 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 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 name ['z']\n arguments [#{variable ['a']}]\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 source #\n is method call\n object #\n variable ['y']\n\n name ['z']\n arguments [#{variable ['a']}]\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/bootstrap\/parserSpec.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"cf40d9f187d11e3eb93d9e2d5dca8cc0a1363235","subject":"pogo rewrite for assertions","message":"pogo rewrite for assertions\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/bootstrap\/assertions.pogo","new_file":"src\/bootstrap\/assertions.pogo","new_contents":"assert = require 'assert'\n\nglobal: should contain fields = (require '..\/spec\/containsFields'): contains fields\nglobal: @x should equal @y = assert: equal @x @y\nglobal: @x should be truthy = assert: ok @x\nglobal: @x should be falsy = assert: ok (not @x)","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/bootstrap\/assertions.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"8c080f7220976d0202a914f1ef07eca29877fce1","subject":"event emitter example","message":"event emitter example\n","repos":"featurist\/pogo-examples","old_file":"examples\/event_emitter.pogo","new_file":"examples\/event_emitter.pogo","new_contents":"EventEmitter = require('events').EventEmitter\n\nshouter = new (EventEmitter)\n\nshouter.on 'shout'\n console.log \"calm down\"\n\nshouter.emit 'shout'","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/event_emitter.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"} {"commit":"7df7fd203c3c5e83f515b65db5a9a67def8927c3","subject":"async for loop for ls","message":"async for loop for ls\n","repos":"featurist\/pogoscript,featurist\/pogoscript,featurist\/pogoscript","old_file":"src\/samples\/ls.pogo","new_file":"src\/samples\/ls.pogo","new_contents":"fs = require 'fs'\n\nfor each in (list, action) asynchronously (done) =\n outstanding callbacks = 0\n\n for each @(item) in (list)\n outstanding callbacks = outstanding callbacks + 1\n action (item) @(error, result)\n outstanding callbacks = outstanding callbacks - 1\n\n if (outstanding callbacks == 0)\n done (error)\n\nfilenames = fs.readdir! '.'\n\nfor each! @(filename) in (filenames) asynchronously\n stat = fs.stat! (filename)\n console.log \"#(filename): #(stat.size)\"\n\nconsole.log ()\nconsole.log \"#(filenames.length) files in total\"\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/samples\/ls.pogo' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"PogoScript"}