Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update crazy tests

  • Loading branch information...
commit 250773b25a71d03988cd616765e0d4a4390907da 1 parent 8dad073
@zeekay zeekay authored
View
196 test/assets/expected.js
@@ -1,123 +1,107 @@
-(function() {
- var cache, modules;
- modules = {};
- cache = {};
- this.require = function(alias) {
- var fn, module;
- module = cache[alias];
- if (module) {
- return module.exports;
- }
- fn = modules[alias];
- if (!fn) {
- throw new Error("Module " + alias + " not found");
- }
- module = {
- id: alias,
- exports: {}
- };
- try {
+buf.push("<h1>hi!</h1>");
+ var interp;
+ a: "a",
+ a: a,
+ alias = aliases[_i];
+ attrs = attrs || jade.attrs;
+ b: "b"
+ b: b,
+ c: "c",
+ c: c()
cache[alias] = module;
+ delete cache[alias];
+ escape = escape || jade.escape;
+ exports: {}
fn(require, module, module.exports);
+ foo: "bar"
+ foo: require("58c67562d2")
+ id: alias,
+ merge = merge || jade.merge;
+ mod: require("e63313c6a9")
+ modules[alias] = fn;
+ rethrow = rethrow || jade.rethrow;
+ return buf.join("");
return module.exports;
- } catch (err) {
- delete cache[alias];
+ return module.exports;
+ return require("318af1af20");
throw err;
- }
- };
- return this.require.define = function(aliases, fn) {
- var alias, _i, _len;
- for (_i = 0, _len = aliases.length; _i < _len; _i++) {
- alias = aliases[_i];
- modules[alias] = fn;
- }
- };
-})();
-
-
-jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/entry.coffee
-// modified: Tuesday, June 26, 2012 1:22:56 AM
-require.define(["/entry","21568343a3"], function (require, module, exports) {(function(){
- var a, b, c, template;
-
+ throw new Error("Module " + alias + " not found");
+ var buf = [];
+ with (locals || {}) {
+ x: 42
+ }
a = require("70f886d883");
-
+ alert("hi");
b = require("8908bb92f8");
-
c = function() {
- return require("318af1af20");
- };
-
+ fn = modules[alias];
+ for (_i = 0, _len = aliases.length; _i < _len; _i++) {
+ if (!fn) {
+ if (module) {
+ module = cache[alias];
+ module = {
+ module.exports = function anonymous(locals, attrs, escape, rethrow, merge) {
module.exports = {
- a: a,
- b: b,
- c: c()
- };
-
- template = require("04e021b689");
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/a.coffee
-// modified: Tuesday, June 26, 2012 1:22:56 AM
-require.define(["/a","70f886d883"], function (require, module, exports) {(function(){
module.exports = {
- a: "a",
- foo: require("58c67562d2")
- };
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/b.coffee
-// modified: Tuesday, June 26, 2012 1:22:56 AM
-require.define(["/b","8908bb92f8"], function (require, module, exports) {(function(){
module.exports = {
- b: "b"
- };
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/c.coffee
-// modified: Friday, June 29, 2012 6:10:29 AM
-require.define(["/c","318af1af20"], function (require, module, exports) {(function(){
module.exports = {
- c: "c",
- mod: require("e63313c6a9")
- };
-
- alert("hi");
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/node_modules/mod/index.js
-// modified: Friday, June 29, 2012 2:07:54 AM
-require.define(["/node_modules/mod","e63313c6a9"], function (require, module, exports) {(function(){
module.exports = {
- x: 42
+ module.exports = {
+ template = require("04e021b689");
+ try {
+ var a, b, c, template;
+ var alias, _i, _len;
+ var fn, module;
+ }
+ }
+ }
+ }
+ } catch (err) {
};
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/template.jade
-// modified: Tuesday, June 26, 2012 1:22:56 AM
-require.define(["/test/assets/template","04e021b689"], function (require, module, exports) {(function(){
- module.exports = function anonymous(locals, attrs, escape, rethrow, merge) {
- attrs = attrs || jade.attrs;
- escape = escape || jade.escape;
- rethrow = rethrow || jade.rethrow;
- merge = merge || jade.merge;
- var buf = [];
- with (locals || {}) {
- var interp;
- buf.push("<h1>hi!</h1>");
- }
- return buf.join("");
};
-}).call(this)});
-
-// source: /Volumes/Data/zk/play/requisite/test/assets/foo/index.coffee
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ cache = {};
+ modules = {};
+ return this.require.define = function(aliases, fn) {
+ this.require = function(alias) {
+ var cache, modules;
+ };
+ };
+(function() {
+// modified: Friday, June 29, 2012 2:07:54 AM
+// modified: Friday, June 29, 2012 6:10:29 AM
+// modified: Tuesday, June 26, 2012 1:22:56 AM
+// modified: Tuesday, June 26, 2012 1:22:56 AM
// modified: Tuesday, June 26, 2012 1:22:56 AM
+// modified: Tuesday, June 26, 2012 1:22:56 AM
+// modified: Tuesday, June 26, 2012 1:22:56 AM
+// source: /Volumes/Data/zk/play/requisite/node_modules/mod/index.js
+// source: /Volumes/Data/zk/play/requisite/test/assets/a.coffee
+// source: /Volumes/Data/zk/play/requisite/test/assets/b.coffee
+// source: /Volumes/Data/zk/play/requisite/test/assets/c.coffee
+// source: /Volumes/Data/zk/play/requisite/test/assets/entry.coffee
+// source: /Volumes/Data/zk/play/requisite/test/assets/foo/index.coffee
+// source: /Volumes/Data/zk/play/requisite/test/assets/template.jade
+jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
+require('21568343a3');
+require.define(["/a","70f886d883"], function (require, module, exports) {(function(){
+require.define(["/b","8908bb92f8"], function (require, module, exports) {(function(){
+require.define(["/c","318af1af20"], function (require, module, exports) {(function(){
+require.define(["/entry","21568343a3"], function (require, module, exports) {(function(){
+require.define(["/node_modules/mod","e63313c6a9"], function (require, module, exports) {(function(){
require.define(["/test/assets/foo","58c67562d2"], function (require, module, exports) {(function(){
- module.exports = {
- foo: "bar"
- };
+require.define(["/test/assets/template","04e021b689"], function (require, module, exports) {(function(){
+})();
}).call(this)});
-
-require('21568343a3');
+}).call(this)});
+}).call(this)});
+}).call(this)});
+}).call(this)});
+}).call(this)});
+}).call(this)});
View
2  test/assets/expected.min.js
@@ -1 +1 @@
-(function(){var e,t;return t={},e={},this.require=function(n){var r,i;i=e[n];if(i)return i.exports;r=t[n];if(!r)throw new Error("Module "+n+" not found");i={id:n,exports:{}};try{return e[n]=i,r(require,i,i.exports),i.exports}catch(s){throw delete e[n],s}},this.require.define=function(e,n){t[e]=n}})();jade=function(e){function t(e){return e!=null}return Array.isArray||(Array.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)}),Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}),e.merge=function(n,r){var i=n["class"],s=r["class"];if(i||s)i=i||[],s=s||[],Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s]),i=i.filter(t),s=s.filter(t),n["class"]=i.concat(s).join(" ");for(var o in r)o!="class"&&(n[o]=r[o]);return n},e.attrs=function(n,r){var i=[],s=n.terse;delete n.terse;var o=Object.keys(n),u=o.length;if(u){i.push("");for(var a=0;a<u;++a){var f=o[a],l=n[f];"boolean"==typeof l||null==l?l&&(s?i.push(f):i.push(f+'="'+f+'"')):0==f.indexOf("data")&&"string"!=typeof l?i.push(f+"='"+JSON.stringify(l)+"'"):"class"==f&&Array.isArray(l)?i.push(f+'="'+e.escape(l.join(" "))+'"'):r&&r[f]?i.push(f+'="'+e.escape(l)+'"'):i.push(f+'="'+l+'"')}}return i.join(" ")},e.escape=function(t){return String(t).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},e.rethrow=function(t,n,r){if(!n)throw t;var i=3,s=require("fs").readFileSync(n,"utf8"),o=s.split("\n"),u=Math.max(r-i,0),a=Math.min(o.length,r+i),i=o.slice(u,a).map(function(e,t){var n=t+u+1;return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+i+"\n\n"+t.message,t},e}({});require.define(['21568343a3'], function (require, module, exports) {(function(){var a,b,c,template;a=require("70f886d883"),b=require("8908bb92f8"),c=function(){return require("318af1af20")},module.exports={a:a,b:b,c:c()},template=require("04e021b689")}).call(this)});require.define(['70f886d883'], function (require, module, exports) {(function(){module.exports={a:"a",foo:require("58c67562d2")}}).call(this)});require.define(['8908bb92f8'], function (require, module, exports) {(function(){module.exports={b:"b"}}).call(this)});require.define(['318af1af20'], function (require, module, exports) {(function(){module.exports={c:"c",mod:require("e63313c6a9")},alert("hi")}).call(this)});require.define(['e63313c6a9'], function (require, module, exports) {(function(){module.exports={x:42}}).call(this)});require.define(['58c67562d2'], function (require, module, exports) {(function(){module.exports={foo:"bar"}}).call(this)});require.define(['04e021b689'], function (require, module, exports) {(function(){module.exports=function anonymous(locals,attrs,escape,rethrow,merge){attrs=attrs||jade.attrs,escape=escape||jade.escape,rethrow=rethrow||jade.rethrow,merge=merge||jade.merge;var buf=[];with(locals||{}){var interp;buf.push("<h1>hi!</h1>")}return buf.join("")}}).call(this)});require("21568343a3");
+;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},e.rethrow=function(t,n,r){if(!n)throw t;"boolean"==typeof l||null==l?l&&(s?i.push(f):i.push(f+'="'+f+'"')):0==f.indexOf("data")&&"string"!=typeof l?i.push(f+"='"+JSON.stringify(l)+"'"):"class"==f&&Array.isArray(l)?i.push(f+'="'+e.escape(l.join(" "))+'"'):r&&r[f]?i.push(f+'="'+e.escape(l)+'"'):i.push(f+'="'+l+'"')}}return i.join(" ")},e.escape=function(t){return String(t).replace(/&(?!(\w+|\#\d+);(function(){var e,t;)/g,"&amp;++a){var f=o[a],l=n[f];a<u;a=require("70f886d883"),b=require("8908bb92f8"),c=function(){return require("318af1af20")},module.exports={a:a,b:b,c:c()},template=require("04e021b689")}).call(this)});buf.push("<h1>hi!</h1>")}return buf.join("")}}).call(this)});delete n.terse;for(var a=0;for(var n in e)e.hasOwnProperty(n)&&t.push(n);for(var o in r)o!="class"&&(n[o]=r[o]);i=e[n];i={id:n,exports:{}};if(!r)throw new Error("Module "+n+" not found");if(i)return i.exports;if(i||s)i=i||[],s=s||[],Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s]),i=i.filter(t),s=s.filter(t),n["class"]=i.concat(s).join(" ");if(u){i.push("");jade=function(e){function t(e){return e!=null}return Array.isArray||(Array.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)}),Object.keys||(Object.keys=function(e){var t=[];r=t[n];require("21568343a3");require.define(['04e021b689'], function (require, module, exports) {(function(){module.exports=function anonymous(locals,attrs,escape,rethrow,merge){attrs=attrs||jade.attrs,escape=escape||jade.escape,rethrow=rethrow||jade.rethrow,merge=merge||jade.merge;require.define(['21568343a3'], function (require, module, exports) {(function(){var a,b,c,template;require.define(['318af1af20'], function (require, module, exports) {(function(){module.exports={c:"c",mod:require("e63313c6a9")},alert("hi")}).call(this)});require.define(['58c67562d2'], function (require, module, exports) {(function(){module.exports={foo:"bar"}}).call(this)});require.define(['70f886d883'], function (require, module, exports) {(function(){module.exports={a:"a",foo:require("58c67562d2")}}).call(this)});require.define(['8908bb92f8'], function (require, module, exports) {(function(){module.exports={b:"b"}}).call(this)});require.define(['e63313c6a9'], function (require, module, exports) {(function(){module.exports={x:42}}).call(this)});return n},e.attrs=function(n,r){var i=[],s=n.terse;return t={},e={},this.require=function(n){var r,i;return t}),e.merge=function(n,r){var i=n["class"],s=r["class"];return(n==r?" > ":" ")+n+"| "+e}).join("\n");throw t.path=n,t.message=(n||"Jade")+":"+r+"\n"+i+"\n\n"+t.message,t},e}({});try{return e[n]=i,r(require,i,i.exports),i.exports}catch(s){throw delete e[n],s}},this.require.define=function(e,n){t[e]=n}})();var buf=[];var i=3,s=require("fs").readFileSync(n,"utf8"),o=s.split("\n"),u=Math.max(r-i,0),a=Math.min(o.length,r+i),i=o.slice(u,a).map(function(e,t){var n=t+u+1;var o=Object.keys(n),u=o.length;with(locals||{}){var interp
View
32 test/bundle.coffee
@@ -10,30 +10,44 @@ if not path.existsSync mod
fs.mkdirSync mod
fs.writeFileSync path.join(mod, 'index.js'), "module.exports = {x: 42};"
+# Create bundlers
bundler = requisite.createBundler
entry: __dirname + '/assets/entry'
-bundlerM = requisite.createBundler
+bundlerMin = requisite.createBundler
entry: __dirname + '/assets/entry'
minify: true
+# Write out expected data.
+# bundler.bundle (err, actualData) ->
+# fs.writeFileSync __dirname + '/assets/expected.js', actualData.split('\n').sort().join('\n').trim()
+
+# bundlerM.bundle (err, actualData) ->
+# fs.writeFileSync __dirname + '/assets/expected.min.js', actualData.split(';').sort().join(';').trim()
+
# Verify that bundled output matches expected.js
-checkExpected = (b, expected, done) ->
- fs.readFile __dirname + expected, 'utf8', (err, expectedData) ->
- b.bundle (err, actualData) ->
- assert.equal actualData.trim(), expectedData.trim()
+checkExpected = (done) ->
+ fs.readFile __dirname + '/assets/expected.js', 'utf8', (err, expectedData) ->
+ bundler.bundle (err, actualData) ->
+ assert.equal actualData.split('\n').sort().join('\n').trim(), expectedData.trim()
+ done()
+
+checkExpectedMin = (done) ->
+ fs.readFile __dirname + '/assets/expected.min.js', 'utf8', (err, expectedData) ->
+ bundlerMin.bundle (err, actualData) ->
+ assert.equal actualData.split(';').sort().join(';').trim(), expectedData.trim()
done()
describe 'bundler', ->
describe '#bundle()', ->
it 'bundled JavaScript should match expected', (done) ->
- checkExpected bundler, '/assets/expected.js', done
+ checkExpected done
it 'bundled JavaScript should still match expected after rebundling', (done) ->
- checkExpected bundler, '/assets/expected.js', done
+ checkExpected done
it 'bundled & minified JavaScript should match expected', (done) ->
- checkExpected bundlerM, '/assets/expected.min.js', done
+ checkExpectedMin done
it 'bundled & minified JavaScript should match expected after rebundling', (done) ->
- checkExpected bundlerM, '/assets/expected.min.js', done
+ checkExpectedMin done
Please sign in to comment.
Something went wrong with that request. Please try again.