You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not easy or quick to read file from browser.
How about use Node.js environment to read file and run our unit tests. If so, we may use Grunt.js to run some tasks.
I have tested the following pattern successfully in Node.js environment and browser, which is inspired by Require.js, comparing require.js with r.js for Node.
// module file
var env;
if (typeof window !== 'undefined' && window) {
env = (window.Sorting = window.Sorting || {});
} else if (typeof process !== 'undefined' && process.versions && !!process.versions.node) {
env = exports;
} else {
// or throw new Error('invalid environment');
env = 'invalid environment';
}
(function(Sorting, undefined){
Sorting.isSorted = function () {};
})(env);
Applying this, we can require(./fileName.js) in Node.js environment, or run JavaScript in browser.
// application file
var Sorting = require('./sorting.js');
Sorting.isSorted();
add test files in compressed file
add FORMAT.md for format specification of input and output
add unit tests through reading file
update grunt task
update npm test script
From Algo.js of Google Code on September 21, 2013 21:26:42
See unit test of graph, we place lots of input edges data in
q-graph.js
. It is better to read input file.Original issue: http://code.google.com/p/algo-js/issues/detail?id=18
The text was updated successfully, but these errors were encountered: