Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test through reading input file should be implemented #18

Closed
scozv opened this issue Dec 12, 2013 · 2 comments
Closed

unit test through reading input file should be implemented #18

scozv opened this issue Dec 12, 2013 · 2 comments

Comments

@scozv
Copy link
Owner

scozv commented Dec 12, 2013

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

@scozv
Copy link
Owner Author

scozv commented Dec 14, 2013

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();

scozv pushed a commit that referenced this issue Dec 24, 2013
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
@scozv scozv closed this as completed Dec 24, 2013
scozv pushed a commit that referenced this issue Dec 25, 2013
keep old input file if there is a file with same name
this is for big input test (see issue #18 comments)
@scozv
Copy link
Owner Author

scozv commented Dec 25, 2013

Due to the limits of drone.io, a CI service, committing and decompressing big file (> 5M) is time-consuming.

So we have to keep big file at local place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant