Browse files

Added CommonJS tests

  • Loading branch information...
1 parent d4f6614 commit 67823d3e86c8659ddb4aa47a31d37ad86ef5be9e @ryanwilliams committed Aug 23, 2011
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "tests/commonjs/lib/commonjs"]
+ path = tests/commonjs/lib/commonjs
+ url = https://github.com/commonjs/commonjs.git
View
1 tests/commonjs/.gitignore
@@ -0,0 +1 @@
+build
View
6 tests/commonjs/jah.json
@@ -0,0 +1,6 @@
+{ "jah_project": { "version": "0.0.1" }
+
+, "output": "commonjs.js"
+
+, "libs": [ ]
+}
1 tests/commonjs/lib/commonjs
@@ -0,0 +1 @@
+Subproject commit 8203f29d858d4d2adbd2bb911949fac7459ac264
View
18 tests/commonjs/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "CommonJS Tests for Jah",
+ "author": "",
+ "description": "",
+ "version": "0.0.1",
+ "homepage": "",
+
+ "engines": {
+ "node": ">= 0.4.0"
+ },
+
+ "repository": {
+ },
+
+ "dependencies": {
+ "jah": ">= 0.0.1"
+ }
+}
View
52 tests/commonjs/public/index.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <script defer src="commonjs.js" type="text/javascript"></script>
+ <title>Commonjs</title>
+ <style type="text/css" media="screen">
+ body {
+ font-family: Helvetica, Arial, sans-serif;
+ font-size: 10pt;
+ background: #ddd;
+ }
+ h1 {
+ text-align: center;
+ text-shadow: 0 2px 1px #fff;
+ }
+ .log {
+ padding: 2px 8px;
+ border-bottom: 1px solid #999;
+ }
+ .log.pass {
+ background: #4d4;
+ }
+ .log.fail {
+ background: #d44;
+ }
+ .log.info {
+ background: #ccc;
+ }
+ #commonjs-test-log {
+ width: 800px;
+ height: 320px;
+ margin: auto;
+ overflow: auto;
+
+ background: white;
+
+ border-radius: 5px;
+ -moz-border-radius: 5px;
+
+ -webkit-box-shadow: rgba(0, 0, 0, 0.45) 0 1px 3px, rgba(0, 0, 0, 0.8) 0 0 1px;
+ -moz-box-shadow: rgba(0, 0, 0, 0.45) 0 1px 3px, rgba(0, 0, 0, 0.8) 0 0 1px;
+ box-shadow: rgba(0, 0, 0, 0.45) 0 1px 3px, rgba(0, 0, 0, 0.8) 0 0 1px;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>CommonJS Tests</h1>
+ <div id="commonjs-test-log">
+ </div>
+ </body>
+</html>
View
55 tests/commonjs/src/main.js
@@ -0,0 +1,55 @@
+"use strict";
+
+var container = document.getElementById('commonjs-test-log');
+container.className = 'logs';
+
+var logNum = 0;
+while (container.firstChild) {
+ container.removeChild(container.firstChild);
+}
+
+exports.main = function () {
+ var tests = [
+ '/tests/modules/1.0/absolute',
+ '/tests/modules/1.0/cyclic',
+ '/tests/modules/1.0/determinism',
+ '/tests/modules/1.0/exactExports',
+ '/tests/modules/1.0/hasOwnProperty',
+ '/tests/modules/1.0/method',
+ '/tests/modules/1.0/missing',
+ '/tests/modules/1.0/monkeys',
+ '/tests/modules/1.0/nested',
+ '/tests/modules/1.0/relative',
+ '/tests/modules/1.0/transitive'
+ ];
+
+ var i = 0;
+ function nextTest() {
+ var test = tests[i];
+
+ window.print = function (msg, tag) {
+ if (tag == 'info') {
+ return;
+ }
+ var div = document.createElement('div')
+ , testName = test.split('/').pop();
+ logNum++;
+ div.appendChild(document.createTextNode(logNum + ' (' + testName + '): ' + msg));
+ div.className = 'log ' + tag;
+ container.appendChild(div);
+ container.scrollTop = container.offsetHeight;
+ };
+
+
+
+
+ require.paths.push(test);
+ require('program');
+ require.paths.splice(require.paths.indexOf(test), 1);
+ i++;
+ if (i < tests.length) {
+ setTimeout(nextTest, 1);
+ }
+ }
+ nextTest();
+}
View
1 tests/commonjs/src/tests

0 comments on commit 67823d3

Please sign in to comment.