├── vim ├── VERSION ├── vim-stratifiedjs.dist ├── .gitignore ├── stratifiedjs │ ├── ftdetect │ │ └── sjs.vim │ └── ftplugin │ │ └── sjs.vim ├── README.md └── vim-stratifiedjs.xml.template ├── src ├── footers │ ├── __js.txt │ └── compiler-main.sjs ├── headers │ ├── __js.txt │ ├── oni-apollo-node.js.txt │ └── oni-apollo.js.txt ├── deps │ ├── dashdash │ │ ├── apollo-module-footer.txt │ │ ├── LICENSE.txt │ │ ├── apollo-module-header.txt │ │ └── apollo-module-endheader.txt │ ├── jsdiff │ │ ├── apollo-module-footer.txt │ │ └── LICENSE │ ├── numeric │ │ ├── lib │ │ │ ├── .gitignore │ │ │ └── README.txt │ │ ├── tools │ │ │ ├── helloworld.txt │ │ │ ├── deploy │ │ │ │ ├── version.txt │ │ │ │ ├── config.sh │ │ │ │ ├── launchie.scpt │ │ │ │ ├── clean.sh │ │ │ │ ├── stage.sh │ │ │ │ ├── test.sh │ │ │ │ ├── deploy.sh │ │ │ │ ├── make_report.py │ │ │ │ └── selenium_basic.py │ │ │ ├── goog-require.js │ │ │ ├── .htaccess │ │ │ ├── mkdoc.sh │ │ │ ├── Crypto-JS v2.4.0 │ │ │ │ ├── hmac │ │ │ │ │ ├── hmac-min.js │ │ │ │ │ └── hmac.js │ │ │ │ ├── pbkdf2 │ │ │ │ │ ├── pbkdf2-min.js │ │ │ │ │ └── pbkdf2.js │ │ │ │ ├── marc4 │ │ │ │ │ ├── marc4-min.js │ │ │ │ │ └── marc4.js │ │ │ │ ├── sha1 │ │ │ │ │ ├── sha1-min.js │ │ │ │ │ └── sha1.js │ │ │ │ ├── pbkdf2async │ │ │ │ │ └── pbkdf2async-min.js │ │ │ │ ├── sha256 │ │ │ │ │ └── sha256-min.js │ │ │ │ ├── crypto │ │ │ │ │ └── crypto-min.js │ │ │ │ ├── rabbit │ │ │ │ │ └── rabbit-min.js │ │ │ │ ├── blockmodes │ │ │ │ │ └── blockmodes-min.js │ │ │ │ └── crypto-sha1 │ │ │ │ │ └── crypto-sha1.js │ │ │ ├── build.sh │ │ │ ├── mytest.html │ │ │ ├── selenium_links.py │ │ │ ├── jquery.flot.image.min.js │ │ │ ├── workshop_in.php │ │ │ ├── unit2.js │ │ │ └── selenium_tests.py │ │ ├── src │ │ │ ├── apollo-module-footer.txt │ │ │ ├── .project │ │ │ └── .externalToolBuilders │ │ │ │ └── Call builder.sh.launch │ │ ├── favicon.ico │ │ ├── resources │ │ │ ├── forkme.png │ │ │ ├── wait16.gif │ │ │ ├── wait24.gif │ │ │ ├── paperplane.png │ │ │ ├── workshop.png │ │ │ ├── paperplane-small.png │ │ │ └── LICENSE.quadprog │ │ ├── license-icons.txt │ │ ├── .gitignore │ │ ├── license.txt │ │ ├── README.markdown │ │ └── myworker.js │ ├── moment │ │ ├── apollo-module-footer.txt │ │ └── apollo-module-header.txt │ ├── FileSaver.js │ │ ├── apollo-module-footer.txt │ │ ├── LICENSE.md │ │ └── apollo-module-header.txt │ ├── big.js │ │ ├── apollo-module-footer.txt │ │ └── apollo-module-header.txt │ ├── sjcl │ │ ├── apollo-module-footer.txt │ │ ├── core │ │ │ ├── codecHex.js │ │ │ ├── codecBytes.js │ │ │ ├── codecString.js │ │ │ ├── hmac.js │ │ │ ├── pbkdf2.js │ │ │ ├── codecBase64.js │ │ │ └── sjcl.js │ │ └── README │ │ │ ├── INSTALL │ │ │ ├── bsd.txt │ │ │ └── COPYRIGHT │ ├── js-yaml │ │ ├── apollo-module-footer.txt │ │ └── apollo-module-header.txt │ ├── moment-timezone │ │ ├── apollo-module-footer.txt │ │ └── apollo-module-header.txt │ ├── JsonDiffPatch │ │ ├── apollo-module-footer.txt │ │ ├── README.md │ │ └── MIT-LICENSE.txt │ ├── node-terminal │ │ ├── apollo-module-footer.txt │ │ ├── LICENSE │ │ ├── README.md │ │ └── apollo-module-header.txt │ ├── html2canvas │ │ ├── apollo-module-footer.txt │ │ └── apollo-module-header.txt │ ├── marked │ │ ├── apollo-module-footer.txt │ │ └── LICENSE │ ├── README.txt │ ├── sources.txt │ └── fetch-external-deps ├── build │ ├── make-sjs │ ├── config.json │ ├── minify.sjs │ ├── std.sjs │ └── devmode.sjs └── bootstrap │ ├── apollo-bootstrap-common.js │ └── apollo-bootstrap-xbrowser.js ├── test ├── unit │ ├── fixtures │ │ ├── merge_child2.sjs │ │ ├── annotated_child1.sjs │ │ ├── annotated_child2.sjs │ │ ├── dynamic_dependency.sjs │ │ ├── empty.js │ │ ├── module1.js │ │ ├── merge_child1.sjs │ │ ├── testscript.js │ │ ├── sjs-module │ │ ├── app-module.app │ │ ├── child1.sjs │ │ ├── node_modules │ │ │ └── dep1 │ │ │ │ ├── node_modules │ │ │ │ └── dep2 │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ └── index.sjs │ │ ├── slow_exports.sjs │ │ ├── npm_dep.sjs │ │ ├── slow_error.sjs │ │ ├── hostenv_detect.sjs │ │ ├── circular_b.sjs │ │ ├── testmodule.js │ │ ├── circular_a.sjs │ │ ├── utf8.sjs │ │ ├── bundle_parent.sjs │ │ ├── circular_c.sjs │ │ ├── iframe-errors.html │ │ ├── gen_tarfile.py │ │ ├── literal-hub.sjs │ │ ├── stack_js_module.js │ │ └── ast-sample.js │ ├── test │ │ └── fixtures │ │ │ ├── test_12.sjs │ │ │ ├── test_1.sjs │ │ │ └── test_2.sjs │ ├── http-tests.sjs │ ├── sjcl-tests.sjs │ ├── compile │ │ ├── stringify-tests.sjs │ │ ├── minify-tests.sjs │ │ └── deps-tests.sjs │ ├── debug-tests.sjs │ ├── node │ │ ├── deps-tests.sjs │ │ └── buffering_stream.js │ ├── docutil-tests.sjs │ ├── legacy-tests.sjs │ ├── xbrowser │ │ ├── iframe-tests.sjs │ │ └── console-tests.sjs │ ├── regexp-tests.sjs │ ├── bytes-tests.sjs │ └── quasi-tests.sjs ├── integration │ ├── fixtures │ │ ├── jsonp.json │ │ ├── returnQuery.template │ │ ├── bundle_b.sjs │ │ ├── data.json │ │ ├── bundle_a.sjs │ │ ├── returnJsonp.template │ │ ├── data.xml │ │ └── jsonp.js │ ├── documentation-tests.sjs │ ├── helper.sjs │ ├── require-tests.sjs │ └── bundle-tests.sjs ├── run ├── aot │ ├── run.html │ └── perf.html ├── perf.html ├── console.html ├── karma ├── lib │ ├── testContext.sjs │ ├── conductance_ctrl.sjs │ └── testUtil.sjs ├── config.mho ├── _index.txt ├── run.html └── init_checks.sjs ├── .gitignore ├── modules ├── wraplib │ └── sjs-lib-index.txt ├── compile │ ├── sjs-lib-index.txt │ ├── sjs.sjs │ └── ast.sjs ├── crypto │ └── sjs-lib-index.txt ├── xbrowser │ └── sjs-lib-index.txt ├── nodejs │ ├── sjs-lib-index.txt │ ├── rimraf.sjs │ ├── mkdirp.sjs │ └── gzip.sjs ├── test │ ├── sjs-lib-index.txt │ └── std.sjs ├── sjs-lib-index.txt └── #language │ ├── documentation.sjs │ └── metadata.sjs ├── sjs.cmd ├── CHANGELOG.md ├── tools ├── bin │ ├── manual-browser │ └── android-browser ├── api-diff.sh ├── vcs-changes.sjs └── karma │ └── conf.js ├── bower.json ├── emacs └── README.md ├── appveyor.yml ├── package.json ├── examples └── xbrowser │ ├── webworkers_pi │ └── worker_pi.js │ └── sandbox.html ├── .travis.yml └── LICENSE /vim/VERSION: -------------------------------------------------------------------------------- 1 | 0.1.9 -------------------------------------------------------------------------------- /src/footers/__js.txt: -------------------------------------------------------------------------------- 1 | } 2 | -------------------------------------------------------------------------------- /src/headers/__js.txt: -------------------------------------------------------------------------------- 1 | __js { 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/merge_child2.sjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/deps/dashdash/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/deps/jsdiff/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/deps/numeric/lib/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/annotated_child1.sjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/fixtures/annotated_child2.sjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/fixtures/dynamic_dependency.sjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/fixtures/empty.js: -------------------------------------------------------------------------------- 1 | /* ... */ 2 | -------------------------------------------------------------------------------- /vim/vim-stratifiedjs.dist: -------------------------------------------------------------------------------- 1 | stratifiedjs 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | *~ 3 | /node_modules 4 | -------------------------------------------------------------------------------- /modules/wraplib/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @nodoc 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/module1.js: -------------------------------------------------------------------------------- 1 | exports.one = 1; 2 | -------------------------------------------------------------------------------- /vim/.gitignore: -------------------------------------------------------------------------------- 1 | 0inst 2 | /gup 3 | *-local.xml 4 | -------------------------------------------------------------------------------- /src/deps/moment/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/helloworld.txt: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | -------------------------------------------------------------------------------- /src/deps/FileSaver.js/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | -------------------------------------------------------------------------------- /src/deps/big.js/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | 2 | } /* __js */ 3 | -------------------------------------------------------------------------------- /src/deps/sjcl/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | 3 | -------------------------------------------------------------------------------- /test/integration/fixtures/jsonp.json: -------------------------------------------------------------------------------- 1 | cb({"data":"result"}); 2 | -------------------------------------------------------------------------------- /test/integration/fixtures/returnQuery.template: -------------------------------------------------------------------------------- 1 | <%=uri.query%> -------------------------------------------------------------------------------- /test/unit/fixtures/merge_child1.sjs: -------------------------------------------------------------------------------- 1 | require('./child1'); 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/testscript.js: -------------------------------------------------------------------------------- 1 | var testscript_var = 77; 2 | -------------------------------------------------------------------------------- /src/deps/js-yaml/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/deps/moment-timezone/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | -------------------------------------------------------------------------------- /src/deps/numeric/src/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | 3 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/version.txt: -------------------------------------------------------------------------------- 1 | 2012-03-18_22-28-19 2 | -------------------------------------------------------------------------------- /test/integration/fixtures/bundle_b.sjs: -------------------------------------------------------------------------------- 1 | require('./bundle_a'); 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/sjs-module: -------------------------------------------------------------------------------- 1 | exports.ok = -> (hold(0),true); 2 | -------------------------------------------------------------------------------- /src/deps/JsonDiffPatch/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | 3 | -------------------------------------------------------------------------------- /src/deps/node-terminal/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } /* __js */ 2 | 3 | -------------------------------------------------------------------------------- /test/unit/fixtures/app-module.app: -------------------------------------------------------------------------------- 1 | exports.ok = -> (hold(0),true); 2 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/goog-require.js: -------------------------------------------------------------------------------- 1 | goog.require('goog.math.Matrix'); 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/child1.sjs: -------------------------------------------------------------------------------- 1 | exports.child1_function1 = function() { return 42; }; 2 | -------------------------------------------------------------------------------- /test/integration/documentation-tests.sjs: -------------------------------------------------------------------------------- 1 | require('./documentation').testLibrary('sjs:'); 2 | -------------------------------------------------------------------------------- /test/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | here="$(dirname "$0")" 3 | "$here/../sjs" "$here/run.html" "$@" 4 | -------------------------------------------------------------------------------- /test/unit/fixtures/node_modules/dep1/node_modules/dep2/index.js: -------------------------------------------------------------------------------- 1 | exports.name = "dep2"; 2 | 3 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/.htaccess: -------------------------------------------------------------------------------- 1 | AddHandler cgi-script .php .pl .jsp .asp .sh .cgi 2 | Options -ExecCGI 3 | -------------------------------------------------------------------------------- /src/deps/numeric/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/favicon.ico -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/config.sh: -------------------------------------------------------------------------------- 1 | user=ec2-user 2 | server=numericjs.com 3 | webroot='/var/www/html' 4 | -------------------------------------------------------------------------------- /test/integration/fixtures/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "doc": [ 3 | { "value": 1}, 4 | { "value": 2} 5 | ] 6 | } -------------------------------------------------------------------------------- /test/unit/fixtures/node_modules/dep1/index.js: -------------------------------------------------------------------------------- 1 | exports.name = "dep1"; 2 | exports.child = require('dep2'); 3 | -------------------------------------------------------------------------------- /test/unit/fixtures/node_modules/dep1/package.json: -------------------------------------------------------------------------------- 1 | { "name": "dep1", "private": true, "main": "index.js" } 2 | -------------------------------------------------------------------------------- /test/unit/fixtures/slow_exports.sjs: -------------------------------------------------------------------------------- 1 | exports.fast_export = 1; 2 | hold(1000); 3 | exports.slow_export = 1; 4 | -------------------------------------------------------------------------------- /src/deps/JsonDiffPatch/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/JsonDiffPatch/README.md -------------------------------------------------------------------------------- /test/unit/fixtures/npm_dep.sjs: -------------------------------------------------------------------------------- 1 | exports.js = require('nodejs:dep1'); 2 | exports.sjs = require('nodejs:dep1/index.sjs'); 3 | -------------------------------------------------------------------------------- /test/unit/fixtures/slow_error.sjs: -------------------------------------------------------------------------------- 1 | exports.fast_export = 1; 2 | hold(1000); 3 | throw new Error("intentional error"); 4 | -------------------------------------------------------------------------------- /test/integration/fixtures/bundle_a.sjs: -------------------------------------------------------------------------------- 1 | module.setCanonicalId("sjs:test/fixtures/bundle_a"); 2 | exports.ping = -> 'pong'; 3 | -------------------------------------------------------------------------------- /test/unit/fixtures/node_modules/dep1/node_modules/dep2/package.json: -------------------------------------------------------------------------------- 1 | { "name": "dep2", "private": true, "main": "index.js" } 2 | -------------------------------------------------------------------------------- /src/deps/JsonDiffPatch/MIT-LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/JsonDiffPatch/MIT-LICENSE.txt -------------------------------------------------------------------------------- /src/deps/numeric/resources/forkme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/forkme.png -------------------------------------------------------------------------------- /src/deps/numeric/resources/wait16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/wait16.gif -------------------------------------------------------------------------------- /src/deps/numeric/resources/wait24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/wait24.gif -------------------------------------------------------------------------------- /test/integration/fixtures/returnJsonp.template: -------------------------------------------------------------------------------- 1 | <%=uri.params()["callback"]%>({ 2 | "data": "<%=uri.params()["data"]%>" 3 | }); 4 | -------------------------------------------------------------------------------- /sjs.cmd: -------------------------------------------------------------------------------- 1 | @IF EXIST "%~dp0\node.exe" ( 2 | "%~dp0\node.exe" "%~dp0\.\sjs" %* 3 | ) ELSE ( 4 | node "%~dp0\.\sjs" %* 5 | ) 6 | -------------------------------------------------------------------------------- /src/deps/numeric/resources/paperplane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/paperplane.png -------------------------------------------------------------------------------- /src/deps/numeric/resources/workshop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/workshop.png -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/launchie.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/tools/deploy/launchie.scpt -------------------------------------------------------------------------------- /test/integration/fixtures/data.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /modules/compile/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library - Compilation Utilities 2 | @summary SJS compilation utilities 3 | -------------------------------------------------------------------------------- /modules/crypto/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library - Crypto Modules 2 | @summary Crptography-related modules 3 | @nodoc 4 | -------------------------------------------------------------------------------- /modules/xbrowser/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library - Xbrowser Modules 2 | @summary Basic cross-browser functionality 3 | -------------------------------------------------------------------------------- /src/deps/numeric/resources/paperplane-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onilabs/stratifiedjs/HEAD/src/deps/numeric/resources/paperplane-small.png -------------------------------------------------------------------------------- /test/unit/fixtures/hostenv_detect.sjs: -------------------------------------------------------------------------------- 1 | if (require("sjs:sys").hostenv === 'nodejs') { 2 | exports.what = "node"; 3 | } else { 4 | exports.what = "a browser"; 5 | } 6 | -------------------------------------------------------------------------------- /test/unit/test/fixtures/test_12.sjs: -------------------------------------------------------------------------------- 1 | var {context, test, assert} = require("sjs:test/suite"); 2 | test("skipped_1").skip(); 3 | test("skipped_2").skip("reason"); 4 | -------------------------------------------------------------------------------- /modules/nodejs/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library - NodeJS Modules 2 | @summary Collection of [nodejs](http://nodejs.org)-related modules. 3 | -------------------------------------------------------------------------------- /test/unit/fixtures/node_modules/dep1/index.sjs: -------------------------------------------------------------------------------- 1 | exports.name = "dep1"; 2 | exports.child = function() { 3 | hold(100); 4 | return require('nodejs:dep2'); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | This changelog lists the most prominent, developer-visible changes beginning at v1.0.0 2 | 3 | ## Version 1.0.0+ 4 | 5 | * New 'batched' mode for sequence::rollingWindow. 6 | -------------------------------------------------------------------------------- /src/build/make-sjs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | SJS_HOME=`dirname $0`/../.. 5 | pushd $SJS_HOME > /dev/null 6 | npm install 7 | ./sjs ./src/build/buildscript.sjs "$@" 8 | popd > /dev/null 9 | -------------------------------------------------------------------------------- /test/unit/fixtures/circular_b.sjs: -------------------------------------------------------------------------------- 1 | var logging = require('sjs:logging'); 2 | logging.info("circular_b start"); 3 | exports.c_module = require('./circular_c'); 4 | logging.info("circular_b end"); 5 | -------------------------------------------------------------------------------- /test/aot/run.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SJS tests (aot) 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/aot/perf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SJS perf tests (aot) 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/unit/fixtures/testmodule.js: -------------------------------------------------------------------------------- 1 | exports.foo = function(a) { return a+41; }; 2 | exports.bar = function() { return this; }; 3 | exports.dynamicRequire = function() { 4 | return require('./module1').one; 5 | }; 6 | -------------------------------------------------------------------------------- /test/unit/fixtures/circular_a.sjs: -------------------------------------------------------------------------------- 1 | var logging = require('sjs:logging'); 2 | exports.start = 1; 3 | logging.info("circular_a start"); 4 | exports.b_module = require('./circular_b'); 5 | logging.info("circular_a end"); 6 | exports.end = 1; 7 | -------------------------------------------------------------------------------- /test/unit/fixtures/utf8.sjs: -------------------------------------------------------------------------------- 1 | exports.test1 = function() { 2 | return "Unicode character U+00E9 (c3 a9, 'e with acute'): é"; 3 | }; 4 | 5 | exports.test2 = function() { 6 | return "Unicode character U+0192 (c6 92, 'f with hook'): ƒ"; 7 | }; 8 | -------------------------------------------------------------------------------- /test/unit/fixtures/bundle_parent.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | @require ./annotated_child1 3 | @require ./annotated_child2 4 | */ 5 | var dyn = './synamic_dependency'; 6 | @ = require(['./merge_child1', {id: './merge_child2', exclude: 'map'}, dyn, {id:dyn}]); 7 | 8 | -------------------------------------------------------------------------------- /test/unit/fixtures/circular_c.sjs: -------------------------------------------------------------------------------- 1 | var logging = require('sjs:logging'); 2 | var object = require('sjs:object') 3 | 4 | logging.info("circular_c start"); 5 | exports.a_module = require('./circular_a') .. object.clone(); 6 | logging.info("circular_c end"); 7 | -------------------------------------------------------------------------------- /src/deps/html2canvas/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | } 2 | 3 | exports.render = function(elem, opts) { 4 | opts = opts ? clone(opts) : {}; 5 | 6 | waitfor(var rv) { 7 | opts.onrendered = resume; 8 | exports._render(elem, opts); 9 | } 10 | return rv; 11 | } 12 | -------------------------------------------------------------------------------- /src/deps/numeric/lib/README.txt: -------------------------------------------------------------------------------- 1 | Numeric Javascript 2 | ================== 3 | 4 | This directory contains numeric.js and numeric-min.js, obtained from 5 | the source files in the /src sibling directory. 6 | 7 | Please see the /README.markdown and www.numericjs.com for more 8 | information. 9 | -------------------------------------------------------------------------------- /test/unit/http-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, assert, context} = require('sjs:test/suite'); 2 | var http = require('sjs:http'); 3 | 4 | test('node.js request fails on non-http URLs', function() { 5 | assert.raises({message: 'Unsupported protocol: file'}, -> http.request('file:///')); 6 | }).serverOnly(); 7 | -------------------------------------------------------------------------------- /vim/stratifiedjs/ftdetect/sjs.vim: -------------------------------------------------------------------------------- 1 | autocmd BufNewFile,BufRead *.sjs set filetype=sjs 2 | autocmd BufNewFile,BufRead *.app set filetype=sjs 3 | autocmd BufNewFile,BufRead *.api set filetype=sjs 4 | autocmd BufNewFile,BufRead *.gen set filetype=sjs 5 | autocmd BufNewFile,BufRead *.mho set filetype=sjs 6 | -------------------------------------------------------------------------------- /test/integration/helper.sjs: -------------------------------------------------------------------------------- 1 | var suite = require('sjs:test/suite'); 2 | exports.requiresConductance = t -> t.skipIf(suite.isBrowser && document.location.host == 'code.onilabs.com', "requires conductance server"); 3 | exports.isPhantomJS = suite.isBrowser && /PhantomJS/.test(window.navigator.userAgent); 4 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd `dirname $0` 4 | cd ../../.. 5 | numeric=`readlink numeric || echo ""` 6 | staging=`readlink staging || echo ""` 7 | for x in v*; do 8 | if [ "z$x" != "z$numeric" -a "z$x" != "z$staging" ]; then 9 | rm -rf $x 10 | fi 11 | done 12 | -------------------------------------------------------------------------------- /test/unit/sjcl-tests.sjs: -------------------------------------------------------------------------------- 1 | var testUtil = require('../lib/testUtil') 2 | var test = testUtil.test; 3 | var sjcl = require('sjs:sjcl'); 4 | 5 | test('pt == decrypt(encrypt(pt))', 'The quick brown fox', function() { 6 | return sjcl.decrypt('My random key', sjcl.encrypt('My random key', 'The quick brown fox')); 7 | }) -------------------------------------------------------------------------------- /tools/bin/manual-browser: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eux 3 | 4 | url="$1" 5 | my_ip="$(ip addr show dev p6p1 scope global | grep -E -o 'inet [^ /]+' | cut -f 2 -d ' ')" 6 | 7 | echo "${url/localhost/$my_ip}" | pyperclip -i 8 | 9 | notify-send "Karma URL copied to clipboard" 10 | 11 | 12 | cat # wait until killed 13 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stratifiedjs", 3 | "version" : "1.0.0", 4 | "author" : "Oni Labs ", 5 | "homepage" : "http://onilabs.com/stratifiedjs", 6 | "private" : true, 7 | "main": ["stratified.js"], 8 | "ignore": ["src", "test", "examples"], 9 | "dependencies": { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/unit/test/fixtures/test_1.sjs: -------------------------------------------------------------------------------- 1 | var {context, test, assert} = require("sjs:test/suite"); 2 | 3 | context("test_1 context_1", function() { 4 | test("test one", -> null); 5 | test("test two", -> null); 6 | }) 7 | 8 | context("test_1 context_2", function() { 9 | test("test one", -> null); 10 | test("test two", -> null); 11 | }) 12 | -------------------------------------------------------------------------------- /test/unit/test/fixtures/test_2.sjs: -------------------------------------------------------------------------------- 1 | var {context, test, assert} = require("sjs:test/suite"); 2 | 3 | context("test_2 context_1", function() { 4 | test("test one", -> null); 5 | test("test two", -> null); 6 | }) 7 | 8 | context("test_2 context_2", function() { 9 | test("test one", -> null); 10 | test("test two", -> null); 11 | }) 12 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/mkdoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | d0=`dirname $0` 3 | d1=`cd $d0/.. && pwd` 4 | djsdoc=$d1/tools/jsdoc-toolkit 5 | djs=$d1/lib 6 | ddoc=$d1/doc 7 | 8 | cd $djsdoc 9 | echo "JSDoc:" 10 | rm -rf $ddoc 11 | mkdir $ddoc 12 | echo '*' > $ddoc/.gitignore 13 | java -jar jsrun.jar app/run.js -t=templates/jsdoc -d=$ddoc -r -v $djs/numeric.js 14 | -------------------------------------------------------------------------------- /src/footers/compiler-main.sjs: -------------------------------------------------------------------------------- 1 | if (require.main === module) { 2 | var seq = require('sjs:sequence'), fs = require('sjs:nodejs/fs'); 3 | require('sjs:sys').argv() .. seq.each {|f| 4 | var filename = JSON.stringify(f); 5 | fs.readFile(f, 'utf-8') .. exports.compile({globalReturn: true, filename: filename, keeplines: true}) .. console.log 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /modules/test/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library - Test Modules 2 | @summary Automated testing utilities 3 | @desc 4 | For running tests, see [::runner]. For defining test cases, see 5 | [::suite]. 6 | 7 | An appropriate reporter from the [::reporter] module will be used 8 | automatically (you should not need to use it directly). 9 | -------------------------------------------------------------------------------- /src/build/config.json: -------------------------------------------------------------------------------- 1 | { 2 | /* Version number which will be inserted into oni-apollo.js, 3 | oni-apollo-node.js and all files under modules/ and rocket-modules/ : */ 4 | "version" : "1.0.0", 5 | 6 | /* Version number which will be inserted into package.json: */ 7 | "npm": { 8 | "version": "1.0.0", 9 | "private": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/perf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SJS perf tests 5 | 6 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/console.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | StratifiedJS console 5 | 6 | 9 | 10 |
11 |
12 | 13 | -------------------------------------------------------------------------------- /test/unit/compile/stringify-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, context, assert} = require('sjs:test/suite'); 2 | 3 | test("basic", function() { 4 | var compiled = require('sjs:compile/stringify').compile(' 5 | // comment 6 | while(true) { 7 | waitfor { 8 | x("one"); 9 | } and { 10 | y(); // comment 2 11 | } 12 | }'); 13 | assert.eq(compiled, '"while(true){waitfor{x(\\"one\\")}and{y()}}"'); 14 | }) 15 | -------------------------------------------------------------------------------- /modules/test/std.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | @require ./suite 3 | @require ../std 4 | @summary Standard test utilities 5 | @desc 6 | This module exports all symbols from the following modules: 7 | - [./suite::] 8 | - [../std::] 9 | 10 | Typically, test modules will use this module as: 11 | 12 | @ = require('sjs:test/std'); 13 | */ 14 | 'use strict'; 15 | module.exports = require(['./suite', '../std']); 16 | -------------------------------------------------------------------------------- /src/build/minify.sjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env apollo 2 | 3 | function usage() { 4 | process.stdout.write("SJS minifier\n\n"); 5 | process.stdout.write("Usage: minify.sjs source\n\n"); 6 | process.exit(0); 7 | } 8 | 9 | if (process.argv.length !== 2) usage(); 10 | 11 | var src = require('sjs:nodejs/fs').readFile(process.argv[1]); 12 | var compiler = require('../../tmp/c1jsmin.js'); 13 | process.stdout.write(compiler.compile(src, {})); 14 | -------------------------------------------------------------------------------- /test/integration/require-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, assert, context} = require('sjs:test/suite'); 2 | var { isPhantomJS } = require('./helper'); 3 | 4 | test('load module from github', function() { 5 | var data = require('github:/onilabs/stratifiedjs/master/test/unit/fixtures/utf8').test2(); 6 | data.charAt(data.length-1) .. assert.eq('\u0192'); 7 | }).skip('github scheme has been retired').ignoreLeaks('_oni_jsonpcb').skipIf(isPhantomJS, "phantomJS bug?"); 8 | -------------------------------------------------------------------------------- /src/deps/numeric/license-icons.txt: -------------------------------------------------------------------------------- 1 | The spinning wait icons by Andrew B. Davidson were taken from 2 | 3 | http://www.andrewdavidson.com/articles/spinning-wait-icons/ 4 | 5 | The icons are copyrighted. As far as license goes, this is my understanding 6 | from the above web site: 7 | 8 | "These icons are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License." 9 | 10 | Link to license: http://creativecommons.org/licenses/by-nc-sa/2.5/ 11 | -------------------------------------------------------------------------------- /test/unit/fixtures/iframe-errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tools/api-diff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | set -o pipefail 4 | 5 | if [ "$#" -lt 2 ]; then 6 | echo "Usage: $0 old-commit new-commit" >&2 7 | exit 1 8 | fi 9 | 10 | git rev-parse "$1" "$2" 11 | jspp="0install run http://gfxmonk.net/dist/0install/python-js-beautify.xml -i -" 12 | getApi () { 13 | git rev-parse "$1" 14 | git show "$1:modules/sjs-lib-index.json" | $jspp 15 | } 16 | 17 | # differ="$((which gvim || echo "diff --side-by-side") 2>/dev/null)" 18 | gvim -d <(getApi "$1") <(getApi "$2") 19 | -------------------------------------------------------------------------------- /vim/README.md: -------------------------------------------------------------------------------- 1 | # Vim syntax support for [stratified javascript][sjs] 2 | 3 | Based on the builtin Javascript syntax support, with syntax 4 | highlighting for all additional SJS syntax. 5 | 6 | To use with [pathogen][], copy the `stratifiedjs` folder into 7 | `~/.vim/bundle`. If you don't use [pathogen][] (or something 8 | similar), now's a good time to start - but you can always 9 | install manually if you're stubborn. 10 | 11 | [pathogen]: https://github.com/tpope/vim-pathogen 12 | [sjs]: http://onilabs.com/stratifiedjs 13 | -------------------------------------------------------------------------------- /test/integration/fixtures/jsonp.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var scripts = document.getElementsByTagName("script"); 3 | // console.log(scripts); 4 | var cb; 5 | for (var i=scripts.length-1; i>=0; i--) { 6 | var script = scripts[i]; 7 | var src = script.getAttribute("src"); 8 | var match = src && src.match(/.*integration\/fixtures\/jsonp\.js\?callback=([^&$]+)/); 9 | if (match) { 10 | cb = match[1]; 11 | break; 12 | } 13 | } 14 | if (!cb) console.log("no callback found!"); 15 | else eval(cb + "({'data':'result'})"); 16 | })(); 17 | -------------------------------------------------------------------------------- /src/deps/marked/apollo-module-footer.txt: -------------------------------------------------------------------------------- 1 | 2 | module.exports.convert = module.exports; 3 | 4 | } /* __js */ 5 | 6 | if (require.main === module) { 7 | var fs = require('sjs:nodejs/fs'); 8 | var { each } = require('sjs:sequence'); 9 | var args = require('sjs:sys').argv(); 10 | if (args.length > 0) { 11 | args .. each {|f| 12 | fs.readFile(f, 'utf-8') .. module.exports.convert .. console.log; 13 | } 14 | } else { 15 | process.stdin .. require('sjs:nodejs/stream').readAll() .. module.exports.convert .. console.log; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /modules/sjs-lib-index.txt: -------------------------------------------------------------------------------- 1 | @lib StratifiedJS Standard Module Library 2 | @version 1.0.0 3 | @summary Standard collection of modules for the StratifiedJS language 4 | @desc 5 | This Library is the standard collection of modules 6 | accompanying the [StratifiedJS] language. 7 | 8 | 9 | ### Loading `sjs` Modules 10 | 11 | You can load modules from the `sjs` library by using the builtin `sjs:` scheme, e.g.: 12 | 13 | var http = require('sjs:http'); 14 | 15 | See [#language/builtins::require] for more information about the module system. 16 | -------------------------------------------------------------------------------- /test/karma: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -n "$NODE_PATH" ]; then 3 | np="$NODE_PATH:" 4 | else 5 | np=""; 6 | fi 7 | 8 | set -eu 9 | if [ "$#" -lt 0 ]; then 10 | echo "missing an action" 11 | exit 1 12 | fi 13 | action="$1" 14 | shift 15 | base="$(dirname "$(cd "$(dirname "$0")" && pwd)")" 16 | 17 | export NODE_PATH="$np$base/.." # node can't find sjs from its own dir 18 | if [ "$action" = "run" ]; then 19 | "$base/node_modules/.bin/karma-sjs" "$action" tools/karma/conf.js -- "test/run.html" "$@" 20 | else 21 | "$base/node_modules/.bin/karma-sjs" "$action" tools/karma/conf.js "$@" 22 | fi 23 | -------------------------------------------------------------------------------- /emacs/README.md: -------------------------------------------------------------------------------- 1 | # Emacs syntax support for Stratified JavaScript 2 | 3 | js.el is a patched version of the lisp/progmodes/js.el file that comes with Emacs. 4 | 5 | Install by placing something like this in your .emacs file: 6 | 7 | (add-to-list 'load-path "/path/to/this/directory/") 8 | 9 | (add-to-list 'auto-mode-alist '("\\.sjs$" . javascript-mode)) 10 | (add-to-list 'auto-mode-alist '("\\.mho$" . javascript-mode)) 11 | (add-to-list 'auto-mode-alist '("\\.app$" . javascript-mode)) 12 | (add-to-list 'auto-mode-alist '("\\.api$" . javascript-mode)) 13 | 14 | -------------------------------------------------------------------------------- /test/lib/testContext.sjs: -------------------------------------------------------------------------------- 1 | var url = require('sjs:url'); 2 | var testUtil = require('./testUtil'); 3 | 4 | var baseURL = null; 5 | 6 | var setBaseURL = exports.setBaseURL = function(base) { 7 | baseURL = base; 8 | }; 9 | 10 | var getHttpURL = exports.getHttpURL = function(relativePath) { 11 | if(testUtil.isBrowser) return url.normalize(relativePath, url.normalize('../', module.id)); 12 | // node can't resolve relative paths, use server location: 13 | require("assert").notEqual(baseURL, null, "please call testContext.setBaseURL()"); 14 | return url.normalize(relativePath, baseURL); 15 | }; 16 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # http://www.appveyor.com/docs/appveyor-yml 2 | environment: 3 | nodejs_version: "0.10" 4 | NPM: "npm.cmd" 5 | 6 | matrix: 7 | - t: unit 8 | - t: integration 9 | 10 | # - t: unit 11 | # BROWSERS: IE 12 | 13 | # - t: integration 14 | # BROWSERS: IE 15 | 16 | build: off 17 | 18 | test_script: 19 | - cmd: python tools/bin/sjs-tests --show-failed 20 | 21 | matrix: 22 | allow_failures: 23 | - t: integration 24 | - BROWSERS: IE 25 | 26 | branches: 27 | # build only master and release braches 28 | only: 29 | - master 30 | - /^\d+(\.\d+)+$/ 31 | 32 | version: "{build}" 33 | -------------------------------------------------------------------------------- /src/deps/numeric/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Emacs backups 24 | *~ 25 | 26 | # generated files 27 | tools/benchlib.js 28 | 29 | # Logs and databases # 30 | ###################### 31 | *.log 32 | *.sql 33 | *.sqlite 34 | 35 | # OS generated files # 36 | ###################### 37 | .DS_Store 38 | ehthumbs.db 39 | Icon 40 | Thumbs.db 41 | .settings 42 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/hmac/hmac-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var f=Crypto,j=f.util,g=f.charenc,h=g.UTF8,k=g.Binary;f.HMAC=function(b,c,a,d){if(c.constructor==String)c=h.stringToBytes(c);if(a.constructor==String)a=h.stringToBytes(a);if(a.length>b._blocksize*4)a=b(a,{asBytes:true});var i=a.slice(0);a=a.slice(0);for(var e=0;e version.txt 7 | source config.sh 8 | cd ../../.. 9 | rm -f numeric.tar.gz 10 | echo "stage.sh: preparing tarball" 11 | tar cvfz numeric.tar.gz numeric 12 | echo "stage.sh: uploading tarball" 13 | scp numeric.tar.gz $user@$server:./ 14 | echo "stage.sh: linking staging to v$version on $server" 15 | ssh $server -l $user "tar xvfz numeric.tar.gz && mv numeric $webroot/v$version && cd $webroot && rm -f staging && ln -s v$version staging && cd staging/tools && deploy/clean.sh && echo Staging successful." 16 | echo "stage.sh: done" 17 | -------------------------------------------------------------------------------- /tools/vcs-changes.sjs: -------------------------------------------------------------------------------- 1 | @ = require('sjs:std'); 2 | exports.hasOutstandingChanges = function() { 3 | var result = @childProcess.run('git', ['diff', '--ignore-all-space'], {stdio: ['ignore', 'pipe', 'ignore']}); 4 | var output = result.stdout.trim(); 5 | //console.log('[[' + output + ']]'); 6 | return output !== ""; 7 | }; 8 | 9 | exports.dumpDiff = function() { 10 | @childProcess.run('git', ['--no-pager', 'diff', '--ignore-all-space'], {stdio: 'inherit'}); 11 | }; 12 | 13 | exports.assertNoChanges = function() { 14 | if (exports.hasOutstandingChanges()) { 15 | exports.dumpDiff(); 16 | @assert.fail("Uncommitted VCS changes found, see above for diff"); 17 | } 18 | }; 19 | 20 | if(require.main === module) exports.assertNoChanges(); 21 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/pbkdf2/pbkdf2-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var c=Crypto,i=c.util,j=c.charenc,k=j.UTF8,p=j.Binary;c.PBKDF2=function(d,e,l,a){function m(q,r){return c.HMAC(s,r,q,{asBytes:true})}if(d.constructor==String)d=k.stringToBytes(d);if(e.constructor==String)e=k.stringToBytes(e);for(var s=a&&a.hasher||c.SHA1,t=a&&a.iterations||1,b=[],n=1;b.lengthhi!]', function() { 9 | var elem = document.createElement("span"); 10 | elem.innerHTML = "hi!"; 11 | return debug.inspect(elem).toLowerCase(); 12 | }).browserOnly(); 13 | 14 | test("splitting array elements over multiple lines", "[ [ 'aaaaaaaaaaaaaaaaaaaa',\n 'bbbbbbbbbbbbbbbbbbbb',\n 'cccccccccccccccccccc' ] ]", function() { 15 | return debug.inspect([[ 16 | 'aaaaaaaaaaaaaaaaaaaa', 17 | 'bbbbbbbbbbbbbbbbbbbb', 18 | 'cccccccccccccccccccc']]); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stratifiedjs", 3 | "description": "StratifiedJS Framework", 4 | "author": "Oni Labs ", 5 | "version": "1.0.0", 6 | "homepage": "http://onilabs.com/stratifiedjs", 7 | "private": true, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/onilabs/stratifiedjs.git" 11 | }, 12 | "main": "stratified-node.js", 13 | "keywords": [ 14 | "stratifiedjs", 15 | "async", 16 | "language" 17 | ], 18 | "bin": { 19 | "sjs": "sjs" 20 | }, 21 | "engines": { 22 | "node": ">=16.15.0" 23 | }, 24 | "scripts": { 25 | "test": "./sjs test/run.html", 26 | "build": "./src/build/make-sjs" 27 | }, 28 | "dependencies": { 29 | "mkdirp": "^1.0.4", 30 | "rimraf": "^2.7.1" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/unit/fixtures/gen_tarfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os, sys, tarfile, tempfile, shutil 4 | from StringIO import StringIO 5 | 6 | case = sys.argv[1] 7 | 8 | f = StringIO() 9 | tar = tarfile.open(fileobj=f, mode='w') 10 | here = os.path.dirname(__file__) 11 | 12 | sample_file = os.path.join(here, 'utf8.sjs') 13 | 14 | if case == 'relative': 15 | tar.add(sample_file, arcname='../extracted') 16 | 17 | if case == 'absolute': 18 | tar.add(sample_file, arcname='/tmp/extracted') 19 | 20 | if case == 'symlink': 21 | tempdir = tempfile.mkdtemp() 22 | try: 23 | 24 | link = os.path.join(tempdir, 'link') 25 | os.symlink('/tmp', link) 26 | tar.add(link, arcname='link') 27 | tar.add(sample_file, arcname='link/extracted') 28 | finally: 29 | shutil.rmtree(tempdir) 30 | 31 | sys.stdout.write(f.getvalue()) 32 | -------------------------------------------------------------------------------- /vim/stratifiedjs/ftplugin/sjs.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | 3 | if exists("b:did_ftplugin") 4 | finish 5 | endif 6 | let b:did_ftplugin = 1 7 | 8 | let s:cpo_save = &cpo 9 | set cpo-=C 10 | 11 | " Set 'formatoptions' to break comment lines but not other lines, 12 | " " and insert the comment leader when hitting or using "o". 13 | setlocal formatoptions-=t formatoptions+=croql 14 | 15 | " Set completion with CTRL-X CTRL-O to autoloaded function. 16 | if exists('&ofu') 17 | setlocal omnifunc=javascriptcomplete#CompleteJS 18 | endif 19 | 20 | " Set 'comments' to format dashed lists in comments. 21 | setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// 22 | 23 | setlocal commentstring=//%s 24 | 25 | let b:undo_ftplugin = "setl fo< ofu< com< cms<" 26 | 27 | let &cpo = s:cpo_save 28 | unlet s:cpo_save 29 | -------------------------------------------------------------------------------- /examples/xbrowser/webworkers_pi/worker_pi.js: -------------------------------------------------------------------------------- 1 | // long-running calculation of pi: 2 | 3 | function calcPi(digits) { 4 | var d = Math.floor(digits/4+4)*14; 5 | var rv = "", carry = 0, arr = [], sum, i, j; 6 | for (i = d; i > 0; i -= 14) { 7 | sum = 0; 8 | for (j = i; j > 0; --j) { 9 | sum = sum * j + 10000 * (arr[j] === undefined ? 2000 : arr[j]); 10 | arr[j] = sum % (j * 2 - 1); 11 | sum = Math.floor(sum/(j * 2 - 1)); 12 | } 13 | var s = "" + Math.floor(carry + sum/10000); 14 | while (s.length < 4) s = "0" + s; 15 | rv += s; 16 | carry = sum % 10000; 17 | } 18 | if (rv.length > digits) 19 | rv = rv.substr(0,digits); 20 | // pass message with result to caller: 21 | self.postMessage(rv); 22 | self.close(); 23 | } 24 | 25 | self.onmessage = function(e) { calcPi(e.data); }; 26 | -------------------------------------------------------------------------------- /src/deps/numeric/src/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | numeric 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.ui.externaltools.ExternalToolBuilder 15 | auto,full,incremental, 16 | 17 | 18 | LaunchConfigHandle 19 | <project>/.externalToolBuilders/Call builder.sh.launch 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.wst.jsdt.core.jsNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/unit/fixtures/literal-hub.sjs: -------------------------------------------------------------------------------- 1 | // a literal source loader, e.g: 2 | // require("literal:exports.hello = 'HELLO!'"); 3 | require.hubs.push(["literal:", { 4 | loader: function(path, parent, src_loader) { 5 | var compile = require.extensions['sjs']; 6 | var descriptor = { 7 | id: path, 8 | exports: {}, 9 | loaded_from: '[literal string]', 10 | loaded_by: parent, 11 | required_by: {}, 12 | require: require // XXX don't have access to makeRequire outside apollo-sys 13 | }; 14 | //TODO: how much of apollo-sys-common#getNativeModule should 15 | // be rewritten / made available for custom loaders like this? 16 | // (setting require.exports, resolving async compilation, reentrant concerns etc) 17 | compile(path.replace(/^literal:/, ''), descriptor); 18 | return descriptor.exports; 19 | } 20 | }]); 21 | -------------------------------------------------------------------------------- /src/headers/oni-apollo-node.js.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Oni StratifiedJS Runtime 3 | * Server-side NodeJS-based implementation 4 | * 5 | * Version: ' ' 6 | * http://onilabs.com/stratifiedjs 7 | * 8 | * (c) 2011-2022 Oni Labs, http://onilabs.com 9 | * 10 | * This file is licensed under the terms of the GPL v2, see 11 | * http://www.gnu.org/licenses/gpl-2.0.html 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | * THE SOFTWARE. 20 | * 21 | */ 22 | -------------------------------------------------------------------------------- /test/unit/fixtures/stack_js_module.js: -------------------------------------------------------------------------------- 1 | var fail_normally = exports.fail_normally = function fail_normally() { 2 | var f1 = function f1() { 3 | f2(); 4 | }; 5 | 6 | var f2 = function f2() { 7 | f3(); 8 | }; 9 | 10 | var f3 = function f3() { 11 | throw new Error("inner error"); 12 | }; 13 | f1(); 14 | } 15 | 16 | fail_normally.expected_stack_lines = ['fixtures/stack_js_module.js:11', 17 | 'fixtures/stack_js_module.js:7', 18 | 'fixtures/stack_js_module.js:3', 19 | 'fixtures/stack_js_module.js:13']; 20 | 21 | var getStackSummary = function(lvl) { 22 | lvl = lvl || 1; 23 | var lines; 24 | try { 25 | throw new Error("line marker"); 26 | } catch(e) { 27 | lines = e.stack.split('\n'); 28 | lines = lines.slice(lvl); 29 | } 30 | return lines.join('\n < '); 31 | } 32 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/marc4/marc4-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var g=Crypto,i=g.util,j=g.charenc.UTF8,k=g.MARC4={encrypt:function(f,b){var e=j.stringToBytes(f),a=i.randomBytes(16),d=b.constructor==String?g.PBKDF2(b,a,32,{asBytes:true}):b;k._marc4(e,d,1536);return i.bytesToBase64(a.concat(e))},decrypt:function(f,b){var e=i.base64ToBytes(f),a=e.splice(0,16);a=b.constructor==String?g.PBKDF2(b,a,32,{asBytes:true}):b;k._marc4(e,a,1536);return j.bytesToString(e)},_marc4:function(f,b,e){var a,d,c,h;a=0;for(c=[];a<256;a++)c[a]=a;for(d=a=0;a<256;a++){d=(d+ 8 | c[a]+b[a%b.length])%256;h=c[a];c[a]=c[d];c[d]=h}a=d=0;for(b=-e;b 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/deps/sjcl/core/codecBytes.js: -------------------------------------------------------------------------------- 1 | /** @fileOverview Bit array codec implementations. 2 | * 3 | * @author Emily Stark 4 | * @author Mike Hamburg 5 | * @author Dan Boneh 6 | */ 7 | 8 | /** @namespace Arrays of bytes */ 9 | sjcl.codec.bytes = { 10 | /** Convert from a bitArray to an array of bytes. */ 11 | fromBits: function (arr) { 12 | var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp; 13 | for (i=0; i>> 24); 18 | tmp <<= 8; 19 | } 20 | return out; 21 | }, 22 | /** Convert from an array of bytes to a bitArray. */ 23 | toBits: function (bytes) { 24 | var out = [], i, tmp=0; 25 | for (i=0; i>5]|=128<<24-c%32;g[(c+64>>>9<<4)+15]=c;for(c=0;c>>31}k=(h<<5|h>>>27)+i+(a[b]>>>0)+(b<20?(d&e|~d&f)+1518500249:b<40?(d^e^f)+1859775393:b<60?(d&e|d&f|e&f)-1894007588:(d^e^f)-899497514);i=f;f=e;e=d<<30|d>>>2;d=h;h=k}h+=q;d+=r;e+=s;f+=t;i+=u}return[h,d,e,f,i]};j._blocksize=16;j._digestsize=20})(); 9 | -------------------------------------------------------------------------------- /src/deps/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains external source code imported from external projects, from which we build modules in the Standard Module Library (modules/). See /src/build/buildscript.sjs for how we we build modules from the code here. 2 | 3 | In order to simplify code management, we deliberately *don't* use git submodules, but have the relevant source code checked in directly into the stratifiedjs repository. 4 | 5 | To pull in updates from the external projects, you can use the utility 'fetch-external-deps' to replace the directories under deps/ with their corresponding github repositories. After running 'fetch-external-deps' you will be left with a separate git repository in each of the directories under deps/. You can then update from upstream by: 6 | - cd'ing into the relevant directory 7 | - running 'git pull' 8 | - resolving merge conflicts 9 | - updating the base revision in deps/sources.txt 10 | - IMPORTANT: cd back into the stratifiedjs repo (i.e. deps/ or higher) 11 | - commit the changes to the stratifiedjs repo 12 | 13 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd `dirname $0` 3 | source config.sh 4 | version=`cat version.txt` 5 | rm -f wintests.log mactests.txt 6 | echo "test.sh: launching IE unit tests" 7 | cd .. 8 | if [ "x$1" == "x--without-IE" ]; then 9 | echo Skipping IE... 10 | echo Skipped IE > deploy/wintests.log 11 | else 12 | osascript deploy/launchie.scpt 13 | fi 14 | echo "test.sh: checking links on $server/staging" 15 | logfile=deploy/mactests.txt 16 | rm -f $logfile 17 | touch $logfile 18 | tail -f $logfile & 19 | tailpid=$! 20 | python -u selenium_links.py Firefox http://$server/staging/ >> $logfile 2>&1 21 | echo "test.sh: Mac/Chrome unit tests on $server/staging" 22 | python -u selenium_tests.py Chrome http://$server/staging/ >> $logfile 2>&1 23 | echo "test.sh: Mac/Firefox unit tests on $server/staging" 24 | python -u selenium_tests.py Firefox http://$server/staging/ >> $logfile 2>&1 25 | kill -9 $tailpid 26 | echo "test.sh: making report" 27 | cd deploy 28 | python make_report.py $version > report.html 29 | scp report.html $user@$server:$webroot/staging 30 | -------------------------------------------------------------------------------- /test/unit/node/deps-tests.sjs: -------------------------------------------------------------------------------- 1 | // sanity tests of external deps 2 | // 3 | // These deps are tested / released independently, so this 4 | // is just testing that our SJS wrapper works as expected. 5 | 6 | @ = require('sjs:test/std'); 7 | @context(function() { 8 | @ .. @extend(require(['sjs:nodejs/tempfile', 'sjs:nodejs/rimraf', 'sjs:nodejs/mkdirp'])); 9 | @test.beforeEach:: function(s) { 10 | s.root = @TemporaryDir(); 11 | } 12 | 13 | @test.afterEach:: function(s) { 14 | require('sjs:nodejs/child-process').run('rm', ['-rf', s.root], {stdio:'inherit'}); 15 | } 16 | 17 | @test("rimraf", function(s) { 18 | @fs.exists(s.root) .. @assert.ok(); 19 | @fs.mkdir(@path.join(s.root, "dir")); 20 | @fs.writeFile(@path.join(s.root, "dir", "file"), "hello"); 21 | @rimraf(s.root); 22 | @fs.exists(s.root) .. @assert.falsy(); 23 | }) 24 | 25 | @test("mkdirp", function(s) { 26 | @fs.exists(s.root) .. @assert.ok(); 27 | var nested = @path.join(s.root, "dir", "file"); 28 | @mkdirp(nested); 29 | @fs.exists(nested) .. @assert.ok(); 30 | }) 31 | }).serverOnly(); 32 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd `dirname $0` 4 | source config.sh 5 | echo Fetching staging copy... 6 | curl $server/staging/ > staging-copy.html 7 | if grep Loisel staging-copy.html > /dev/null; then 8 | echo "Fetched." 9 | else 10 | echo "Staging copy does not work!" 11 | exit 1 12 | fi 13 | echo Deploying... 14 | ssh $server -l $user "( cd $webroot && [ -L staging ] && foo=\`readlink staging\` && rm -f numeric && ln -s \$foo numeric && rm -f staging && numeric/tools/deploy/clean.sh && echo Deployment successful. ) || echo FAIL: Deployment unsuccessful." 15 | echo Comparing staging copy with live copy... 16 | curl http://$server/ > live-copy.html 17 | if diff staging-copy.html live-copy.html >/dev/null; then 18 | echo Staging and live copies match. 19 | else 20 | echo FAIL: Staging and live copies do not match. 21 | exit 1 22 | fi 23 | rm -f staging-copy.html live-copy.html 24 | echo Testing live links 25 | cd .. 26 | pwd 27 | python ./selenium_links.py Firefox http://$server/ 28 | cd deploy 29 | python selenium_basic.py Firefox http://$server/ 30 | -------------------------------------------------------------------------------- /src/deps/FileSaver.js/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright © 2015 [Eli Grey][1]. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | [1]: http://eligrey.com 10 | -------------------------------------------------------------------------------- /src/deps/sjcl/core/codecString.js: -------------------------------------------------------------------------------- 1 | /** @fileOverview Bit array codec implementations. 2 | * 3 | * @author Emily Stark 4 | * @author Mike Hamburg 5 | * @author Dan Boneh 6 | */ 7 | 8 | /** @namespace UTF-8 strings */ 9 | sjcl.codec.utf8String = { 10 | /** Convert from a bitArray to a UTF-8 string. */ 11 | fromBits: function (arr) { 12 | var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp; 13 | for (i=0; i>> 24); 18 | tmp <<= 8; 19 | } 20 | return decodeURIComponent(escape(out)); 21 | }, 22 | 23 | /** Convert from a UTF-8 string to a bitArray. */ 24 | toBits: function (str) { 25 | str = unescape(encodeURIComponent(str)); 26 | var out = [], i, tmp=0; 27 | for (i=0; i >(logger -t "$syslogname") 8 | BASH_XTRACEFD=3 9 | echo "Tracing to syslog as $syslogname" 10 | unset syslogname 11 | debug() { echo "$@" >&3; } 12 | set -x 13 | 14 | androidExec() { 15 | # ensure that the phone is unlocked 16 | adb shell input keyevent 82 17 | 18 | # clear data so open tabs don't persist 19 | adb shell pm clear com.android.browser 20 | 21 | # start browser 22 | adb shell am start -a android.intent.action.VIEW -n com.android.browser/.BrowserActivity -d "$1" 23 | 24 | # block until trap 25 | cat 26 | } 27 | 28 | 29 | killAndroid() { 30 | # stop the browser 31 | adb shell am force-stop com.android.browser 32 | } 33 | 34 | trap "killAndroid; exit 0" EXIT 35 | 36 | debug "----------------" 37 | 38 | 39 | # http://developer.android.com/tools/devices/emulator.html#emulatornetworking 40 | captureUrl=$1 41 | androidExec ${captureUrl/localhost/10.0.2.2} 42 | -------------------------------------------------------------------------------- /modules/#language/documentation.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | @summary StratifiedJS documentation directives 3 | @type doc 4 | 5 | @desc 6 | Documentation in StratifiedJS is embedded in [./metadata::] comments. 7 | 8 | The current documentation format is not yet fully documented, 9 | so for now you will need to follow by example using the 10 | StratifiedJS standard library source code (there is a [source] 11 | link at the bottom of each documentation page, which may help). 12 | 13 | // TODO: other documentation directives 14 | 15 | 16 | @feature sjs-lib-index.txt 17 | @summary Per-folder metadata 18 | @desc 19 | StratifiedJS' documentation tools use this file to assign 20 | metadata to a folder. In particular tools 21 | will not traverse any directory unless it contains a 22 | `sjs-lib-index.txt` file, to avoid indexing unrelated source code. 23 | 24 | The format of this file is the same as in SJS source code, except the 25 | command delimiters (`/**` and `*\/`) are not required. 26 | 27 | ### Example: 28 | 29 | # sjs-lib-index.txt 30 | @name MyLib 31 | @summary Tools for doing great things 32 | @version 1.0.5 33 | 34 | 35 | */ 36 | -------------------------------------------------------------------------------- /test/unit/compile/minify-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, context, assert} = require('sjs:test/suite'); 2 | 3 | test("basic", function() { 4 | var compiled = require('sjs:compile/minify').compile(" 5 | // comment 6 | while(true) { 7 | waitfor { 8 | x(); 9 | } and { 10 | y(); // comment 2 11 | } 12 | }"); 13 | assert.eq(compiled, 'while(true){waitfor{x()}and{y()}}'); 14 | }) 15 | 16 | test("quasi interpolation", function() { 17 | var compiled = require('sjs:compile/minify').compile('`string ${literal}`;'); 18 | assert.eq(compiled, '`string ${literal}`;'); 19 | }) 20 | 21 | test("string interpolation", function() { 22 | var compiled = require('sjs:compile/minify').compile('"string #{literal}";'); 23 | assert.eq(compiled, '"string #{literal}";'); 24 | }) 25 | 26 | test("altns", function() { 27 | var compiled = require('sjs:compile/minify').compile('@val;'); 28 | assert.eq(compiled, '@val;'); 29 | }) 30 | 31 | test("string interpolation inside __js", function() { 32 | var compiled = require('sjs:compile/minify').compile(' 33 | __js { 34 | print("#{"); 35 | } 36 | '); 37 | assert.eq(compiled, '__js {print("#{");}'); 38 | }).skip("BROKEN"); 39 | -------------------------------------------------------------------------------- /src/deps/node-terminal/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2011 Mattijs Hoitink 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the 'Software'), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/deps/marked/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Christopher Jeffrey (https://github.com/chjj/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /test/unit/compile/deps-tests.sjs: -------------------------------------------------------------------------------- 1 | @ = require('sjs:test/std'); 2 | var { @compile } = require('sjs:compile/deps.js'); 3 | 4 | @context(function() { 5 | var deps = function(input) { 6 | var output = @compile(input); 7 | @logging.info('OUTPUT:', output); 8 | return output .. @map(pair -> pair[1]) .. @flatten; 9 | }; 10 | 11 | @test("trivial requires", function() { 12 | deps("require('mod')") .. @assert.eq(['mod']); 13 | deps("require('mod1'); require('mod2');") .. @assert.eq(['mod1', 'mod2']); 14 | }) 15 | 16 | @test("ignores dynamic require expressions", function() { 17 | // although we'd rather it didn't in trivial cases... 18 | deps("var x='mod1'; require(x);") .. @assert.eq([]); 19 | deps("var x='mod1'; require([x,'mod2']);") .. @assert.eq([undefined, 'mod2']); 20 | }) 21 | 22 | @test("inline require expressions", function() { 23 | deps("require('logging').log(123);") .. @assert.eq(['logging']); 24 | }) 25 | 26 | @test("function argument require expressions", function() { 27 | deps("log(require('mod'));") .. @assert.eq(['mod']); 28 | deps("console.log(require('mod'));") .. @assert.eq(['mod']); 29 | }) 30 | }).serverOnly(); 31 | 32 | -------------------------------------------------------------------------------- /examples/xbrowser/sandbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 34 | 35 | 36 | StratifiedJS Sandbox 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/pbkdf2async/pbkdf2async-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var b=Crypto,n=b.util,o=b.charenc,p=o.UTF8,w=o.Binary;if(!b.nextTick)if(typeof process!="undefined"&&typeof process.nextTick!=="undefined")b.nextTick=process.nextTick;else if(typeof setTimeout!=="undefined")b.nextTick=function(e){setTimeout(e,0)};b.PBKDF2Async=function(e,g,j,x,a){function q(c){if(r){var f=d.length/k._digestsize*l+c;setTimeout(function(){r(Math.round(f/y*100))},0)}}function s(c,f){return b.HMAC(k,f,c,{asBytes:true})}if(e.constructor==String)e=p.stringToBytes(e);if(g.constructor== 8 | String)g=p.stringToBytes(g);var k=a&&a.hasher||b.SHA1,l=a&&a.iterations||1,r=a&&a.onProgressChange,y=Math.ceil(j/k._digestsize)*l,h=b.nextTick,d=[],t=1,u,v;h(u=function(){if(d.length k .. @contains('bundle_a')) .. @assert.ok(keys); 18 | 19 | require('./fixtures/bundle_b'); 20 | 21 | // bundle should be unused, as bundle_a is already loaded 22 | keys .. @any(k -> k .. @contains('bundle_a')) .. @assert.ok(keys); 23 | 24 | // and module should not have been replaced 25 | require.modules[canonicalId] .. @assert.is(initialModule); 26 | }) .. requiresConductance(); 27 | 28 | }).browserOnly(); 29 | -------------------------------------------------------------------------------- /src/deps/numeric/resources/LICENSE.quadprog: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2011 Alberto Santini 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /src/deps/numeric/license.txt: -------------------------------------------------------------------------------- 1 | (See also licenses in the resources subdirectory.) 2 | 3 | Numeric Javascript 4 | Copyright (C) 2011 by Sébastien Loisel 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/deps/big.js/apollo-module-header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * StratifiedJS 'big' module 3 | * 4 | * Part of the Stratified JavaScript Standard Module Library 5 | * Version: 'unstable' 6 | * http://onilabs.com/stratifiedjs 7 | * 8 | * (c) 2023 Oni Labs, http://onilabs.com 9 | * 10 | * 11 | * *************************************************************** 12 | * * DO NOT EDIT marked.sjs - IT IS A GENERATED FILE! * 13 | * * EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN * 14 | * * stratifiedjs/src/build/make-sjs * 15 | * *************************************************************** 16 | * 17 | * 18 | * This file is derived from the "big.js" project 19 | * (https://github.com/MikeMcl/big.js), 20 | * which is available under the terms of the MIT License. 21 | * 22 | */ 23 | 24 | /** 25 | @module big 26 | @summary arbitrary-precision decimal arithmetic (tracking the [big.js library](http://mikemcl.github.io/big.js/)) 27 | @home sjs:big 28 | */ 29 | 30 | /** 31 | @function Big 32 | @summary Constructor as documented at [http://mikemcl.github.io/big.js/] 33 | */ 34 | 35 | /** 36 | turn off docs from this point onwards: 37 | @docsoff 38 | */ 39 | __js { 40 | -------------------------------------------------------------------------------- /src/deps/dashdash/LICENSE.txt: -------------------------------------------------------------------------------- 1 | # This is the MIT license 2 | 3 | Copyright (c) 2013 Trent Mick. All rights reserved. 4 | Copyright (c) 2013 Joyent Inc. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | if [ -f buildpid.log ]; then 3 | buildpid=`cat buildpid.log` 4 | kill -9 $buildpid || true 5 | rm -f buildpid.log 6 | fi 7 | echo $$ > buildpid.log 8 | if [ -f nodepid.log ]; then 9 | nodepid=`cat nodepid.log` 10 | kill -9 $nodepid || true 11 | rm -f nodepid.log 12 | fi 13 | ver=`grep 'numeric.version.*=.*"' ../src/numeric.js | sed 's/numeric.version[ =]*"\([0-9.]*\)".*/\1/'` 14 | echo "Version is $ver" 15 | cat ../src/numeric.js ../src/seedrandom.js ../src/quadprog.js ../src/svd.js > ../lib/numeric-$ver.js 16 | uglifyjs ../lib/numeric-$ver.js > ../lib/numeric-$ver.min.js 17 | cat jquery-1.7.1.min.js jquery.flot.min.js 'Crypto-JS v2.4.0/crypto/crypto-min.js' 'Crypto-JS v2.4.0/crypto-sha256/crypto-sha256.js' json2.js > megalib.js 18 | echo "" | cat closurelib.js sylvester.js - ../lib/numeric-$ver.min.js jquery-1.7.1.min.js jquery.flot.min.js > benchlib.js 19 | cp ../src/documentation.html .. 20 | rm -f ../workshop.php 21 | sed -e '/WORKSHOPHTML/r workshop.html' -e 's/WORKSHOPHTML//' -e "s/VERSIONSTRING/$ver/" workshop_in.php > ../workshop.php 22 | cd .. 23 | runjs=`which d8 || which jsdb` 24 | echo Using $runjs 25 | $runjs ./tools/unit2.js & 26 | echo $! > tools/nodepid.log 27 | cd tools 28 | wait 29 | rm -f buildpid.log 30 | rm -f nodepid.log 31 | 32 | -------------------------------------------------------------------------------- /test/unit/docutil-tests.sjs: -------------------------------------------------------------------------------- 1 | @ = require(['sjs:test/suite']); 2 | @docutil = require('sjs:docutil'); 3 | 4 | @context('parsing comments', function() { 5 | @test('only extracts fields that are aligned with the initial indent level', function() { 6 | @docutil.extractDocFields([" 7 | @key val 8 | @desc 9 | A description involving indented docs: 10 | @indented 11 | @key2 val2 12 | "]) .. @assert.eq([ 13 | ['key', 'val'], 14 | ['desc', 'A description involving indented docs:\n @indented',], 15 | ['key2', 'val2'], 16 | ]); 17 | }) 18 | 19 | @test('escaping of end-comments', function() { 20 | @docutil.extractDocComments("/**comment with multiple *\\/ end (*\\/) bits*/") 21 | .. @assert.eq(["comment with multiple */ end (*/) bits"]); 22 | }) 23 | }) 24 | 25 | @context('@type', function() { 26 | @test('module type overrides default type', function() { 27 | @docutil.parseModuleDocs("/** 28 | @type doc 29 | */").type .. @assert.eq('doc'); 30 | }) 31 | 32 | @test('variable type is assigned to `vartype`', function() { 33 | @docutil.parseModuleDocs("/** 34 | @variable a 35 | @type String 36 | */").children .. @assert.eq({ 37 | a: { 38 | type: 'variable', 39 | valtype: 'String' 40 | }, 41 | }); 42 | }) 43 | }) 44 | -------------------------------------------------------------------------------- /test/unit/legacy-tests.sjs: -------------------------------------------------------------------------------- 1 | var testUtil = require('../lib/testUtil'); 2 | var testEq = testUtil.test; 3 | var testFn = testUtil.testFn; 4 | var {test, context, assert} = require('sjs:test/suite'); 5 | 6 | @ = require('sjs:test/std'); 7 | var s = require("sjs:sequence"); 8 | var toArray = s.toArray; 9 | var legacy = require('sjs:legacy'); 10 | 11 | context('partition', function() { 12 | testEq('partition(integers(1,10) .. toArray, x->x%2)', [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]], function() { 13 | return legacy.partition(s.integers(1, 10) .. s.toArray, x -> x%2); 14 | }); 15 | 16 | testEq('partition(integers(1,10), x->x%2)', [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]], function() { 17 | return legacy.partition(s.integers(1, 10), x -> x%2) .. s.map(s.toArray); 18 | }); 19 | 20 | test('should consume only as many items as required', function() { 21 | var seen = []; 22 | var log = function(item) { seen.push(item); return item; } 23 | var [odd, even] = s.integers() 24 | .. s.transform(log) 25 | .. legacy.partition(x -> x % 2); 26 | 27 | even = even .. s.take(3) .. toArray(); 28 | odd = odd .. s.take(3) .. toArray(); 29 | hold(100); 30 | even .. assert.eq([0, 2, 4]); 31 | odd .. assert.eq([1, 3, 5]); 32 | seen .. assert.eq([0, 1, 2, 3, 4, 5]); 33 | }).skip("BROKEN (return after spawn())"); 34 | }) 35 | -------------------------------------------------------------------------------- /src/deps/sjcl/core/hmac.js: -------------------------------------------------------------------------------- 1 | /** @fileOverview HMAC implementation. 2 | * 3 | * @author Emily Stark 4 | * @author Mike Hamburg 5 | * @author Dan Boneh 6 | */ 7 | 8 | /** HMAC with the specified hash function. 9 | * @constructor 10 | * @param {bitArray} key the key for HMAC. 11 | * @param {Object} [hash=sjcl.hash.sha256] The hash function to use. 12 | */ 13 | sjcl.misc.hmac = function (key, Hash) { 14 | this._hash = Hash = Hash || sjcl.hash.sha256; 15 | var exKey = [[],[]], i, 16 | bs = Hash.prototype.blockSize / 32; 17 | this._baseHash = [new Hash(), new Hash()]; 18 | 19 | if (key.length > bs) { 20 | key = Hash.hash(key); 21 | } 22 | 23 | for (i=0; i 2 | 3 | 4 | vim-stratifiedjs 5 | vim stratifiedjs syntax support 6 | 7 | 8 | # Vim syntax support for [stratified javascript][sjs] 9 | 10 | To use with [pathogen][], copy the `stratifiedjs` folder into 11 | `~/.vim/bundle`. If you don't use [pathogen][] (or something 12 | similar), now's a good time to start - but you can always 13 | install manually if you're stubborn. 14 | 15 | [pathogen]: https://github.com/tpope/vim-pathogen 16 | [sjs]: http://onilabs.com/stratifiedjs 17 | 18 | http://gfxmonk.github.com/vim-stratifiedjs/ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/hmac/hmac.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){ 8 | 9 | // Shortcuts 10 | var C = Crypto, 11 | util = C.util, 12 | charenc = C.charenc, 13 | UTF8 = charenc.UTF8, 14 | Binary = charenc.Binary; 15 | 16 | C.HMAC = function (hasher, message, key, options) { 17 | 18 | // Convert to byte arrays 19 | if (message.constructor == String) message = UTF8.stringToBytes(message); 20 | if (key.constructor == String) key = UTF8.stringToBytes(key); 21 | /* else, assume byte arrays already */ 22 | 23 | // Allow arbitrary length keys 24 | if (key.length > hasher._blocksize * 4) 25 | key = hasher(key, { asBytes: true }); 26 | 27 | // XOR keys with pad constants 28 | var okey = key.slice(0), 29 | ikey = key.slice(0); 30 | for (var i = 0; i < hasher._blocksize * 4; i++) { 31 | okey[i] ^= 0x5C; 32 | ikey[i] ^= 0x36; 33 | } 34 | 35 | var hmacbytes = hasher(okey.concat(hasher(ikey.concat(message), { asBytes: true })), { asBytes: true }); 36 | 37 | return options && options.asBytes ? hmacbytes : 38 | options && options.asString ? Binary.bytesToString(hmacbytes) : 39 | util.bytesToHex(hmacbytes); 40 | 41 | }; 42 | 43 | })(); 44 | -------------------------------------------------------------------------------- /test/unit/xbrowser/iframe-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, assert, context} = require('sjs:test/suite'); 2 | var Url = require('sjs:url'); 3 | 4 | context("cross-frame communication", function() { 5 | test.beforeAll:: function(s) { 6 | s.frame = document.createElement("iframe"); 7 | document.body.appendChild(s.frame); 8 | }; 9 | test.afterAll:: function(s) { 10 | document.body.removeChild(s.frame); 11 | }; 12 | 13 | context("exceptions", function() { 14 | test.beforeAll:: function(s) { 15 | var url = Url.normalize('../fixtures/iframe-errors.html', module.id); 16 | s.frame.contentDocument.location.href = url; 17 | waitfor { 18 | while(!(s.frame.contentWindow && s.frame.contentWindow.fail)) { 19 | hold(100); 20 | //console.log('waiting'); 21 | } 22 | } or { 23 | hold(2000); 24 | throw new Error("setup timed out"); 25 | } 26 | s.window = s.frame.contentWindow; 27 | }; 28 | test("synchronous errors are propagated", function(s) { 29 | assert.raises({message: "immediate error thrown by iframe"}, -> s.window.fail()); 30 | }); 31 | 32 | test("errors after suspension are propagated", function(s) { 33 | assert.raises({message: "delayed error thrown by iframe"}, -> s.window.delayfail()); 34 | }).skip("WON'T WORK - EFs don't work across VMs any longer"); 35 | }).timeout(2); 36 | 37 | }).browserOnly(); 38 | -------------------------------------------------------------------------------- /src/headers/oni-apollo.js.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Oni StratifiedJS Runtime 3 | * Client-side Cross-Browser implementation 4 | * 5 | * Version: ' ' 6 | * http://onilabs.com/stratifiedjs 7 | * 8 | * (c) 2010-2022 Oni Labs, http://onilabs.com 9 | * 10 | * This file is licensed under the terms of the MIT License: 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy 13 | * of this software and associated documentation files (the "Software"), to deal 14 | * in the Software without restriction, including without limitation the rights 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the Software is 17 | * furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in 20 | * all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | * 30 | */ 31 | -------------------------------------------------------------------------------- /src/bootstrap/apollo-bootstrap-common.js: -------------------------------------------------------------------------------- 1 | /* 2 | * StratifiedJS bootstrap code, common part 3 | * 4 | * Part of the StratifiedJS Runtime 5 | * http://onilabs.com/stratifiedjs 6 | * 7 | * (c) 2010-2011 Oni Labs, http://onilabs.com 8 | * 9 | * This file is licensed under the terms of the MIT License: 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | * 29 | */ 30 | /* 31 | Nothing yet 32 | */ 33 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/make_report.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | import time 4 | 5 | print """ 6 | 7 | 8 | Report for v"""+sys.argv[1]+""" 9 | 15 | 16 | 17 |
18 | Mac unit tests """+sys.argv[1]+""" 19 |
20 | """ 21 | 22 | out = open('mactests.txt','r').read() 23 | foo = re.sub(r'\n([0-9]+ PASS:)',r'
\1',out) 24 | bar = re.sub(r'\n([0-9]+ FAIL:)',r'
\1',foo) 25 | baz = re.sub(r'\n(.* testing complete. PASS:)',r'
\1',bar) 26 | print baz 27 | print """ 28 |
29 | Windows unit tests """+sys.argv[1]+""" 30 |
31 | """ 32 | out = 0 33 | for k in range(60): 34 | try: 35 | out = open('wintests.log','r').read() 36 | break 37 | except: 38 | time.sleep(10) 39 | if out==0: 40 | print """
FAIL: Window testing suite has failed.""" 41 | else: 42 | foo = re.sub(r'\n([0-9]+ PASS:)',r'
\1',out) 43 | bar = re.sub(r'\n([0-9]+ FAIL:)',r'
\1',foo) 44 | baz = re.sub(r'\n(.* testing complete. PASS:)',r'
\1',bar) 45 | print baz 46 | 47 | print """ 48 |
49 | """ 50 | -------------------------------------------------------------------------------- /test/config.mho: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env conductance 2 | // Default conductance configuration 3 | 4 | @ = require('mho:std'); 5 | @response = require('mho:server/response'); 6 | 7 | var root = @url.normalize("../", module.id) .. @url.toPath; 8 | exports.serve = function(args) { 9 | @server.run({ 10 | address: @Port(7071), 11 | routes: [ 12 | @route.SystemRoutes(), 13 | @Route('http/post_echo', { 14 | POST: (req) -> req.response.end(req.body() .. @join) 15 | }), 16 | @Route('http/fail', { 17 | GET: function(req) { 18 | req .. @response.setStatus(500); 19 | req.response.end("failure response data"); 20 | } 21 | }), 22 | @Route('http/ok', { 23 | GET: function(req) { 24 | req .. @response.setStatus(200); 25 | req.response.end("ok"); 26 | } 27 | }), 28 | @Route('http/redirect', { 29 | GET: function(req) { 30 | var url = req.url; 31 | var p = url.params(); 32 | 33 | var dest = p.dest; 34 | if (!dest && p.infinite) dest = url.source; 35 | if (!dest) throw new Error("`dest` required (url: #{url.source})"); 36 | 37 | req .. @response.writeRedirectResponse(@url.normalize(dest, url.source)); 38 | } 39 | }), 40 | @route.CodeDirectory(root), 41 | ] 42 | .. @route.LogRequests(@logging.INFO) 43 | .. @route.AllowCORS() 44 | }); 45 | }; 46 | 47 | if (require.main === module) exports.serve(); 48 | -------------------------------------------------------------------------------- /src/deps/sjcl/README/INSTALL: -------------------------------------------------------------------------------- 1 | SJCL comes with a file sjcl.js pre-built. This default build includes 2 | all the modules except for sjcl.codec.bytes (because the demo site doesn't 3 | use it). All you need to do to install is copy this file to your web 4 | server and start using it. 5 | 6 | SJCL is divided into modules implementing various cryptographic and 7 | convenience functions. If you don't need them all for your application, 8 | you can reconfigure SJCL for a smaller code size. To do this, you can 9 | run 10 | 11 | ./configure --without-all --with-aes --with-sha256 ... 12 | 13 | Then type 14 | 15 | make 16 | 17 | to rebuild sjcl.js. This will also create a few intermediate files 18 | core*.js; you can delete these automatically by typing 19 | 20 | make sjcl.js tidy 21 | 22 | instead. You will need make, perl, bash and java to rebuild SJCL. 23 | 24 | Some of the modules depend on other modules; configure should handle this 25 | automatically unless you tell it --without-FOO --with-BAR, where BAR 26 | depends on FOO. If you do this, configure will yell at you. 27 | 28 | SJCL is compressed by stripping comments, shortening variable names, etc. 29 | You can also pass a --compress argument to configure to change the 30 | compressor. By default SJCL uses some perl/sh scripts and Google's 31 | Closure compressor. 32 | 33 | If you reconfigure SJCL, it is recommended that you run the included test 34 | suite by typing "make test". If this prints "FAIL" or segfaults, SJCL 35 | doesn't work; please file a bug. 36 | 37 | -------------------------------------------------------------------------------- /test/unit/fixtures/ast-sample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file contains all of the syntactic constructs that 3 | * should be parsed identially by SJS / JS. 4 | * For SJS-specific syntax needs to be addressed 5 | * specifically in ast-tests.sjs 6 | */ 7 | 8 | function foo() { 9 | return 1; 10 | } 11 | 12 | console.log("string!\""); 13 | console['log']; 14 | var array = [1, "two", /three/]; 15 | var regex_flags = /foo/gm; 16 | var { destructure } = obj; 17 | var x = (1); 18 | var x = (1,2); 19 | var x = (1,2,3); 20 | x ? 1 : 2; 21 | if(x) { 1 } else if (y) { 2 } else { 3 }; 22 | if(x) { 1 } 23 | while(1) { loop(); } 24 | do { loop() } while(1); 25 | lbl: 1; 26 | for (var i=0; i null; 64 | (function({a, b:c}) { }); 65 | (function({a, b:[c,d]}) { }); 66 | var [a,,c] = arr; 67 | 68 | // pre-function comment 69 | function foo() { 70 | // leading function comment 71 | 72 | //pre-expression comment 73 | bar(); 74 | } 75 | -------------------------------------------------------------------------------- /test/unit/regexp-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, context, assert} = require('sjs:test/suite'); 2 | 3 | var {each, map} = require('sjs:sequence'); 4 | var regexp = require('sjs:regexp'); 5 | 6 | test('escape', function() { 7 | var specials = [ 8 | '.', '*', '+', '?', '^', '=', '!', ':', '$', 9 | '{', '}', '(', ')', '|', '[', ']', '/', '\\' 10 | ]; 11 | 12 | var allSpecials = specials.join(''); 13 | 14 | var escaped = regexp.escape(allSpecials); 15 | escaped .. assert.eq('\\' + specials.join('\\')); 16 | 17 | 18 | specials .. each {|ch| 19 | var escaped = regexp.escape(ch); 20 | escaped .. assert.eq('\\' + ch); 21 | var re = new RegExp(escaped); 22 | re.exec(ch) .. assert.ok("#{ch} incorrectly escaped"); 23 | } 24 | 25 | var re = new RegExp(escaped); 26 | re.exec(allSpecials) .. assert.ok("#{allSpecials} incorrectly escaped"); 27 | }) 28 | 29 | context('matches', function() { 30 | test("returns all matches", function() { 31 | "foof far faz" .. regexp.matches(/f./g) .. map(m -> m[0]) .. assert.eq(['fo', 'f ', 'fa', 'fa']); 32 | }) 33 | 34 | test("rejects a non-global regexp", function() { 35 | assert.raises( -> "foof far faz" .. regexp.matches(/f./)); 36 | }) 37 | 38 | test("handles a zero-width regexp", function() { 39 | // not actually useful, but we need to make sure it doesn't loop infinitely 40 | "abc" .. regexp.matches(/()/g) .. map(m -> [m[0], m.index]) .. assert.eq([ 41 | ["", 0], 42 | ["", 1], 43 | ["", 2], 44 | ["", 3]]); 45 | }) 46 | }) 47 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/mytest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Flot Examples 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Flot Examples

14 | 15 |
16 | 17 |

Simple example. You don't need to specify much to get an 18 | attractive look. Put in a placeholder, make sure you set its 19 | dimensions (otherwise the plot library will barf) and call the 20 | plot function with the data. The axes are automatically 21 | scaled.

22 | 23 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /modules/compile/sjs.sjs: -------------------------------------------------------------------------------- 1 | /* 2 | * C1 SJS -> StratifiedJS VM compiler kernel 3 | * 4 | * Part of StratifiedJS 5 | * http://onilabs.com/stratifiedjs 6 | * 7 | * (c) 2011-2022 Oni Labs, http://onilabs.com 8 | * 9 | * This file is licensed under the terms of the GPL v2, see 10 | * http://www.gnu.org/licenses/gpl-2.0.html 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18 | * THE SOFTWARE. 19 | * 20 | */ 21 | /** 22 | @module compile/sjs 23 | @executable 24 | @summary SJS Compiler 25 | @home sjs:compile/sjs 26 | 27 | @function compile 28 | @summary Compile a string of SJS source code into JavaScript 29 | @param {String} [src] 30 | @param {optional Object} [settings] 31 | @setting {String} [filename] 32 | @return {String} Compiled JavaScript 33 | 34 | 35 | @docsoff */ 36 | exports.compile = __oni_rt.c1.compile; 37 | if (require.main === module) { 38 | var seq = require('sjs:sequence'), fs = require('sjs:nodejs/fs'); 39 | require('sjs:sys').argv() .. seq.each {|f| 40 | var filename = JSON.stringify(f); 41 | fs.readFile(f, 'utf-8') .. exports.compile({globalReturn: true, filename: filename, keeplines: true}) .. console.log 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/_index.txt: -------------------------------------------------------------------------------- 1 | ### NOTE: do not edit this file manually, 2 | ### regenerate it by running src/build/make-sjs 3 | unit/array-tests.sjs 4 | unit/assert-tests.sjs 5 | unit/bundle-tests.sjs 6 | unit/bytes-tests.sjs 7 | unit/compile/ast-tests.sjs 8 | unit/compile/deps-tests.sjs 9 | unit/compile/minify-tests.sjs 10 | unit/compile/stringify-tests.sjs 11 | unit/controlflow-tests.sjs 12 | unit/cutil-tests.sjs 13 | unit/dashdash-tests.sjs 14 | unit/debug-tests.sjs 15 | unit/docutil-tests.sjs 16 | unit/dynamic-vars-tests.sjs 17 | unit/event-tests.sjs 18 | unit/function-tests.sjs 19 | unit/http-tests.sjs 20 | unit/legacy-tests.sjs 21 | unit/logging-tests.sjs 22 | unit/lru-cache-tests.sjs 23 | unit/map-tests.sjs 24 | unit/node/child-process-tests.sjs 25 | unit/node/deps-tests.sjs 26 | unit/node/fs-tests.sjs 27 | unit/node/process-tests.sjs 28 | unit/node/stream-tests.sjs 29 | unit/node/tempfile-tests.sjs 30 | unit/object-tests.sjs 31 | unit/observable-tests.sjs 32 | unit/quasi-tests.sjs 33 | unit/regexp-tests.sjs 34 | unit/require-tests.sjs 35 | unit/sequence-tests.sjs 36 | unit/service-tests.sjs 37 | unit/shell-quote-tests.sjs 38 | unit/sjcl-tests.sjs 39 | unit/sjs-2-tests.sjs 40 | unit/sjs-3-tests.sjs 41 | unit/sjs-4-tests.sjs 42 | unit/sjs-tests.sjs 43 | unit/stack-tests.sjs 44 | unit/string-tests.sjs 45 | unit/test/reporter-tests.sjs 46 | unit/test/runner-tests.sjs 47 | unit/thread-tests.sjs 48 | unit/url-tests.sjs 49 | unit/xbrowser/console-tests.sjs 50 | unit/xbrowser/dom-tests.sjs 51 | unit/xbrowser/iframe-tests.sjs 52 | integration/bundle-tests.sjs 53 | integration/documentation-tests.sjs 54 | integration/http-tests.sjs 55 | integration/require-tests.sjs 56 | -------------------------------------------------------------------------------- /src/deps/sjcl/README/bsd.txt: -------------------------------------------------------------------------------- 1 | Copyright 2009-2010 Emily Stark, Mike Hamburg, Dan Boneh. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 17 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | The views and conclusions contained in the software and documentation 29 | are those of the authors and should not be interpreted as representing 30 | official policies, either expressed or implied, of the authors. 31 | -------------------------------------------------------------------------------- /src/deps/sources.txt: -------------------------------------------------------------------------------- 1 | # numeric lib 2 | numeric/ https://github.com/sloisel/numeric.git 5441d192269f2a6b4d8e32aee32d676bb90a0b30 3 | 4 | # Stanford JavaScript Crypto Library 5 | sjcl/ https://github.com/bitwiseshiftleft/sjcl.git 81c63557548ac4d5c9e9fae8e95ee7ffc3334c9d 6 | 7 | # node-terminal: 8 | node-terminal/ https://github.com/mattijs/node-terminal.git 00e6fa30b196a3a709b025c2725c89f4d6d54408 9 | 10 | # JsonDiffPatch: 11 | JsonDiffPatch/ https://github.com/benjamine/JsonDiffPatch.git 2b7ef07a253e41aad4ed4d938ab701baec2b00db 12 | 13 | # marked: 14 | marked/ https://github.com/chjj/marked.git 922dd964950a64ca0808952847a1a4e00d42f7b6 15 | 16 | # dashdash: 17 | dashdash/ https://github.com/trentm/node-dashdash.git cf94c5989381d17315beb5b675a9dd25410c00b5 18 | 19 | # jsdiff: 20 | jsdiff/ https://github.com/kpdecker/jsdiff.git 1f4bf7a708fc1121bb49e3b10d2ec7218c52a210 21 | 22 | # html2canvas: 23 | html2canvas/ https://github.com/niklasvh/html2canvas.git 069140974b3bbcaa442a3c7c597b345ff04da1ce 24 | 25 | # FileSaver.js: 26 | FileSaver.js/ https://github.com/eligrey/FileSaver.js.git ec5c3cca113f9c0fba66c8d0ef44d4a6bf985357 27 | 28 | # momentjs (currently v2.22.2) 29 | moment/ https://github.com/moment/moment.git 2e2a5b35439665d4b0200143d808a7c26d6cd30f 30 | 31 | # moment-timezone (currently v0.5.17) 32 | moment-timezone/ https://github.com/moment/moment-timezone.git 75f9e6e7bf95e363b97a4d4376325272bcf5946b 33 | 34 | # js-yaml (currently 3.12.0) 35 | js-yaml/ https://github.com/nodeca/js-yaml.git 5cdad9bd27ad97627b21f0111ca3f125fe618acd 36 | 37 | # big.js (currently 6.2.1) 38 | big.js/ https://github.com/MikeMcl/big.js.git 8f44eb57da97709a56024c6bd97a17804a1be91a 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Oni StratifiedJS: Multi-Platform StratifiedJS Implementation 2 | ============================================================ 3 | 4 | (c) 2010-2022 Oni Labs, http://onilabs.com 5 | 6 | The Oni StratifiedJS distribution is made available as open-source. 7 | 8 | All client-side components of the distribution are licensed under the MIT License. 9 | Some server-side components are licensed under the GPL v2. 10 | 11 | The upshot is that if you use StratifiedJS purely on the client-side via the 12 | cross-browser stratified.js runtime and the standard module library, there 13 | are no restrictions placed on your application. 14 | If you use StratifiedJS on the server-side, or you use the StratifiedJS compiler 15 | or virtual machine directly (i.e. not via stratified.js) in another product, 16 | then that product also needs to be licensed under the GPL. 17 | 18 | Alternative licensing available; for enquiries please contact alex@onilabs.com 19 | 20 | 21 | For exact licensing terms, please see individual files. As an overview: 22 | 23 | - The modules contained in the Standard Module Library 24 | (modules/*) are licensed under the MIT License. 25 | 26 | - The bootstraping code (src/bootstrap/*) is licensed under the MIT License. 27 | 28 | - The system module code (src/sys/*) is licensed under the MIT License. 29 | 30 | - The client-side cross-browser StratifiedJS runtime (stratified.js) 31 | is licensed under the MIT License. 32 | 33 | - The compiler and virtual machine code (src/c1/* and 34 | src/vm1/*) is licensed under the GPL v2. 35 | 36 | - The server-side Node.JS-based StratifiedJS runtime 37 | (stratified-node.js) is licensed under the GPL v2. 38 | 39 | -------------------------------------------------------------------------------- /src/deps/jsdiff/LICENSE: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2009-2011, Kevin Decker 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use of this software in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above 11 | copyright notice, this list of conditions and the 12 | following disclaimer. 13 | 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer in the documentation and/or other 17 | materials provided with the distribution. 18 | 19 | * Neither the name of Kevin Decker nor the names of its 20 | contributors may be used to endorse or promote products 21 | derived from this software without specific prior 22 | written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 26 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/deps/sjcl/README/COPYRIGHT: -------------------------------------------------------------------------------- 1 | SJCL used to be in the public domain. Now it's: 2 | 3 | Copyright 2009-2010 Emily Stark, Mike Hamburg, Dan Boneh, Stanford University. 4 | 5 | This is for liability reasons. (Speaking of which, SJCL comes with NO 6 | WARRANTY WHATSOEVER, express or implied, to the limit of applicable 7 | law.) 8 | 9 | SJCL is dual-licensed under the GNU GPL version 2.0 or higher, and a 10 | 2-clause BSD license. You may use SJCL under the terms of either of 11 | these licenses. For your convenience, the GPL versions 2.0 and 3.0 12 | and the 2-clause BSD license are included here. Additionally, you may 13 | serve "crunched" copies of sjcl (i.e. those with comments removed, 14 | and other transformations to reduce code size) without any copyright 15 | notice. 16 | 17 | SJCL includes JsDoc toolkit, YUI compressor, Closure compressor, 18 | JSLint and the CodeView template in its build system. These programs' 19 | copyrights are owned by other people. They are distributed here under 20 | the MPL, MIT, BSD, Apache and JSLint licenses. Codeview is "free for 21 | download" but has no license attached; it is Copyright 2010 Wouter Bos. 22 | 23 | The BSD license is (almost?) strictly more permissive, but the 24 | additionally licensing under the GPL allows us to use OCB 2.0 code 25 | royalty-free (at least, if OCB 2.0's creator Phil Rogaway has anything 26 | to say about it). Note that if you redistribute SJCL under a license 27 | other than the GPL, you or your users may need to pay patent licensing 28 | fees for OCB 2.0. 29 | 30 | There may be patents which apply to SJCL other than Phil Rogaway's OCB 31 | patents. We suggest that you consult legal counsel before using SJCL 32 | in a commercial project. 33 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/pbkdf2/pbkdf2.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){ 8 | 9 | // Shortcuts 10 | var C = Crypto, 11 | util = C.util, 12 | charenc = C.charenc, 13 | UTF8 = charenc.UTF8, 14 | Binary = charenc.Binary; 15 | 16 | C.PBKDF2 = function (password, salt, keylen, options) { 17 | 18 | // Convert to byte arrays 19 | if (password.constructor == String) password = UTF8.stringToBytes(password); 20 | if (salt.constructor == String) salt = UTF8.stringToBytes(salt); 21 | /* else, assume byte arrays already */ 22 | 23 | // Defaults 24 | var hasher = options && options.hasher || C.SHA1, 25 | iterations = options && options.iterations || 1; 26 | 27 | // Pseudo-random function 28 | function PRF(password, salt) { 29 | return C.HMAC(hasher, salt, password, { asBytes: true }); 30 | } 31 | 32 | // Generate key 33 | var derivedKeyBytes = [], 34 | blockindex = 1; 35 | while (derivedKeyBytes.length < keylen) { 36 | var block = PRF(password, salt.concat(util.wordsToBytes([blockindex]))); 37 | for (var u = block, i = 1; i < iterations; i++) { 38 | u = PRF(password, u); 39 | for (var j = 0; j < block.length; j++) block[j] ^= u[j]; 40 | } 41 | derivedKeyBytes = derivedKeyBytes.concat(block); 42 | blockindex++; 43 | } 44 | 45 | // Truncate excess bytes 46 | derivedKeyBytes.length = keylen; 47 | 48 | return options && options.asBytes ? derivedKeyBytes : 49 | options && options.asString ? Binary.bytesToString(derivedKeyBytes) : 50 | util.bytesToHex(derivedKeyBytes); 51 | 52 | }; 53 | 54 | })(); 55 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/selenium_links.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.common.exceptions import TimeoutException 3 | from selenium.webdriver.support.ui import WebDriverWait 4 | import time 5 | import traceback 6 | import sys 7 | import urllib 8 | import re 9 | 10 | url = "" 11 | def test(links,driver): 12 | p=0 13 | f=0 14 | t=0 15 | for k in range(len(links)): 16 | x = links[k] 17 | foo = "" 18 | t=t+1 19 | try: 20 | link = driver.find_element_by_id(x[0]) 21 | link.click() 22 | foo = driver.page_source 23 | driver.back() 24 | assert(x[1] in foo) 25 | print k,"PASS:",x[0],"==>",x[1],"in page" 26 | p=p+1 27 | except: 28 | print k,"FAIL:",x[0],"==>",x[1],"not in page" 29 | traceback.print_exc() 30 | f=f+1 31 | print 'Link testing complete. PASS:',p,'FAIL:',f,'Total:',t 32 | 33 | url = "" 34 | if len(sys.argv) > 1: 35 | client = sys.argv[1] 36 | if(len(sys.argv)>2): 37 | url = sys.argv[2] 38 | else: 39 | client = "Firefox" 40 | 41 | if url == "": 42 | url = "http://127.0.0.1/staging/" 43 | 44 | mainlinks = [("linkhome","library for numerical computations"), 45 | ("linkworkshop","IN"), 46 | ("linkdoc","vectors and matrices"), 47 | ("linklib","var numeric"), 48 | ("linklibmin","var numeric="),] 49 | driver=0 50 | print "Link testing." 51 | try: 52 | driver = eval('webdriver.'+client+'()') 53 | print "Using",client 54 | driver.implicitly_wait(10) 55 | driver.get(url) 56 | test(mainlinks,driver) 57 | driver.quit() 58 | except: 59 | print "Could not do browser",client 60 | if driver: 61 | driver.quit() 62 | 63 | -------------------------------------------------------------------------------- /src/deps/sjcl/core/pbkdf2.js: -------------------------------------------------------------------------------- 1 | /** @fileOverview Password-based key-derivation function, version 2.0. 2 | * 3 | * @author Emily Stark 4 | * @author Mike Hamburg 5 | * @author Dan Boneh 6 | */ 7 | 8 | /** Password-Based Key-Derivation Function, version 2.0. 9 | * 10 | * Generate keys from passwords using PBKDF2-HMAC-SHA256. 11 | * 12 | * This is the method specified by RSA's PKCS #5 standard. 13 | * 14 | * @param {bitArray|String} password The password. 15 | * @param {bitArray} salt The salt. Should have lots of entropy. 16 | * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure. 17 | * @param {Number} [length] The length of the derived key. Defaults to the 18 | output size of the hash function. 19 | * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family. 20 | * @return {bitArray} the derived key. 21 | */ 22 | sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) { 23 | count = count || 1000; 24 | 25 | if (length < 0 || count < 0) { 26 | throw sjcl.exception.invalid("invalid params to pbkdf2"); 27 | } 28 | 29 | if (typeof password === "string") { 30 | password = sjcl.codec.utf8String.toBits(password); 31 | } 32 | 33 | Prff = Prff || sjcl.misc.hmac; 34 | 35 | var prf = new Prff(password), 36 | u, ui, i, j, k, out = [], b = sjcl.bitArray; 37 | 38 | for (k = 1; 32 * out.length < (length || 1); k++) { 39 | u = ui = prf.encrypt(b.concat(salt,[k])); 40 | 41 | for (i=1; i").load(l).error(l).attr("src",j)})};function d(q,o,l){var m=q.getPlotOffset();if(!l.images||!l.images.show){return}var r=l.datapoints.points,n=l.datapoints.pointsize;for(var t=0;tv){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}if(l.images.anchor=="center"){x=0.5*(v-w)/(y.width-1);w-=x;v+=x;x=0.5*(f-g)/(y.height-1);g-=x;f+=x}if(w==v||g==f||w>=h.max||v<=h.min||g>=u.max||f<=u.min){continue}var k=0,s=0,j=y.width,p=y.height;if(wh.max){j+=(j-k)*(h.max-v)/(v-w);v=h.max}if(gu.max){s+=(s-p)*(u.max-f)/(f-g);f=u.max}w=h.p2c(w);v=h.p2c(v);g=u.p2c(g);f=u.p2c(f);if(w>v){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}x=o.globalAlpha;o.globalAlpha*=l.images.alpha;o.drawImage(y,k,s,j-k,p-s,w+m.left,g+m.top,v-w,f-g);o.globalAlpha=x}}function b(i,f,g,h){if(!f.images.show){return}h.format=[{required:true},{x:true,number:true,required:true},{y:true,number:true,required:true},{x:true,number:true,required:true},{y:true,number:true,required:true}]}function e(f){f.hooks.processRawData.push(b);f.hooks.drawSeries.push(d)}c.plot.plugins.push({init:e,options:a,name:"image",version:"1.1"})})(jQuery); -------------------------------------------------------------------------------- /src/deps/numeric/myworker.js: -------------------------------------------------------------------------------- 1 | var _send = (typeof workerPostMessage !== 'undefined')?workerPostMessage:postMessage; 2 | var _myeval = eval; 3 | var _flag = 0; 4 | var workshop = (typeof workshop === "undefined")?{}:workshop; 5 | workshop.plot = function(p,o,s) { 6 | _send(JSON.stringify({k:workshop.current.k,n:workshop.current.n,p:p,o:o,s:s})); 7 | } 8 | workshop.html = function(o) { 9 | _send(JSON.stringify({k:workshop.current.k,n:workshop.current.n,o:o})); 10 | } 11 | 12 | var console; 13 | if(!console) console = {}; 14 | console.log = function() { 15 | var k,n=arguments.length; 16 | var _x = workshop.current; 17 | if(_x) { 18 | for(k=0;k0) _send(JSON.stringify({k:_x.k,n:_x.n,o:' '})); 20 | _send(JSON.stringify({k:_x.k,n:_x.n,o:numeric.prettyPrint(arguments[k])})); 21 | } 22 | } 23 | _send(JSON.stringify({k:_x.k,n:_x.n,o:'\n'})); 24 | } 25 | 26 | _onmessage = function(event) { 27 | var _ans, _foo, _x = JSON.parse(event.data); 28 | if(typeof _x.imports !== "undefined") { 29 | for(_foo=0;_foo<_x.imports.length;_foo++) { importScripts(_x.imports[_foo]); } 30 | return; 31 | } 32 | try { 33 | workshop.current = {k:_x.k, n:_x.n}; 34 | _ans = _myeval(_x.e); 35 | if(typeof(_ans) !== "undefined") { _foo = numeric.prettyPrint(_ans,true); } 36 | else { _foo = ""; } 37 | workshop.current = undefined; 38 | } catch(e) { 39 | _ans = undefined; 40 | _foo = e.name+': '+e.message; 41 | if(typeof e.stack !== "undefined" && typeof e.stack.toString !== "undefined") 42 | { _foo += "\n\n"+e.stack.toString(); } 43 | } 44 | _foo = _foo.replace(/&/g,'&').replace(/>/g,'>').replace(/>5]|=128<<24-b%32;f[(b+64>>9<<4)+15]=b;for(p=0;p>>7)^(g<<14|g>>>18)^g>>>3)+(h[c-7]>>>0)+((e<<15|e>>>17)^(e<<13|e>>>19)^e>>>10)+(h[c-16]>>>0)}e=b&i^b&j^i&j;var w=(b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22);g=(o>>>0)+((d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7| 10 | d>>>25))+(d&k^~d&l)+v[c]+(h[c]>>>0);e=w+e;o=l;l=k;k=d;d=n+g;n=j;j=i;i=b;b=g+e}a[0]+=b;a[1]+=i;a[2]+=j;a[3]+=n;a[4]+=d;a[5]+=k;a[6]+=l;a[7]+=o}return a};m._blocksize=16;m._digestsize=32})(); 11 | -------------------------------------------------------------------------------- /tools/karma/conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(config) { 2 | config.set({ 3 | basePath: '../../', 4 | 5 | frameworks: [ 6 | 'sjs', 7 | ], 8 | 9 | client: { 10 | // workaround for https://github.com/karma-runner/karma/issues/961 11 | captureConsole: true, 12 | hubs: { 13 | 'sjs:': '/__sjs/modules/' 14 | }, 15 | }, 16 | 17 | files: [ 18 | 'test/json2.js', // required for IE<8 only 19 | ], 20 | 21 | proxies: { 22 | // http tests rely on dynamic behaviour (served by conductance) 23 | '/http': 'http://localhost:7071/http', 24 | 25 | // bundle-tests rely on conductance bundle functionality 26 | '/test/integration/fixtures': 'http://localhost:7071/test/integration/fixtures' 27 | }, 28 | 29 | exclude: [], 30 | 31 | // test results reporter to use 32 | // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' 33 | reporters: ['quiet'], 34 | 35 | // web server port 36 | port: 9876, 37 | 38 | // cli runner port 39 | runnerPort: 9100, 40 | 41 | colors: true, 42 | 43 | logLevel: config.LOG_INFO, 44 | 45 | // enable / disable watching file and executing tests whenever any file changes 46 | autoWatch: false, 47 | 48 | browsers: [ 49 | 'PhantomJS', 50 | // 'tools/bin/manual-browser', 51 | // 'tools/bin/android-browser', 52 | ], 53 | 54 | // If browser does not capture in given timeout [ms], kill it 55 | captureTimeout: 0, 56 | 57 | // Continuous Integration mode 58 | // if true, it capture browsers, run tests and exit 59 | singleRun: false, 60 | 61 | // plugins to load 62 | plugins: [ 63 | 'karma-chrome-launcher' 64 | ,'karma-firefox-launcher' 65 | ,'karma-ie-launcher' 66 | ,'karma-script-launcher' 67 | ,'karma-phantomjs-launcher' 68 | ,'karma-sjs-adapter' 69 | ,'karma-quiet-reporter' 70 | ], 71 | }); 72 | }; 73 | -------------------------------------------------------------------------------- /src/deps/sjcl/core/codecBase64.js: -------------------------------------------------------------------------------- 1 | /** @fileOverview Bit array codec implementations. 2 | * 3 | * @author Emily Stark 4 | * @author Mike Hamburg 5 | * @author Dan Boneh 6 | */ 7 | 8 | /** @namespace Base64 encoding/decoding */ 9 | sjcl.codec.base64 = { 10 | /** The base64 alphabet. 11 | * @private 12 | */ 13 | _chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 14 | 15 | /** Convert from a bitArray to a base64 string. */ 16 | fromBits: function (arr, _noEquals, _url) { 17 | var out = "", i, bits=0, c = sjcl.codec.base64._chars, ta=0, bl = sjcl.bitArray.bitLength(arr); 18 | if (_url) c = c.substr(0,62) + '-_'; 19 | for (i=0; out.length * 6 < bl; ) { 20 | out += c.charAt((ta ^ arr[i]>>>bits) >>> 26); 21 | if (bits < 6) { 22 | ta = arr[i] << (6-bits); 23 | bits += 26; 24 | i++; 25 | } else { 26 | ta <<= 6; 27 | bits -= 6; 28 | } 29 | } 30 | while ((out.length & 3) && !_noEquals) { out += "="; } 31 | return out; 32 | }, 33 | 34 | /** Convert from a base64 string to a bitArray */ 35 | toBits: function(str, _url) { 36 | str = str.replace(/\s|=/g,''); 37 | var out = [], i, bits=0, c = sjcl.codec.base64._chars, ta=0, x; 38 | if (_url) c = c.substr(0,62) + '-_'; 39 | for (i=0; i 26) { 45 | bits -= 26; 46 | out.push(ta ^ x>>>bits); 47 | ta = x << (32-bits); 48 | } else { 49 | bits += 6; 50 | ta ^= x << (32-bits); 51 | } 52 | } 53 | if (bits&56) { 54 | out.push(sjcl.bitArray.partial(bits&56, ta, 1)); 55 | } 56 | return out; 57 | } 58 | }; 59 | 60 | sjcl.codec.base64url = { 61 | fromBits: function (arr) { return sjcl.codec.base64.fromBits(arr,1,1); }, 62 | toBits: function (str) { return sjcl.codec.base64.toBits(str,1); } 63 | }; 64 | -------------------------------------------------------------------------------- /test/unit/bytes-tests.sjs: -------------------------------------------------------------------------------- 1 | @ = require(['sjs:test/std', 'sjs:bytes']); 2 | 3 | var input = [1,2,3]; 4 | var types = [ 5 | ['Uint8Array', 'isUint8Array', 'toUint8Array', new Uint8Array([1,2,3])], 6 | ['ArrayBuffer', 'isArrayBuffer', 'toArrayBuffer', (new Uint8Array([1,2,3])).buffer], 7 | ]; 8 | 9 | if(!@isBrowser) { 10 | types.push(['Buffer', 'isBuffer', 'toBuffer', Buffer.from([1,2,3])]); 11 | } 12 | 13 | @context("Array", function() { 14 | @test("Array isBytes", function() { 15 | input .. @isBytes .. @assert.eq(false); 16 | }) 17 | 18 | types .. @each {|[className, testMethod, convertMethod, sourceExample]| 19 | @test("Array .. #{testMethod} should be false", function() { 20 | input .. @[testMethod] .. @assert.eq(false); 21 | }) 22 | 23 | @test("Array .. #{convertMethod}", function() { 24 | var converted = input .. @[convertMethod]; 25 | converted .. @assert.eq(sourceExample); 26 | }) 27 | } 28 | }) 29 | 30 | // because the types are all functionally equivalent, we just test 31 | // each permutation of (type, conversion, test) against all other binary types. 32 | types .. @each {|[className, testMethod, convertMethod, sourceExample]| 33 | @context(className, function() { 34 | var cls = @sys.getGlobal(className); 35 | cls .. @assert.ok(); 36 | 37 | @test("isBytes", function() { 38 | sourceExample .. @isBytes .. @assert.eq(true); 39 | }) 40 | 41 | types .. @each {|[desc,,,example]| 42 | var isSelf = example === sourceExample; 43 | 44 | // since ca. node v 4.5, buffers are also unit8arrays: 45 | if (desc ==='Buffer' && className ==='Uint8Array') continue; 46 | 47 | @test("#{desc} .. #{testMethod} should be #{isSelf}", function() { 48 | example .. @[testMethod] .. @assert.eq(isSelf); 49 | }) 50 | 51 | @test("#{desc} .. #{convertMethod}", function() { 52 | if(isSelf) { 53 | example .. @[convertMethod] .. @assert.is(example); 54 | } else { 55 | example .. @[convertMethod] .. @assert.eq(sourceExample); 56 | } 57 | }) 58 | } 59 | 60 | }) 61 | } 62 | -------------------------------------------------------------------------------- /src/build/std.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | // metadata for sjs:bundle: 3 | @require sjs:object 4 | @require sjs:array 5 | @require sjs:set 6 | @require sjs:map 7 | @require sjs:sequence 8 | @require sjs:string 9 | @require sjs:compare 10 | @require sjs:debug 11 | @require sjs:function 12 | @require sjs:cutil 13 | @require sjs:quasi 14 | @require sjs:assert 15 | @require sjs:logging 16 | @require sjs:event 17 | @require sjs:sys 18 | @require sjs:http 19 | @require sjs:regexp 20 | @require sjs:url 21 | @require sjs:observable 22 | @require sjs:service 23 | */ 24 | 25 | var { hostenv, getGlobal } = require('builtin:apollo-sys'); 26 | var modules = [ 27 | 'sjs:object', 28 | 'sjs:array', 29 | 'sjs:set', 30 | 'sjs:map', 31 | 'sjs:sequence', 32 | 'sjs:string', 33 | 'sjs:compare', 34 | 'sjs:debug', 35 | {id: 'sjs:function', name:'fn'}, 36 | 'sjs:cutil', 37 | 'sjs:quasi', 38 | {id:'sjs:assert', name:'assert'}, 39 | {id:'sjs:logging', include:['print','debug','verbose','info','warn','error']}, 40 | {id:'sjs:logging', name:'logging'}, 41 | 'sjs:event', 42 | {id:'sjs:sys', name: 'sys'}, 43 | {id:'sjs:http', name: 'http'}, 44 | {id:'sjs:regexp', name: 'regexp'}, 45 | {id:'sjs:url', name: 'url'}, 46 | 'sjs:observable', 47 | 'sjs:service' 48 | ]; 49 | 50 | if (hostenv === 'nodejs') { 51 | modules = modules.concat([ 52 | {id:'sjs:nodejs/stream', name:'stream'}, 53 | {id:'sjs:nodejs/stream', include:['pump']}, 54 | {id:'sjs:sys', include: ['argv', 'eval']}, 55 | 'sjs:bytes', 56 | {id:'nodejs:path', name: 'path'}, 57 | {id:'sjs:nodejs/fs', name: 'fs'}, 58 | {id:'sjs:nodejs/child-process', name: 'childProcess'}, 59 | ]); 60 | } else { 61 | modules = modules.concat([ 62 | {id:'sjs:sys', include: ['eval']} 63 | ]); 64 | if (getGlobal().document && getGlobal().document.createElement) { 65 | modules = modules.concat([ 66 | {id: 'sjs:xbrowser/dom', name: 'dom'}, 67 | {id: 'sjs:xbrowser/dom', include: ['preventDefault','stopEvent', 'eventTarget']} 68 | ]); 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/deploy/selenium_basic.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.common.exceptions import TimeoutException 3 | from selenium.webdriver.support.ui import WebDriverWait 4 | import time 5 | import traceback 6 | import sys 7 | import urllib 8 | import re 9 | 10 | tests=[('numeric.add(1,[2,3]);','[3,4]')] 11 | def test(name,driver): 12 | p = 0 13 | f = 0 14 | t = 0 15 | try: 16 | for k in range(len(tests)): 17 | t=t+1 18 | foo = "" 19 | try: 20 | input = driver.find_element_by_id("text_"+str(k+1)) 21 | input.send_keys(tests[k][0]+'\n') 22 | bar = "out_"+str(k+1) 23 | WebDriverWait(driver,5).until(lambda driver: driver.find_element_by_id(bar).text not in ["",""]) 24 | output = driver.find_element_by_id(bar) 25 | foo = re.sub(r'\s','',output.text) 26 | if(tests[k][1][0:6]=="Error:"): 27 | foo = foo[0:len(tests[k][1])] 28 | assert(foo == tests[k][1]) 29 | print k,"PASS:",tests[k][0],'==>',foo 30 | p=p+1 31 | except Exception as ex: 32 | print k,"FAIL:",tests[k][0],'==>',foo,"reason:",ex 33 | f=f+1 34 | print name,'testing complete. PASS:',p,'FAIL:',f,'Total:',t 35 | except: 36 | print "FAIL: "+name+" selenium tests. Details:" 37 | traceback.print_exc() 38 | 39 | url = "" 40 | if len(sys.argv) > 1: 41 | client = sys.argv[1] 42 | if(len(sys.argv)>2): 43 | url = sys.argv[2] 44 | else: 45 | client = "Firefox" 46 | 47 | if url == "": 48 | url = "http://127.0.0.1/staging/" 49 | 50 | print "Basic functionality test." 51 | driver=0 52 | try: 53 | driver = eval('webdriver.'+client+'()') 54 | print "Using",client 55 | driver.implicitly_wait(2) 56 | driver.get(url+'workshop.php') 57 | test(client,driver) 58 | except: 59 | print "Could not use browser",client 60 | if(driver): 61 | driver.quit() 62 | -------------------------------------------------------------------------------- /src/deps/js-yaml/apollo-module-header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * StratifiedJS 'yaml' module 3 | * 4 | * Part of the Stratified JavaScript Standard Module Library 5 | * Version: 'unstable' 6 | * http://onilabs.com/stratifiedjs 7 | * 8 | * (c) 2013 Oni Labs, http://onilabs.com 9 | * 10 | * 11 | * *************************************************************** 12 | * * DO NOT EDIT yaml.sjs - IT IS A GENERATED FILE! * 13 | * * EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN * 14 | * * stratifiedjs/src/build/make-sjs * 15 | * *************************************************************** 16 | * 17 | * 18 | * This file is derived from the "js-yaml" project 19 | * (https://github.com/nodeca/js-yaml), 20 | * which is available under the terms of the MIT License. 21 | * 22 | */ 23 | 24 | /** 25 | @module yaml 26 | @summary YAML parser (tracking the [js-yaml](https://github.com/nodeca/js-yaml) library, currently v3.12.0) 27 | @home sjs:yaml 28 | @desc 29 | 30 | * See https://github.com/nodeca/js-yaml#api for API documentation. 31 | 32 | * See http://nodeca.github.io/js-yaml for a demo. 33 | 34 | * Function expressions (via esprima) are not supported. 35 | 36 | @function safeLoad 37 | @summary Parse `content` as a single YAML document 38 | @param {String} [content] 39 | @return {Object} 40 | @desc 41 | * See https://github.com/nodeca/js-yaml#api for API documentation. 42 | 43 | 44 | @function dump 45 | @summary Serialize `obj` as a YAML document. 46 | @param {Object} [obj] 47 | @return {String} 48 | @desc 49 | * See https://github.com/nodeca/js-yaml#api for API documentation. 50 | 51 | */ 52 | 53 | 54 | 55 | /** 56 | @docsoff 57 | */ 58 | 59 | // js-yaml attempts to load various modules (esprima, buffer) that we don't want in certain scenarios 60 | var normal_require = require; 61 | require = function(id) { 62 | if (normal_require('builtin:apollo-sys').hostenv === 'nodejs' && id === 'buffer') 63 | return normal_require('buffer'); 64 | return undefined; 65 | }; 66 | 67 | __js { 68 | 69 | -------------------------------------------------------------------------------- /test/unit/xbrowser/console-tests.sjs: -------------------------------------------------------------------------------- 1 | var {test, context, assert, isIE} = require('sjs:test/suite'); 2 | var logging = require('sjs:logging'); 3 | 4 | context("console", function() { 5 | var {console} = require('sjs:xbrowser/console'); 6 | 7 | var sendReturn = function(elem) { 8 | var eventObj = document.createEventObject ? document.createEventObject() : document.createEvent("Events"); 9 | if(eventObj.initEvent) eventObj.initEvent("keydown", true, true); 10 | 11 | var keyCode = 13; 12 | eventObj.keyCode = keyCode; 13 | eventObj.which = keyCode; 14 | 15 | elem.dispatchEvent ? elem.dispatchEvent(eventObj) : elem.fireEvent("onkeydown", eventObj); 16 | } 17 | 18 | var exec = function(c, str) { 19 | var input = c.root.getElementsByTagName("input")[0]; 20 | input.value = str; 21 | input.value .. assert.eq(str); 22 | input .. sendReturn(); 23 | } 24 | 25 | test.afterEach:: function(state) { 26 | if(state.console) state.console.shutdown(); 27 | }; 28 | 29 | // -------------------------------------------- 30 | 31 | test("leaves no elements behind", function() { 32 | var body = document.getElementsByTagName('body')[0]; 33 | // childElementCount not supported on IE7 34 | var elemCount = -> 'childElementCount' in body ? body.childElementCount : body.childNodes.length; 35 | var initial = elemCount(); 36 | assert.number(initial); 37 | 38 | var c = console(); 39 | c.shutdown(); 40 | 41 | assert.eq(elemCount(), initial); 42 | }); 43 | 44 | test("aborts its running strata on shutdown", function(s) { 45 | var c = s.console = console({collapsed:false}); 46 | var testState = window.testState = { count: 0 }; 47 | 48 | c .. exec("testState.logging = require('sjs:logging'); while(1) { testState.logging.info('LOOP'); testState.count++; hold(100); }"); 49 | hold(120); 50 | // after 120ms, should have run loop twice 51 | assert.eq(testState.count, 2); 52 | c.shutdown(); 53 | logging.info("shut down"); 54 | 55 | hold(20); 56 | assert.eq(testState.count, 2); 57 | }); 58 | 59 | }).browserOnly().ignoreLeaks('testState'); 60 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/workshop_in.php: -------------------------------------------------------------------------------- 1 | 23 | 24 | WORKSHOPHTML 25 | 26 | 59 | 60 | 63 | 64 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/deps/numeric/tools/Crypto-JS v2.4.0/crypto/crypto-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.4.0 3 | * http://code.google.com/p/crypto-js/ 4 | * Copyright (c) 2011, Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | if(typeof Crypto=="undefined"||!Crypto.util)(function(){var e=window.Crypto={},h=e.util={rotl:function(a,b){return a<>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return h.rotl(a,8)&16711935|h.rotl(a,24)&4278255360;for(var b=0;b0;a--)b.push(Math.floor(Math.random()*256));return b},bytesToWords:function(a){for(var b=[],c=0,d=0;c>>5]|=a[c]<<24- 8 | d%32;return b},wordsToBytes:function(a){for(var b=[],c=0;c>>5]>>>24-c%32&255);return b},bytesToHex:function(a){for(var b=[],c=0;c>>4).toString(16));b.push((a[c]&15).toString(16))}return b.join("")},hexToBytes:function(a){for(var b=[],c=0;c>>6*(3-g)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){if(typeof atob=="function")return f.stringToBytes(atob(a));a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var b=[],c=0,d=0;c>> 10 | 6-d*2);return b}};e=e.charenc={};e.UTF8={stringToBytes:function(a){return f.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(f.bytesToString(a)))}};var f=e.Binary={stringToBytes:function(a){for(var b=[],c=0;c0) { write(' '); } 6 | write(arguments[k]); } 7 | write('\n'); 8 | if(typeof system !== "undefined") { system.stdout.flush(); } 9 | } 10 | }; 11 | function XMLHttpRequest() { 12 | this.response = ""; 13 | if(typeof system !== "undefined") { 14 | this.open = function(get,url) { this.responseText = new Stream(url).readFile(); } 15 | } else { 16 | this.open = function(get,url) { this.responseText = read(url); } 17 | } 18 | this.send = function() {} 19 | } 20 | var foo; 21 | if(typeof system !== "undefined") { foo = new Stream('./documentation.html').readFile(); } 22 | else { foo = read('./documentation.html'); } 23 | var baz; 24 | if(typeof system !== "undefined") { baz = new Stream('./src/numeric.js').readFile(); } 25 | else { baz = read('./src/numeric.js'); } 26 | var ver = baz.match(/numeric.version[ =]*"([0-9.]*)".*/)[1] 27 | var bar = foo.match(/
[\s\S]*?(?=<\/pre>)/g).join('\n').replace(/
/g,'').split('\n> ')
28 | var baz = [];
29 | var k,k0=0;
30 | for(k=0;k0) { baz[k0] = [bar[k].substring(0,j),bar[k].substring(j+1)]; k0++; }
33 | }
34 | 
35 | load('./lib/numeric-'+ver+'.js');
36 | if(typeof numeric === "undefined") { throw new Error("Could not load numeric.js"); }
37 | var unit_pass = 0, unit_fail = 0;
38 | var a,b,msg;
39 | var k1 = 0;
40 | var workshop = {};
41 | for(k=0;k')));
47 |         foo = bar+foo;
48 |     } catch(e) { foo = e.toString(); }
49 |     a = foo.replace(/\s/g,'');
50 |     b = baz[k][1].replace(/\s/g,'');
51 |     if(a===b) {
52 |         msg = k1+" PASS "+baz[k][0]+"==>"+a+"==="+b;
53 |         unit_pass++;
54 |     } else {
55 |         msg = k1+" FAIL "+baz[k][0]+"==>"+a+"!=="+b;
56 |         unit_fail++;
57 |     }
58 |     console.log(msg);
59 | }
60 | console.log('unit2: '+k1+' tests, '+unit_pass+' pass and '+unit_fail+' fail.');
61 | 


--------------------------------------------------------------------------------
/modules/nodejs/rimraf.sjs:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'nodejs/rimraf' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * Version: '1.0.0'
 6 |  * http://onilabs.com/stratifiedjs
 7 |  *
 8 |  * (c) 2014-2016 Oni Labs, http://onilabs.com
 9 |  *
10 |  * This file is licensed under the terms of the MIT License:
11 |  *
12 |  * Permission is hereby granted, free of charge, to any person obtaining a copy
13 |  * of this software and associated documentation files (the "Software"), to deal
14 |  * in the Software without restriction, including without limitation the rights
15 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 |  * copies of the Software, and to permit persons to whom the Software is
17 |  * furnished to do so, subject to the following conditions:
18 |  *
19 |  * The above copyright notice and this permission notice shall be included in
20 |  * all copies or substantial portions of the Software.
21 |  *
22 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 |  * THE SOFTWARE.
29 |  *
30 |  */
31 | 
32 | /**
33 |   @module    rimraf
34 |   @summary   `rm -rf` for node (tracking the [rimraf library](https://github.com/isaacs/rimraf))
35 |   @home      sjs:nodejs/rimraf
36 |   @hostenv   nodejs
37 |   @desc
38 |     This module tracks the [rimraf](https://github.com/isaacs/rimraf) library by Isaac Z. Schlueter.
39 | */
40 | 'use strict';
41 | 
42 | /**
43 |   @function rimraf
44 |   @param {String} [path]
45 |   @summary Recursively remove the given `path`
46 | */
47 | 
48 | var dep = require('nodejs:rimraf');
49 | exports.rimraf = function() {
50 |   var args = Array.prototype.slice.call(arguments);
51 |   waitfor(var err, rv) {
52 |     // call original (JS) function with callback
53 |     dep.apply(null, args.concat([resume]));
54 |   }
55 |   if(err) throw err;
56 |   return rv;
57 | };
58 | 
59 | 


--------------------------------------------------------------------------------
/src/deps/sjcl/core/sjcl.js:
--------------------------------------------------------------------------------
 1 | /** @fileOverview Javascript cryptography implementation.
 2 |  *
 3 |  * Crush to remove comments, shorten variable names and
 4 |  * generally reduce transmission size.
 5 |  *
 6 |  * @author Emily Stark
 7 |  * @author Mike Hamburg
 8 |  * @author Dan Boneh
 9 |  */
10 | 
11 | "use strict";
12 | /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
13 | /*global document, window, escape, unescape */
14 | 
15 | /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
16 | var sjcl = {
17 |   /** @namespace Symmetric ciphers. */
18 |   cipher: {},
19 | 
20 |   /** @namespace Hash functions.  Right now only SHA256 is implemented. */
21 |   hash: {},
22 | 
23 |   /** @namespace Key exchange functions.  Right now only SRP is implemented. */
24 |   keyexchange: {},
25 |   
26 |   /** @namespace Block cipher modes of operation. */
27 |   mode: {},
28 | 
29 |   /** @namespace Miscellaneous.  HMAC and PBKDF2. */
30 |   misc: {},
31 |   
32 |   /**
33 |    * @namespace Bit array encoders and decoders.
34 |    *
35 |    * @description
36 |    * The members of this namespace are functions which translate between
37 |    * SJCL's bitArrays and other objects (usually strings).  Because it
38 |    * isn't always clear which direction is encoding and which is decoding,
39 |    * the method names are "fromBits" and "toBits".
40 |    */
41 |   codec: {},
42 |   
43 |   /** @namespace Exceptions. */
44 |   exception: {
45 |     /** @class Ciphertext is corrupt. */
46 |     corrupt: function(message) {
47 |       this.toString = function() { return "CORRUPT: "+this.message; };
48 |       this.message = message;
49 |     },
50 |     
51 |     /** @class Invalid parameter. */
52 |     invalid: function(message) {
53 |       this.toString = function() { return "INVALID: "+this.message; };
54 |       this.message = message;
55 |     },
56 |     
57 |     /** @class Bug or missing feature in SJCL. */
58 |     bug: function(message) {
59 |       this.toString = function() { return "BUG: "+this.message; };
60 |       this.message = message;
61 |     },
62 | 
63 |     /** @class Something isn't ready. */
64 |     notReady: function(message) {
65 |       this.toString = function() { return "NOT READY: "+this.message; };
66 |       this.message = message;
67 |     }
68 |   }
69 | };
70 | 
71 | if(typeof module != 'undefined' && module.exports){
72 |   module.exports = sjcl;
73 | }
74 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/Crypto-JS v2.4.0/sha1/sha1.js:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Crypto-JS v2.4.0
 3 |  * http://code.google.com/p/crypto-js/
 4 |  * Copyright (c) 2011, Jeff Mott. All rights reserved.
 5 |  * http://code.google.com/p/crypto-js/wiki/License
 6 |  */
 7 | (function(){
 8 | 
 9 | // Shortcuts
10 | var C = Crypto,
11 |     util = C.util,
12 |     charenc = C.charenc,
13 |     UTF8 = charenc.UTF8,
14 |     Binary = charenc.Binary;
15 | 
16 | // Public API
17 | var SHA1 = C.SHA1 = function (message, options) {
18 | 	var digestbytes = util.wordsToBytes(SHA1._sha1(message));
19 | 	return options && options.asBytes ? digestbytes :
20 | 	       options && options.asString ? Binary.bytesToString(digestbytes) :
21 | 	       util.bytesToHex(digestbytes);
22 | };
23 | 
24 | // The core
25 | SHA1._sha1 = function (message) {
26 | 
27 | 	// Convert to byte array
28 | 	if (message.constructor == String) message = UTF8.stringToBytes(message);
29 | 	/* else, assume byte array already */
30 | 
31 | 	var m  = util.bytesToWords(message),
32 | 	    l  = message.length * 8,
33 | 	    w  =  [],
34 | 	    H0 =  1732584193,
35 | 	    H1 = -271733879,
36 | 	    H2 = -1732584194,
37 | 	    H3 =  271733878,
38 | 	    H4 = -1009589776;
39 | 
40 | 	// Padding
41 | 	m[l >> 5] |= 0x80 << (24 - l % 32);
42 | 	m[((l + 64 >>> 9) << 4) + 15] = l;
43 | 
44 | 	for (var i = 0; i < m.length; i += 16) {
45 | 
46 | 		var a = H0,
47 | 		    b = H1,
48 | 		    c = H2,
49 | 		    d = H3,
50 | 		    e = H4;
51 | 
52 | 		for (var j = 0; j < 80; j++) {
53 | 
54 | 			if (j < 16) w[j] = m[i + j];
55 | 			else {
56 | 				var n = w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16];
57 | 				w[j] = (n << 1) | (n >>> 31);
58 | 			}
59 | 
60 | 			var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (
61 | 			         j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :
62 | 			         j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :
63 | 			         j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :
64 | 			                  (H1 ^ H2 ^ H3) - 899497514);
65 | 
66 | 			H4 =  H3;
67 | 			H3 =  H2;
68 | 			H2 = (H1 << 30) | (H1 >>> 2);
69 | 			H1 =  H0;
70 | 			H0 =  t;
71 | 
72 | 		}
73 | 
74 | 		H0 += a;
75 | 		H1 += b;
76 | 		H2 += c;
77 | 		H3 += d;
78 | 		H4 += e;
79 | 
80 | 	}
81 | 
82 | 	return [H0, H1, H2, H3, H4];
83 | 
84 | };
85 | 
86 | // Package private blocksize
87 | SHA1._blocksize = 16;
88 | 
89 | SHA1._digestsize = 20;
90 | 
91 | })();
92 | 


--------------------------------------------------------------------------------
/src/deps/fetch-external-deps:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/env sjs
 2 | // vim: syntax=sjs
 3 | 
 4 | var path = require('path');
 5 | var fs      = require('sjs:nodejs/fs');
 6 | var childProcess    = require('sjs:nodejs/child-process');
 7 | var prompt    = require('sjs:debug').prompt;
 8 | var { merge } = require('sjs:object');
 9 | @ = require('sjs:sequence');
10 | 
11 | var run = function(cmd, args, opts) {
12 |   console.log(" + #{cmd} #{args.join(' ')}");
13 |   return childProcess.run(cmd, args, ({stdio:'inherit'} .. merge(opts)));
14 | }
15 | 
16 | // make sure we're in the right directory
17 | var here = path.dirname(process.argv[1]);
18 | process.chdir(here);
19 | 
20 | var sources = getSources();
21 | for (var i=0; i line.length > 0)
25 |     // .. @monitor(x -> console.log(JSON.stringify(x)))
26 |     .. @map(line -> line[1]) // extract just the Y column of status (working copy state). It's OK if we have staged changes.
27 |     .. @filter(st -> st != ' ')
28 |     .. @toArray;
29 |   if (changes.length !== 0) {
30 |     console.log('directory '+src.dir+' not clean -> ignoring');
31 |     continue;
32 |   }
33 |   if (fs.exists(src.dir+'.git')) {
34 |     console.log('directory '+src.dir+' already contains a git repository -> ignoring');
35 |     continue;
36 |   }
37 |   var fullpath = path.join(here, src.dir);
38 |   console.log("Replacing directory #{fullpath} with github repository at #{src.repo}");
39 |   if (prompt('Sure you want to proceed? [y/N] ').toLowerCase() != 'y') {
40 |     console.log('Skipping '+fs.realpath(src.dir));
41 |     continue;
42 |   }
43 |   run('rm', ['-rf', src.dir]);
44 |   console.log('Cloning external repo');
45 |   run('git', ['clone', src.repo, src.dir]);
46 |   console.log('Checking out revision '+src.commit);
47 |   run('git', ['checkout', src.commit], {cwd: src.dir});
48 |   console.log('Reapplying our patches');
49 |   run('git', ['checkout', '--', src.dir]);
50 | }
51 | 
52 | 
53 | // helpers:
54 | 
55 | function getSources() {
56 |   var src = fs.readFile('sources.txt').toString().split("\n");
57 |   var matches, rv = [];
58 |   for (var i=0; iresume(x, false), x->resume(x,true));
38 |     }
39 |     if (except) throw rv;
40 |     return rv;
41 |   }
42 |   return val;
43 | }
44 | 
45 | 
46 | 
47 | /**
48 |   @module    mkdirp
49 |   @summary   Recursively make directories (tracking the [mkdirp library](https://github.com/substack/node-mkdirp))
50 |   @home      sjs:nodejs/mkdirp
51 |   @hostenv   nodejs
52 | */
53 | 'use strict';
54 | 
55 | /**
56 |   @function mkdirp
57 |   @param {String} [path]
58 |   @summary Ensure `path` (and any parent directories) exist
59 |   @desc
60 |     If `path` already exists and is a directory, `mkdirp` returns successfully.
61 | */
62 | var dep = require('nodejs:mkdirp');
63 | exports.mkdirp = function(...args) {
64 |   return AWAIT:: dep.apply(null,args);
65 | }
66 | 


--------------------------------------------------------------------------------
/src/bootstrap/apollo-bootstrap-xbrowser.js:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS bootstrap code, hostenv-specific part
 3 |  *
 4 |  * Cross-browser ('xbrowser') version
 5 |  *
 6 |  * Part of the StratifiedJS Runtime
 7 |  * http://onilabs.com/stratifiedjs
 8 |  *
 9 |  * (c) 2011-2022 Oni Labs, http://onilabs.com
10 |  *
11 |  * This file is licensed under the terms of the MIT License:
12 |  *
13 |  * Permission is hereby granted, free of charge, to any person obtaining a copy
14 |  * of this software and associated documentation files (the "Software"), to deal
15 |  * in the Software without restriction, including without limitation the rights
16 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 |  * copies of the Software, and to permit persons to whom the Software is
18 |  * furnished to do so, subject to the following conditions:
19 |  *
20 |  * The above copyright notice and this permission notice shall be included in
21 |  * all copies or substantial portions of the Software.
22 |  *
23 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 |  * THE SOFTWARE.
30 |  *
31 |  */
32 | 
33 | if (!__oni_rt.sys) {
34 |   
35 |   //----------------------------------------------------------------------
36 |   // Install SJS system module ('builtin:apollo-sys'). Bootstrapping will be
37 |   // run from there.
38 |   // The system module is spread over two parts: the 'common' part, and the
39 |   // 'hostenv' specific part. 
40 |   // hostenv is one of : 'xbrowser' | 'nodejs' 
41 |   __oni_rt.G.eval("(function(exports) {"+
42 |                   __oni_rt.c1.compile(__oni_rt.modsrc['builtin:apollo-sys-common.sjs'],
43 |                                       {filename:"'apollo-sys-common.sjs'"})+"\n"+
44 |                   __oni_rt.c1.compile(__oni_rt.modsrc['builtin:apollo-sys-'+__oni_rt.hostenv+'.sjs'],
45 |                                       {filename:"'apollo-sys-"+__oni_rt.hostenv+".sjs'"})+
46 |                  "})({})");
47 |   delete __oni_rt.modsrc['builtin:apollo-sys-common.sjs'];
48 |   delete __oni_rt.modsrc['builtin:apollo-sys-'+__oni_rt.hostenv+'.sjs']; 
49 | }
50 | 
51 | 
52 | 
53 | 


--------------------------------------------------------------------------------
/src/deps/node-terminal/README.md:
--------------------------------------------------------------------------------
 1 | # Terminal
 2 | 
 3 | Terminal is a small package that can be used with [node.js](http://nodejs.org) to control terminal output. The package can move the cursor in the terminal and output colored text. It can colorize a message with a simple straightforward markup syntax.
 4 | 
 5 | # Examples
 6 | 
 7 | Some examples from the `examples` directory. 
 8 | 
 9 | ## Colors
10 | 
11 | Control colored output. See also `examples/colors.js`. Colors may vary depending on the terminal settings.
12 | 
13 | Simple color changing:
14 |     
15 |     terminal.color('magenta').write('Unicorn');
16 | 
17 | This will output `Unicorn` in magenta (or purple). To change the background color to magenta:
18 | 
19 |     terminal.color('magenta', 'background').write('Unicorn');
20 | 
21 | ### Color formatting
22 | 
23 | `Terminal` supports formatting strings with colors using a simple syntax. Outputting `Unicorn` in magenta (like the example above) would look like this:
24 | 
25 |     terminal.colorize('%mUnicorn');
26 |     
27 |     // And changing the background color to magenta
28 |     terminal.colorize('%5Unicorn');
29 | 
30 | Using this syntax we can create `Rainbows` easily in one line:
31 | 
32 |     terminal.colorize('%rR%ma%ci%bn%yb%go%rw\n');
33 |     
34 |     // Or with background colors
35 |     terminal.colorize('%w%1  R  %2  A  %3  I  %4  N  %5  B  %6  O  %7  W  %n ');
36 | 
37 | The colorize function accepts the following modifiers:
38 | 
39 |                       text      text            background
40 |           ------------------------------------------------
41 |           %k %K %0    black     dark grey       black
42 |           %r %R %1    red       bold red        red
43 |           %g %G %2    green     bold green      green
44 |           %y %Y %3    yellow    bold yellow     yellow
45 |           %b %B %4    blue      bold blue       blue
46 |           %m %M %5    magenta   bold magenta    magenta
47 |           %p %P       magenta (think: purple)
48 |           %c %C %6    cyan      bold cyan       cyan
49 |           %w %W %7    white     bold white      white
50 |     
51 |           %F     Blinking, Flashing
52 |           %U     Underline
53 |           %8     Reverse
54 |           %_,%9  Bold
55 |     
56 |           %n,%N  Resets the color
57 |           %%     A single %
58 | 
59 | Colored ouput can be reset with the `reset` function:
60 | 
61 |     terminal.color('red').write('This is red,').reset().write(' and this is not');
62 | # License
63 | 
64 | Terminal is licensed under The MIT License
65 | 
66 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/selenium_tests.py:
--------------------------------------------------------------------------------
 1 | from selenium import webdriver
 2 | from selenium.common.exceptions import TimeoutException
 3 | from selenium.webdriver.support.ui import WebDriverWait
 4 | import time
 5 | import traceback
 6 | import sys
 7 | import urllib
 8 | import re
 9 | 
10 | def test(name,driver):
11 |     p = 0
12 |     f = 0
13 |     t = 0
14 |     try:
15 |         for k in range(len(tests)):
16 |             t=t+1
17 |             foo = ""
18 |             try:
19 |                 input = driver.find_element_by_id("text_"+str(k+1))
20 |                 input.send_keys(tests[k][0]+'\n')
21 |                 bar = "out_"+str(k+1)
22 |                 WebDriverWait(driver,5).until(lambda driver: driver.find_element_by_id(bar).text not in ["",""])
23 |                 output = driver.find_element_by_id(bar)
24 |                 foo = re.sub(r'\s','',output.text)
25 |                 if(tests[k][1][0:6]=="Error:"):
26 |                     foo = foo[0:len(tests[k][1])]
27 |                 assert(foo == tests[k][1])
28 |                 print k,"PASS:",tests[k][0],'==>',foo
29 |                 p=p+1
30 |             except Exception as ex:
31 |                 print k,"FAIL:",tests[k][0],'==>',foo,"reason:",ex
32 |                 f=f+1
33 |         print name,'testing complete. PASS:',p,'FAIL:',f,'Total:',t
34 |     except:
35 |         print "FAIL: "+name+" selenium tests. Details:"
36 |         traceback.print_exc()
37 | 
38 | url = ""
39 | if len(sys.argv) > 1:
40 |     client = sys.argv[1]
41 |     if(len(sys.argv)>2):
42 |         url = sys.argv[2]
43 | else:
44 |     client = "Firefox"
45 | 
46 | if url == "":
47 |     url = "http://127.0.0.1/staging/"
48 | 
49 | u0 = url + 'documentation.html'
50 | print 'Fetching',u0
51 | njs = urllib.urlopen(u0).read()
52 | y = re.findall(r'
[\s\S]*?(?=<\/pre>)',njs)
53 | tests = [];
54 | 
55 | print "In-browser unit tests."
56 | for x in y:
57 |     baz = x.split('\n> ')[1:]
58 |     for foo in baz:
59 |         bar = foo.find('\n')
60 |         tests.append((foo[0:bar],re.sub(r'\s','',foo[bar+1:])))
61 | driver=0
62 | try:
63 |     driver = eval('webdriver.'+client+'()')
64 |     print "Using",client
65 |     driver.implicitly_wait(2)
66 |     driver.get(url+'workshop.php')
67 |     try:
68 |         WebDriverWait(driver, 30).until(lambda driver : driver.find_element_by_id("text_1"))
69 |         test(client,driver)
70 |     except Exception as ex:
71 |         print "FAIL: text_1 not found. ",ex
72 | except:
73 |     print "Could not use browser",client
74 | if(driver):
75 |     driver.quit()
76 | 


--------------------------------------------------------------------------------
/src/deps/dashdash/apollo-module-header.txt:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'dashdash' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * Version: 'unstable'
 6 |  * http://onilabs.com/stratifiedjs
 7 |  *
 8 |  * (c) 2013 Oni Labs, http://onilabs.com
 9 |  *
10 |  *
11 |  *   ***************************************************************
12 |  *   *    DO NOT EDIT dashdash.sjs - IT IS A GENERATED FILE!       *
13 |  *   *    EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN *
14 |  *   *    stratifiedjs/src/build/make-sjs                          *
15 |  *   ***************************************************************
16 |  *
17 |  *
18 |  * This file is derived from the "dashdash" project
19 |  * (https://github.com/trentm/node-dashdash),
20 |  * which is available under the terms of the MIT License.
21 |  *
22 |  * Original License Text:
23 |  *
24 |  * # This is the MIT license
25 |  *
26 |  * Copyright (c) 2013 Trent Mick. All rights reserved.
27 |  * Copyright (c) 2013 Joyent Inc. All rights reserved.
28 |  *
29 |  * Permission is hereby granted, free of charge, to any person obtaining a
30 |  * copy of this software and associated documentation files (the
31 |  * "Software"), to deal in the Software without restriction, including
32 |  * without limitation the rights to use, copy, modify, merge, publish,
33 |  * distribute, sublicense, and/or sell copies of the Software, and to
34 |  * permit persons to whom the Software is furnished to do so, subject to
35 |  * the following conditions:
36 |  *
37 |  * The above copyright notice and this permission notice shall be included
38 |  * in all copies or substantial portions of the Software.
39 |  *
40 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
41 |  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42 |  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43 |  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
44 |  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45 |  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
46 |  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 |  */
48 | 
49 | /**
50 |   @module    dashdash
51 |   @summary   Options parser (tracking the [node-dashdash library](https://github.com/trentm/node-dashdash))
52 |   @home      sjs:dashdash
53 |   @desc
54 |     This module tracks the [dashdash](https://github.com/trentm/node-dashdash) library by Trent Mick.
55 |     The original library is written for node.js, but this version works in all environments.
56 | 
57 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/Crypto-JS v2.4.0/rabbit/rabbit-min.js:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Crypto-JS v2.4.0
 3 |  * http://code.google.com/p/crypto-js/
 4 |  * Copyright (c) 2011, Jeff Mott. All rights reserved.
 5 |  * http://code.google.com/p/crypto-js/wiki/License
 6 |  */
 7 | (function(){var j=Crypto,g=j.util,l=j.charenc.UTF8,d=[],b=[],k,i=j.Rabbit={encrypt:function(a,c){var f=l.stringToBytes(a),e=g.randomBytes(8),h=c.constructor==String?j.PBKDF2(c,e,32,{asBytes:true}):c;i._rabbit(f,h,g.bytesToWords(e));return g.bytesToBase64(e.concat(f))},decrypt:function(a,c){var f=g.base64ToBytes(a),e=f.splice(0,8),h=c.constructor==String?j.PBKDF2(c,e,32,{asBytes:true}):c;i._rabbit(f,h,g.bytesToWords(e));return l.bytesToString(f)},_rabbit:function(a,c,f){i._keysetup(c);f&&i._ivsetup(f);
 8 | c=[];for(f=0;f>>16^d[3]<<16;c[1]=d[2]^d[7]>>>16^d[5]<<16;c[2]=d[4]^d[1]>>>16^d[7]<<16;c[3]=d[6]^d[3]>>>16^d[1]<<16;for(var e=0;e<4;e++)c[e]=(c[e]<<8|c[e]>>>24)&16711935|(c[e]<<24|c[e]>>>8)&4278255360;for(e=120;e>=0;e-=8)c[e/8]=c[e>>>5]>>>24-e%32&255}a[f]^=c[f%16]}},_keysetup:function(a){d[0]=a[0];d[2]=a[1];d[4]=a[2];d[6]=a[3];d[1]=a[3]<<16|a[2]>>>16;d[3]=a[0]<<16|a[3]>>>16;d[5]=a[1]<<16|a[0]>>>16;d[7]=a[2]<<16|a[1]>>>16;b[0]=g.rotl(a[2],16);
 9 | b[2]=g.rotl(a[3],16);b[4]=g.rotl(a[0],16);b[6]=g.rotl(a[1],16);b[1]=a[0]&4294901760|a[1]&65535;b[3]=a[1]&4294901760|a[2]&65535;b[5]=a[2]&4294901760|a[3]&65535;b[7]=a[3]&4294901760|a[0]&65535;for(a=k=0;a<4;a++)i._nextstate();for(a=0;a<8;a++)b[a]^=d[a+4&7]},_ivsetup:function(a){var c=g.endian(a[0]);a=g.endian(a[1]);var f=c>>>16|a&4294901760,e=a<<16|c&65535;b[0]^=c;b[1]^=f;b[2]^=a;b[3]^=e;b[4]^=c;b[5]^=f;b[6]^=a;b[7]^=e;for(c=0;c<4;c++)i._nextstate()},_nextstate:function(){for(var a=[],c=0;c<8;c++)a[c]=
10 | b[c];b[0]=b[0]+1295307597+k>>>0;b[1]=b[1]+3545052371+(b[0]>>>0>>0?1:0)>>>0;b[2]=b[2]+886263092+(b[1]>>>0>>0?1:0)>>>0;b[3]=b[3]+1295307597+(b[2]>>>0>>0?1:0)>>>0;b[4]=b[4]+3545052371+(b[3]>>>0>>0?1:0)>>>0;b[5]=b[5]+886263092+(b[4]>>>0>>0?1:0)>>>0;b[6]=b[6]+1295307597+(b[5]>>>0>>0?1:0)>>>0;b[7]=b[7]+3545052371+(b[6]>>>0>>0?1:0)>>>0;k=b[7]>>>0>>0?1:0;a=[];for(c=0;c<8;c++){var f=d[c]+b[c]>>>0,e=f&65535,h=f>>>16;a[c]=((e*e>>>17)+e*h>>>15)+h*h^((f&4294901760)*
11 | f>>>0)+((f&65535)*f>>>0)>>>0}d[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16);d[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7];d[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16);d[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1];d[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16);d[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3];d[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16);d[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]}}})();
12 | 


--------------------------------------------------------------------------------
/src/deps/dashdash/apollo-module-endheader.txt:
--------------------------------------------------------------------------------
 1 | 
 2 | */
 3 | 
 4 | /**
 5 |   @function parse
 6 |   @param {Settings} [settings]
 7 |   @setting {Object} [config]
 8 |   @setting {Array} [argv=require('sjs:sys').argv()]
 9 |   @setting {Object} [env]
10 |   @setting {Number} [slice=0]
11 |   @summary Parse an array of arguments.
12 |   @desc
13 |     Create a parser and parse the given `argv` (or [sys::argv]`()` if no
14 |     `argv` option is given).
15 | 
16 |     See the [dashdash::] module docs for more information and examples.
17 |  */
18 | 
19 | /**
20 |   @class Parser
21 |   @summary Use [::createParser] to create a Parser.
22 |   @function createParser
23 |   @param {Object} [config]
24 |   @param {Boolean} [interspersed] Default true.
25 |   @summary Create a [::Parser].
26 |   @desc
27 |     See the [dashdash::] module docs for more information and examples.
28 | 
29 |   @function Parser.parse
30 |   @summary Parse an array of arguments.
31 |   @param {optional Array} [argv=sys.argv()] Array of string arguments.
32 |   @param {Settings} [settings]
33 |   @setting {Array} [argv]
34 |   @setting {Object} [env]
35 |   @setting {Number} [slice=0]
36 |   @desc
37 |     `argv` should always be provided in a browser environment. In the
38 |     nodejs environment it may be omitted, in which case the arguments
39 |     will be taken from [sys::argv].
40 | 
41 |     See the [dashdash::] module docs for more information and examples.
42 | 
43 |   @function Parser.help
44 |   @param {Settings} [options]
45 |   @setting {Number|String} [indent] Number of indent spaces (or a string to be used)
46 |   @setting {Number} [maxCol] Maximum line width (default 80).
47 | 
48 |   @summary Return a help string for this parser.
49 |   @desc
50 |     Only the most commonly-used options are listed here.
51 |     See the [dashdash::] module docs for a full list of options.
52 |  */
53 | 
54 | 
55 | 
56 | /**
57 |   turn off docs from this point onwards:
58 |   @docsoff
59 | */
60 | 
61 | // prevent errors in xbrowser env
62 | var sys = require('builtin:apollo-sys');
63 | var global = sys.getGlobal();
64 | var process = sys.hostenv == 'xbrowser' ? {env: {}} : global.process;
65 | var assert = require('./assert');
66 | var { each, map, join, indexed } = require('./sequence');
67 | var { ownKeys, clone } = require('./object');
68 | 
69 | var format = function(str /*, replacements ... */) {
70 |     // upstream uses node.js' util/format function,
71 |     // which isn't available in the browser.
72 |     var str = arguments[0];
73 |     var idx = 1;
74 |     var args = arguments;
75 |     return str.replace(/%(.)/g, function(text, fmt) {
76 |         var obj = args[idx++];
77 |         if (fmt == 'j') return JSON.stringify(obj);
78 |         return String(obj);
79 |     });
80 | }
81 | 
82 | 


--------------------------------------------------------------------------------
/test/run.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     SJS tests
 5 |     
 6 |     
66 |   
67 | 
68 | 


--------------------------------------------------------------------------------
/src/deps/FileSaver.js/apollo-module-header.txt:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'filesaver' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * http://onilabs.com/stratifiedjs
 6 |  *
 7 |  * (c) 2015 Oni Labs, http://onilabs.com
 8 |  *
 9 |  *
10 |  *   ***************************************************************
11 |  *   *    DO NOT EDIT jsondiffpatch.sjs - IT IS A GENERATED FILE!  *
12 |  *   *    EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN *
13 |  *   *    stratifiedjs/src/build/make-sjs                          *
14 |  *   ***************************************************************
15 |  *
16 |  *
17 |  * This file is derived from the "FileSaver.js" project 
18 |  * (https://github.com/eligrey/FileSaver.js.git), 
19 |  * which is available under the terms of the MIT License.
20 |  *
21 |  * Original License Text:
22 |  *
23 |  *  Copyright © 2015 Eli Grey.
24 |  *
25 |  *  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
26 |  *
27 |  *  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
28 |  *
29 |  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |  */
31 | 
32 | /**
33 |   @module    filesaver
34 |   @summary   Blob saveAs() functionality
35 |   @home      sjs:xbrowser/filesaver
36 |   @hostenv   xbrowser
37 |   @desc      
38 |              This module tracks the [FileSaver.js](https://github.com/eligrey/FileSaver.js) by Eli Grey
39 | */
40 | 
41 | /**
42 |     @function saveAs
43 |     @summary  Open a 'Save As' dialog for the given Blob
44 |     @param {Blob} [data]
45 |     @param {String} [filename]
46 |     @param {optional Boolean} [disableAutoBOM=false] If this flag is `true`, no Unicode byte order marks will be applied
47 |     @desc
48 |           * Note that this function will return immediately and not wait for the download to complete.
49 |           * Note also the limitations listed at https://github.com/eligrey/FileSaver.js.
50 | */
51 | 
52 | /**
53 |   turn off docs from this point onwards:
54 |   @docsoff
55 | */
56 | __js {
57 | 


--------------------------------------------------------------------------------
/modules/nodejs/gzip.sjs:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'nodejs/gzip' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * Version: '1.0.0'
 6 |  * http://onilabs.com/stratifiedjs
 7 |  *
 8 |  * (c) 2014-2016 Oni Labs, http://onilabs.com
 9 |  *
10 |  * This file is licensed under the terms of the MIT License:
11 |  *
12 |  * Permission is hereby granted, free of charge, to any person obtaining a copy
13 |  * of this software and associated documentation files (the "Software"), to deal
14 |  * in the Software without restriction, including without limitation the rights
15 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 |  * copies of the Software, and to permit persons to whom the Software is
17 |  * furnished to do so, subject to the following conditions:
18 |  *
19 |  * The above copyright notice and this permission notice shall be included in
20 |  * all copies or substantial portions of the Software.
21 |  *
22 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 |  * THE SOFTWARE.
29 |  *
30 |  */
31 | /**
32 |   @module    nodejs/gzip
33 |   @summary   Gzip compression / decompression for SJS streams.
34 |   @hostenv   nodejs
35 | */
36 | 'use strict';
37 | 
38 | var zlib = require('nodejs:zlib');
39 | @ = require(['../sequence', './stream', '../event']);
40 | 
41 | /**
42 |   @function decompress
43 |   @summary  gunzip (decompress) stream transformer
44 |   @param    {sequence::Stream} [src] compressed stream
45 |   @param    {optional Settings} [opts] opts for [./stream::pump]
46 |   @return   {sequence::Stream} decompressed stream
47 | */
48 | exports.decompress = function(stream, opts) {
49 |   return @Stream(function(emit) {
50 |     var gunzipStream = zlib.createGunzip();
51 |     waitfor {
52 |       stream .. @pump(gunzipStream);
53 |     } and {
54 |       gunzipStream .. @contents .. @each(emit);
55 |     }
56 |   });
57 | }
58 | 
59 | /**
60 |   @function compress
61 |   @summary  gzip (compress) stream transformer
62 |   @param    {sequence::Stream} [src] data stream
63 |   @param    {optional Settings} [opts] opts for [./stream::pump]
64 |   @return   {sequence::Stream} compressed stream
65 | */
66 | exports.compress = function(stream, opts) {
67 |   return @Stream(function(emit) {
68 |     var gzipStream = zlib.createGzip();
69 |     waitfor {
70 |       stream .. @pump(gzipStream);
71 |     } and {
72 |       gzipStream .. @contents .. @each(emit);
73 |     }
74 |   });
75 | }
76 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/Crypto-JS v2.4.0/blockmodes/blockmodes-min.js:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Crypto-JS v2.4.0
 3 |  * http://code.google.com/p/crypto-js/
 4 |  * Copyright (c) 2011, Jeff Mott. All rights reserved.
 5 |  * http://code.google.com/p/crypto-js/wiki/License
 6 |  */
 7 | (function(h){function l(c,a){var b=c._blocksize*4;return b-a.length%b}var j=h.pad={},g=function(c){for(var a=c.pop(),b=1;b0;d--)a.push(0)},unpad:function(){}};j.iso7816={pad:function(c,a){var b=l(c,a);for(a.push(128);b>1;b--)a.push(0)},unpad:function(c){for(;c.pop()!=128;);}};j.ansix923={pad:function(c,a){for(var b=l(c,a),d=1;d process.stdout.write(s)
67 | }
68 | 


--------------------------------------------------------------------------------
/test/unit/quasi-tests.sjs:
--------------------------------------------------------------------------------
 1 | var testUtil = require('../lib/testUtil');
 2 | var test = testUtil.test;
 3 | var {context, assert} = require('sjs:test/suite');
 4 | 
 5 | var { Quasi, isQuasi, joinQuasis, mapQuasi } = require("sjs:quasi");
 6 | var { Stream } = require('sjs:sequence');
 7 | 
 8 | context("syntax", function() {
 9 |   test('braced quasi', ["", 1], function() { var x=1; return `${x}`.parts});
10 |   test('escaping quasi interpolation', ["${var}"], function() { return `\${var}`.parts});
11 |   test('quasis without braces', ["", 1], function() { var x=1; return `$x`.parts});
12 |   test('quasi calls without braces', ["", 4, ".toString()"], function() { var x= (y) -> y + 1; return `$x(3).toString()`.parts});
13 |   test('quasi accessors without braces', ["", 1, ".toString()"], function() { var x= 1; return `$x.toString()`.parts});
14 | })
15 | 
16 | context("isQuasi", function() {
17 |   test('isQuasi(``)', true, function() { return isQuasi(``); });
18 |   test('isQuasi(`foo`)', true, function() { return isQuasi(`foo`); });
19 |   test('isQuasi(`foo${"bar"}baz`)', true, function() { return isQuasi(`foo${"bar"}baz`); });
20 |   test('isQuasi("")', false, function() { return isQuasi(''); });
21 |   test('isQuasi([])', false, function() { return isQuasi([]); });
22 |   test('isQuasi({})', false, function() { return isQuasi({}); });
23 |   test('isQuasi({parts:[]})', false, function() { return isQuasi({parts:[]}); });
24 | 
25 |   test('isQuasi(Quasi([]))', true, function() { return isQuasi(Quasi([])); });
26 |   test('isQuasi(Quasi(["a", 1, "b"]))', true, function() { return isQuasi(Quasi(['a', 1, 'b'])); });
27 | })
28 | 
29 | context("Quasi constructor", function() {
30 |   test('Quasi(["a", 1, "b"]) equals `a${1}b`', `a${1}b`, function() {
31 |     return Quasi(['a', 1, 'b']);
32 |   });
33 | })
34 | 
35 | context("join", function() {
36 |   test('joinQuasis(``,``) equals ``', ``, function() { return joinQuasis(``,``); });
37 |   test('joinQuasis(`a${1}`,`b`) equals `a${1}b`', `a${1}b`, function() { return joinQuasis(`a${1}`,`b`); });
38 |   test('joinQuasis(`a`,`${2}b`) equals `a${2}b`', `a${2}b`, function() { return joinQuasis(`a`,`${2}b`); });
39 |   test('joinQuasis(`a${1}`,`${2}b`) equals `a${1}${2}b`', `a${1}${2}b`, function() { return joinQuasis(`a${1}`,`${2}b`); });
40 |   test('joinQuasis(`a${1}`,`${2}b`, `${3}`) equals `a${1}${2}b${3}`', `a${1}${2}b${3}`, function() { return joinQuasis(`a${1}`,`${2}b`, `${3}`); });
41 |   test('joinQuasis on a sequence', `a${1}${2}b${3}`, function() {
42 |     var seq = Stream:: function(e) {
43 |       e(`a${1}`);
44 |       e(`${2}b`);
45 |       e(`${3}`);
46 |     }
47 |     return joinQuasis(seq);
48 |   });
49 | })
50 | 
51 | context("map", function() {
52 |   test('mapQuasi(`start${0}middle${1}end`, (v) -> v + 1)', ["start",1,"middle",2,"end"], function() { return mapQuasi(`start${0}middle${1}end`, function(val) { return val + 1; }); });
53 | })
54 | 


--------------------------------------------------------------------------------
/src/deps/moment/apollo-module-header.txt:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'moment' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * http://onilabs.com/stratifiedjs
 6 |  *
 7 |  * (c) 2015 Oni Labs, http://onilabs.com
 8 |  *
 9 |  *
10 |  *   ***************************************************************
11 |  *   *    DO NOT EDIT moment.sjs - IT IS A GENERATED FILE!         *
12 |  *   *    EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN *
13 |  *   *    stratifiedjs/src/build/make-sjs                          *
14 |  *   ***************************************************************
15 |  *
16 |  *
17 |  * This file is derived from the "http://momentjs.com" project, 
18 |  * which is available under the terms of the MIT License.
19 |  *
20 |  * Original License Text:
21 |  *
22 |  *  Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors
23 |  *
24 |  *  Permission is hereby granted, free of charge, to any person
25 |  *  obtaining a copy of this software and associated documentation
26 |  *  files (the "Software"), to deal in the Software without
27 |  *  restriction, including without limitation the rights to use,
28 |  *  copy, modify, merge, publish, distribute, sublicense, and/or sell
29 |  *  copies of the Software, and to permit persons to whom the
30 |  *  Software is furnished to do so, subject to the following
31 |  *  conditions:
32 |  * 
33 |  *  The above copyright notice and this permission notice shall be
34 |  *  included in all copies or substantial portions of the Software.
35 |  * 
36 |  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 |  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
38 |  *  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 |  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
40 |  *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 |  *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 |  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 |  *  OTHER DEALINGS IN THE SOFTWARE.
44 |  */
45 | 
46 | /**
47 |   @module    moment
48 |   @summary   Parsing, validating, manipulating and displaying dates
49 |   @home      sjs:moment
50 |   @desc      
51 |              This module tracks the [momentjs](https://github.com/moment/moment/) library (version 2.22.2 without locale bundles).
52 | 
53 |              ### Usage
54 | 
55 |              There are no exported symbols from this module. The return value of `require('sjs:moment')` is itself a function, as documented at http://momentjs.com.
56 | 
57 |              If you need timezone support, you should use [./moment-timezone::] instead.
58 |              Requireing the latter also amends any previously loaded 'moment' module with
59 |              timezone functionality.
60 | */
61 | 
62 | /**
63 |   turn off docs from this point onwards:
64 |   @docsoff
65 | */
66 | __js {
67 | 


--------------------------------------------------------------------------------
/test/lib/testUtil.sjs:
--------------------------------------------------------------------------------
 1 | var suite = require("sjs:test/suite");
 2 | var seq = require("sjs:sequence");
 3 | var assert = suite.assert;
 4 | var isBrowser = exports.isBrowser = suite.isBrowser;
 5 | 
 6 | // TODO: do we need a public API for printing to the results line?
 7 | var print = isBrowser ? (s) -> require('sjs:test/reporter').HtmlOutput.instance.print(s, false) : (s) -> process.stdout.write(s);
 8 | 
 9 | var isIE = exports.isIE = suite.isIE;
10 | exports.at_least_IE = function(min_version) {
11 |   if (!isIE()) return true;
12 |   return IE_version() >= min_version;
13 | }
14 | 
15 | var IE_version = exports.IE_version = suite.ieVersion;
16 | 
17 | /*
18 |  * TODO: remove uses of this function, or at least rename it to `testEq`
19 |  */
20 | exports.test = function test(name, expected, f) {
21 |   return suite.test(name, function() {
22 |     assert.eq(f(), expected);
23 |   })
24 | }
25 | 
26 | /**
27 |  * Test the return value of `fn` (ctx[method]) against an expected value
28 |  * If args is not an array, it's taken as a single argument. Otherwise, an array of arguments.
29 |  *
30 |  * If ctx is not given, `method` should be a function object (rather than a propety name).
31 |  */
32 | exports.testFn = function(ctx /* optional */, method, args, expected) {
33 |   var fn;
34 |   if (arguments.length < 4) {
35 |     // no ctx provided, methodName is the function
36 |     [fn, args, expected] = arguments;
37 |     ctx = null;
38 |     method = null;
39 |   } else {
40 |     fn = ctx[method];
41 |   }
42 |   if (!Array.isArray(args)) args = [args];
43 |   var args_desc = args .. seq.map(JSON.stringify) .. seq.join(", ");
44 |   var desc = method ? "#{method}(#{args_desc})" : args_desc;
45 |   return suite.test(desc, function() {
46 |     assert.eq(fn.apply(ctx, args), expected);
47 |   })
48 | }
49 | 
50 | exports.testParity = function testParity(expr, f) {
51 |   return suite.test("parity: " + expr, function() {
52 |     var expected;
53 |     try {
54 |       expected = eval(expr);
55 |     }
56 |     catch (e) {
57 |       expected = e;
58 |     }
59 |     var actual;
60 |     try {
61 |       actual = f();
62 |     }
63 |     catch (e) {
64 |       actual = e;
65 |     }
66 |     assert.eq(actual, expected);
67 |   })
68 | }
69 | 
70 | exports.time = function time(name, f) {
71 |   return suite.test('time: ' + name, function() {
72 |     var start = new Date();
73 |     f();
74 |     var duration = (new Date()) - start;
75 |     print(duration + "ms ");
76 |   })
77 | }
78 | 
79 | exports.testCompilation = function testCompilation(name, src) {
80 |   return suite.test('compile: ' + name, function() {
81 |     var insize = src.length;
82 |     var start = new Date();
83 |     for (var i=0; i<10; ++i)
84 |       var outsize = __oni_rt.c1.compile(src).length;
85 |     var duration = (new Date()) - start;
86 |     print("in: " + insize + " byte, out: " + outsize + " byte, duration(*10): " + duration + "ms ");
87 |   })
88 | }
89 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/Crypto-JS v2.4.0/marc4/marc4.js:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * Crypto-JS v2.4.0
  3 |  * http://code.google.com/p/crypto-js/
  4 |  * Copyright (c) 2011, Jeff Mott. All rights reserved.
  5 |  * http://code.google.com/p/crypto-js/wiki/License
  6 |  */
  7 | (function(){
  8 | 
  9 | // Shortcuts
 10 | var C = Crypto,
 11 |     util = C.util,
 12 |     charenc = C.charenc,
 13 |     UTF8 = charenc.UTF8,
 14 |     Binary = charenc.Binary;
 15 | 
 16 | var MARC4 = C.MARC4 = {
 17 | 
 18 | 	/**
 19 | 	 * Public API
 20 | 	 */
 21 | 
 22 | 	encrypt: function (message, password) {
 23 | 
 24 | 		var
 25 | 
 26 | 		    // Convert to bytes
 27 | 		    m = UTF8.stringToBytes(message),
 28 | 
 29 | 		    // Generate random IV
 30 | 		    iv = util.randomBytes(16),
 31 | 
 32 | 		    // Generate key
 33 | 		    k = password.constructor == String ?
 34 | 		        // Derive key from passphrase
 35 | 		        C.PBKDF2(password, iv, 32, { asBytes: true }) :
 36 | 		        // else, assume byte array representing cryptographic key
 37 | 		        password;
 38 | 
 39 | 		// Encrypt
 40 | 		MARC4._marc4(m, k, 1536);
 41 | 
 42 | 		// Return ciphertext
 43 | 		return util.bytesToBase64(iv.concat(m));
 44 | 
 45 | 	},
 46 | 
 47 | 	decrypt: function (ciphertext, password) {
 48 | 
 49 | 		var
 50 | 
 51 | 		    // Convert to bytes
 52 | 		    c = util.base64ToBytes(ciphertext),
 53 | 
 54 | 		    // Separate IV and message
 55 | 		    iv = c.splice(0, 16),
 56 | 
 57 | 		    // Generate key
 58 | 		    k = password.constructor == String ?
 59 | 		        // Derive key from passphrase
 60 | 		        C.PBKDF2(password, iv, 32, { asBytes: true }) :
 61 | 		        // else, assume byte array representing cryptographic key
 62 | 		        password;
 63 | 
 64 | 		// Decrypt
 65 | 		MARC4._marc4(c, k, 1536);
 66 | 
 67 | 		// Return plaintext
 68 | 		return UTF8.bytesToString(c);
 69 | 
 70 | 	},
 71 | 
 72 | 
 73 | 	/**
 74 | 	 * Internal methods
 75 | 	 */
 76 | 
 77 | 	// The core
 78 | 	_marc4: function (m, k, drop) {
 79 | 
 80 | 		// State variables
 81 | 		var i, j, s, temp;
 82 | 
 83 | 		// Key setup
 84 | 		for (i = 0, s = []; i < 256; i++) s[i] = i;
 85 | 		for (i = 0, j = 0;  i < 256; i++) {
 86 | 
 87 | 			j = (j + s[i] + k[i % k.length]) % 256;
 88 | 
 89 | 			// Swap
 90 | 			temp = s[i];
 91 | 			s[i] = s[j];
 92 | 			s[j] = temp;
 93 | 
 94 | 		}
 95 | 
 96 | 		// Clear counters
 97 | 		i = j = 0;
 98 | 
 99 | 		// Encryption
100 | 		for (var k = -drop; k < m.length; k++) {
101 | 
102 | 			i = (i + 1) % 256;
103 | 			j = (j + s[i]) % 256;
104 | 
105 | 			// Swap
106 | 			temp = s[i];
107 | 			s[i] = s[j];
108 | 			s[j] = temp;
109 | 
110 | 			// Stop here if we're still dropping keystream
111 | 			if (k < 0) continue;
112 | 
113 | 			// Encrypt
114 | 			m[k] ^= s[(s[i] + s[j]) % 256];
115 | 
116 | 		}
117 | 
118 | 	}
119 | 
120 | };
121 | 
122 | })();
123 | 


--------------------------------------------------------------------------------
/test/unit/node/buffering_stream.js:
--------------------------------------------------------------------------------
 1 | var util = require('util');
 2 | var Duplex = require('stream').Duplex;
 3 | var WRITE_DELAY = 50;
 4 | var WRITE_TIME = 20;
 5 | var WRITE_BUFFER = 50;
 6 | 
 7 | //
 8 | // A buffering stream that acts kind of like gzip (but without compression) -
 9 | // writes will succeed fairly quickly until WRITE_BUFFER items are queued, after
10 | // which point writes will take WRITE_TIME.
11 | //
12 | // If any writes are pending, WRITE_DELAY ms later the chunks will be shifted
13 | // onfo the readable side of the stream, and emitted when requested by a _read()
14 | //
15 | var BufferingStream = function() {
16 | 	Duplex.call(this, {highWaterMark:1});
17 | 	this.chunks = [];
18 | 	this.pending = [];
19 | 	this.pendingMove = null;
20 | 	this.atCapacity = false;
21 | 	// this.on('readable', function() { console.log("* BufferingStream readable");});
22 | };
23 | util.inherits(BufferingStream, Duplex);
24 | 
25 | BufferingStream.prototype.end = function() {
26 | 	// console.log("BufferingStream end");
27 | 	Duplex.prototype.end.apply(this, arguments);
28 | 	this._write(null, null, function() { /* noop */});
29 | };
30 | 
31 | BufferingStream.prototype._read = function(size) {
32 | 	// console.log("_read");
33 | 	var self = this;
34 | 	self.atCapacity = false;
35 | 	
36 | 	// XXX if _read pushes items synchronously, `readable` events are emitted too late and cause premature EOF
37 | 	setTimeout(self.emitBufferedItems.bind(self), 0);
38 | 	// self.emitBufferedItems();
39 | };
40 | 
41 | BufferingStream.prototype.emitBufferedItems = function() {
42 | 	if(this.atCapacity) return;
43 | 	// if (this.chunks.length > 0) console.log('pumping up to ' + this.chunks.length + " readable chunks");
44 | 	while(this.chunks.length > 0) {
45 | 		// console.log("Emitting " + this.chunks[0]);
46 | 		if(!this.push(this.chunks.shift())) {
47 | 			// console.log("read buffer full; " + this.chunks.length + " chunks still buffered");
48 | 			this.atCapacity = true;
49 | 			break;
50 | 		}
51 | 	}
52 | };
53 | 
54 | BufferingStream.prototype._write = function(chunk, encoding, cb) {
55 | 	var self = this;
56 | 	// console.log("_write: ", chunk === null);
57 | 	// console.log("Appending " + chunk + " to " + this.pending.length + " pending chunks");
58 | 	self.pending.push(chunk);
59 | 	if(!self.pendingMove) {
60 | 		setTimeout(function() {
61 | 			// console.log("_moving " + self.pending.length + " onto " + (self.chunks.length));
62 | 			self.chunks = self.chunks.concat(self.pending);
63 | 			self.pending = [];
64 | 			self.pendingMove = false;
65 | 			self.emitBufferedItems();
66 | 		}, WRITE_DELAY);
67 | 		self.pendingMove = true;
68 | 	}
69 | 	if(self.pending.length > WRITE_BUFFER) {
70 | 		// console.log("pretend to be slow at writing...");
71 | 		setTimeout(function() { cb(); }, WRITE_TIME);
72 | 	} else {
73 | 		setImmediate(function() { cb(); });
74 | 	}
75 | };
76 | BufferingStream.prototype._id = 'BufferingStream';
77 | 
78 | exports.BufferingStream = BufferingStream;
79 | 


--------------------------------------------------------------------------------
/src/deps/numeric/tools/Crypto-JS v2.4.0/crypto-sha1/crypto-sha1.js:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Crypto-JS v2.4.0
 3 |  * http://code.google.com/p/crypto-js/
 4 |  * Copyright (c) 2011, Jeff Mott. All rights reserved.
 5 |  * http://code.google.com/p/crypto-js/wiki/License
 6 |  */
 7 | if(typeof Crypto=="undefined"||!Crypto.util)(function(){var k=window.Crypto={},l=k.util={rotl:function(a,c){return a<>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return l.rotl(a,8)&16711935|l.rotl(a,24)&4278255360;for(var c=0;c0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],b=0,d=0;b>>5]|=a[b]<<24-
 8 | d%32;return c},wordsToBytes:function(a){for(var c=[],b=0;b>>5]>>>24-b%32&255);return c},bytesToHex:function(a){for(var c=[],b=0;b>>4).toString(16));c.push((a[b]&15).toString(16))}return c.join("")},hexToBytes:function(a){for(var c=[],b=0;b>>6*(3-e)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){if(typeof atob=="function")return m.stringToBytes(atob(a));a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],b=0,d=0;b>>
10 | 6-d*2);return c}};k=k.charenc={};k.UTF8={stringToBytes:function(a){return m.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(m.bytesToString(a)))}};var m=k.Binary={stringToBytes:function(a){for(var c=[],b=0;b>5]|=128<<24-g%32;e[(g+64>>>9<<4)+15]=g;for(g=0;g>>31}p=(n<<5|n>>>27)+o+(d[f]>>>0)+(f<20?(h&i|~h&j)+1518500249:f<40?(h^i^j)+1859775393:f<60?(h&i|h&j|i&j)-1894007588:(h^i^j)-899497514);o=j;j=i;i=h<<30|h>>>2;h=n;n=p}n+=q;h+=r;i+=s;j+=t;o+=u}return[n,h,i,j,o]};b._blocksize=16;b._digestsize=20})();
13 | 


--------------------------------------------------------------------------------
/src/deps/html2canvas/apollo-module-header.txt:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'xbrowser/html2canvas' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * Version: 'unstable'
 6 |  * http://onilabs.com/stratifiedjs
 7 |  *
 8 |  * (c) 2014 Oni Labs, http://onilabs.com
 9 |  *
10 |  *
11 |  *   ***************************************************************
12 |  *   *    DO NOT EDIT xbrowser/html2canvas.sjs - IT IS A GENERATED FILE!       *
13 |  *   *    EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN *
14 |  *   *    stratifiedjs/src/build/make-sjs                          *
15 |  *   ***************************************************************
16 |  *
17 |  *
18 |  * This file is derived from the "html2canvas" project
19 |  * (https://github.com/niklasvh/html2canvas), available under
20 |  * the MIT license.
21 |  *
22 |  * Original License Text:
23 |  *
24 |  * Copyright (c) 2014 Niklas von Hertzen
25 |  * 
26 |  * Permission is hereby granted, free of charge, to any person
27 |  * obtaining a copy of this software and associated documentation
28 |  * files (the "Software"), to deal in the Software without
29 |  * restriction, including without limitation the rights to use,
30 |  * copy, modify, merge, publish, distribute, sublicense, and/or sell
31 |  * copies of the Software, and to permit persons to whom the
32 |  * Software is furnished to do so, subject to the following
33 |  * conditions:
34 |  * 
35 |  * The above copyright notice and this permission notice shall be
36 |  * included in all copies or substantial portions of the Software.
37 |  * 
38 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39 |  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40 |  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41 |  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42 |  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43 |  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44 |  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45 |  * OTHER DEALINGS IN THE SOFTWARE.
46 |  */
47 | 
48 | /**
49 |   @module    html2canvas
50 |   @summary   Generate virtual screenshots of HTML elements (tracking the [html2canvas library](http://html2canvas.hertzen.com/))
51 |   @hostenv   xbrowser
52 | 
53 |   @function render
54 |   @param {DOMElement} [element]
55 |   @param {Settings} [opts]
56 |   @summary Render `element` to a HTML `` reresentation.
57 |   @return {DOMElement} A  element.
58 |   @desc
59 |     Since there is no browser API for actually capturing screenshots, this library
60 |     makes a best-effort attempt to emulate a browser rendering based on the current
61 |     state of the DOM. The resulting screenshots are therefore not 100% percent accurate,
62 |     and may not include some cross-origin content due to browser security policies (e.g images, iframes).
63 | 
64 |     See the [official webpage](http://html2canvas.hertzen.com/) for further details.
65 | */
66 | 
67 | var { clone } = require('../object');
68 | 
69 | /** @docsoff */
70 | __js {
71 | 


--------------------------------------------------------------------------------
/src/deps/moment-timezone/apollo-module-header.txt:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * StratifiedJS 'moment-timezone' module
 3 |  *
 4 |  * Part of the Stratified JavaScript Standard Module Library
 5 |  * http://onilabs.com/stratifiedjs
 6 |  *
 7 |  * (c) 2015 Oni Labs, http://onilabs.com
 8 |  *
 9 |  *
10 |  *   ***************************************************************
11 |  *   *    DO NOT EDIT moment-timezone.sjs - IT IS A GENERATED FILE *
12 |  *   *    EDIT THE SOURCE CODE UNDER stratifiedjs/src/deps AND RUN *
13 |  *   *    stratifiedjs/src/build/make-sjs                          *
14 |  *   ***************************************************************
15 |  *
16 |  *
17 |  * This file is derived from the "http://momentjs.com" project, 
18 |  * which is available under the terms of the MIT License.
19 |  *
20 |  * Original License Text:
21 |  *
22 |  *  Copyright (c) 2014 Tim Wood
23 |  *
24 |  *  Permission is hereby granted, free of charge, to any person
25 |  *  obtaining a copy of this software and associated documentation
26 |  *  files (the "Software"), to deal in the Software without
27 |  *  restriction, including without limitation the rights to use,
28 |  *  copy, modify, merge, publish, distribute, sublicense, and/or sell
29 |  *  copies of the Software, and to permit persons to whom the
30 |  *  Software is furnished to do so, subject to the following
31 |  *  conditions:
32 |  * 
33 |  *  The above copyright notice and this permission notice shall be
34 |  *  included in all copies or substantial portions of the Software.
35 |  * 
36 |  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 |  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
38 |  *  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 |  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
40 |  *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 |  *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 |  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 |  *  OTHER DEALINGS IN THE SOFTWARE.
44 |  */
45 | 
46 | /**
47 |   @module    moment-timezone
48 |   @summary   Timezone support for sjs:moment
49 |   @home      sjs:moment-timezone
50 |   @desc      
51 |              This module tracks the [momentjs/timezone](https://github.com/moment/moment-timezone/) library (version: 0.5.17) with all current (2018e) IANA timezone data built-in.
52 | 
53 |              ### Usage
54 | 
55 |              sjs:moment-timezone `require`s the sjs:moment module, amends it with 
56 |              timezone functionality and returns it as its module.export.
57 | 
58 |              There are no exported symbols from this module. The return value of `require('sjs:moment')` is itself a function, as documented at http://momentjs.com.
59 | 
60 | */
61 | 
62 | /**
63 |   turn off docs from this point onwards:
64 |   @docsoff
65 | */
66 | 
67 | var moment = require('./moment');
68 | 
69 | __js {
70 | 
71 | /* coerce into using sjs's require mechanism:
72 | */
73 | 
74 | function define(deps, factory) {
75 |   module.exports = factory(moment);
76 | }
77 | define.amd = true;
78 | 
79 | 


--------------------------------------------------------------------------------
/test/init_checks.sjs:
--------------------------------------------------------------------------------
  1 | // sanity checks on the test suite runner itself:
  2 | 
  3 | var { Runner } = require("sjs:test/runner");
  4 | var { context, assert, test } = require("sjs:test/suite");
  5 | var logging = require("sjs:logging");
  6 | var { each, toArray } = require('sjs:sequence');
  7 | var { waitforAll } = require('sjs:cutil');
  8 | 
  9 | // suite with passing & failing tests
 10 | var runner = new Runner({});
 11 | runner.context("root", function() {
 12 |   context("group 1", function() {
 13 |     test("OK 1", -> assert.ok(true));
 14 |     test("FAIL 1", -> assert.ok(false));
 15 |   })
 16 | 
 17 |   context("group 2", function() {
 18 |     test("OK 2", -> assert.ok(true)).skip();
 19 |     test("FAIL 2", -> assert.ok(false));
 20 |     test("FAIL 3", -> assert.ok(false));
 21 |   })
 22 | 
 23 |   context("group 3", function() {
 24 |     context("group 4", function() {
 25 |       test("OK 3", -> assert.ok(true));
 26 |     }).skip();
 27 |     test("FAIL 4", -> assert.ok(false)).skip();
 28 |     test("FAIL 5", -> assert.ok(false)).skip();
 29 |   })
 30 | })
 31 | 
 32 | var suite_result = runner.run();
 33 | var debug = require("sjs:debug");
 34 | var check = function(actual, expected, desc) {
 35 |   if (expected != actual) {
 36 |     throw new Error("\n------------\n#{desc || "check failed"}: expected:\n#{expected}\n got:\n#{actual}\n---------------------");
 37 |   }
 38 | }
 39 | 
 40 | logging.debug(`got result: ${suite_result}`);
 41 | check(suite_result.ok(), false, "result.ok()");
 42 | check(suite_result.count(), 7, "result.count()");
 43 | check(suite_result.passed, 1, "result.passed");
 44 | check(suite_result.failed, 3, "result.failed");
 45 | check(suite_result.skipped, 3, "result.skipped");
 46 | 
 47 | var events = [];
 48 | var reporter = {};
 49 | var event_names = ['contextBegin', 'contextEnd', 'testBegin', 'testEnd', 'testPassed', 'testFailed', 'testSkipped', 'suiteEnd'];
 50 | 
 51 | reporter.suiteBegin = function(results) {
 52 |   check(results.total, 7, "results.total");
 53 |   events.push('suiteBegin');
 54 | }
 55 | 
 56 | event_names .. each {|key|
 57 |   reporter[key] = function(testResult) {
 58 |     if (testResult && testResult.description) {
 59 |       events.push("#{key}: #{testResult.description}");
 60 |     } else {
 61 |       events.push(key);
 62 |     }
 63 |   }
 64 | }
 65 | 
 66 | runner.run(reporter);
 67 | 
 68 | check(events.join("\n"), "
 69 | suiteBegin
 70 | contextBegin: root
 71 | contextBegin: group 1
 72 | testBegin: OK 1
 73 | testPassed: OK 1
 74 | testEnd: OK 1
 75 | testBegin: FAIL 1
 76 | testFailed: FAIL 1
 77 | testEnd: FAIL 1
 78 | contextEnd: group 1
 79 | contextBegin: group 2
 80 | testBegin: OK 2
 81 | testSkipped: OK 2
 82 | testEnd: OK 2
 83 | testBegin: FAIL 2
 84 | testFailed: FAIL 2
 85 | testEnd: FAIL 2
 86 | testBegin: FAIL 3
 87 | testFailed: FAIL 3
 88 | testEnd: FAIL 3
 89 | contextEnd: group 2
 90 | contextBegin: group 3
 91 | contextBegin: group 4
 92 | contextEnd: group 4
 93 | testBegin: FAIL 4
 94 | testSkipped: FAIL 4
 95 | testEnd: FAIL 4
 96 | testBegin: FAIL 5
 97 | testSkipped: FAIL 5
 98 | testEnd: FAIL 5
 99 | contextEnd: group 3
100 | contextEnd: root
101 | suiteEnd
102 | ".trim());
103 | logging.verbose("test runner sanity check OK");
104 | 
105 | 


--------------------------------------------------------------------------------