diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-06 10:08:13 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-07 08:51:34 +0300 |
| commit | df93bb43321bcccbc7ee539b520203e97f18d9da (patch) | |
| tree | 9f62587151bf54bacdf6b54561199e093f7696cb /tests | |
| parent | 41f42bc1ba7fb728e8ced0a2285cbaf2570da170 (diff) | |
tests: add test_nan_problem
replaces test_history.js.
fixes links to new external/scripts/*
The new test some point it actually showed the d3 problem, but now it doesn't.
To run it:
node tests/test_nan_problem.js | grep nan
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_history.js | 47 | ||||
| -rw-r--r-- | tests/test_nan_problem.js | 78 |
2 files changed, 78 insertions, 47 deletions
diff --git a/tests/test_history.js b/tests/test_history.js deleted file mode 100644 index 0851d9aa..00000000 --- a/tests/test_history.js +++ /dev/null @@ -1,47 +0,0 @@ -var fs = require('fs'), - jsdom = require('jsdom'); - -var script_filenames = [ - "d3/d3.v3.min.js", - "scripts/jquery.js", - "external/jquery-ui.js", - "scripts/caret.js", - - "scripts/autocomplete.js", - "scripts/history.js", - "scripts/rhizicore.js", - "scripts/textanalysis.js", - "scripts/textanalysis-ui.js", - "scripts/buttons.js", - "scripts/drag_n_drop.js", - "scripts/robot.js", - "scripts/watchdog.js", - "scripts/gant.js"].map(function(x) { return "../" + x; }); - -//var scripts = script_filenames.map(function (x) { console.log('reading ' + x); return fs.readFileSync(x); }); - -var typein = function(window, text) { - var c; - - for(c in text) { - console.log(c); - } -} - -var env = jsdom.env({ - //src: scripts, - scripts: script_filenames, - //url: "http://localhost:12345/", - html: "<html><body></body></html>", - created: function(errors, window) { - window.console.log = console.log; - }, - done: function (errors, window) { - console.log('---------'); - console.log(errors); - console.log('---------'); - //typein(window, "#a is #b|"); - console.log(window.textAnalyser2("#a")); - process.exit(); - } -}); diff --git a/tests/test_nan_problem.js b/tests/test_nan_problem.js new file mode 100644 index 00000000..fab9df34 --- /dev/null +++ b/tests/test_nan_problem.js @@ -0,0 +1,78 @@ +var fs = require('fs'), + jsdom = require('jsdom'); + +var script_filenames = [ + "external/scripts/d3/d3.js", + "external/scripts/jquery.js", + "external/scripts/jquery-ui.js", + "external/scripts/autocomplete.js", + + "scripts/caret.js", + "scripts/history.js", + "scripts/rhizicore.js", + "scripts/textanalysis.js", + "scripts/textanalysis-ui.js", + "scripts/buttons.js", + "scripts/drag_n_drop.js", + "scripts/robot.js", + "scripts/watchdog.js", + "scripts/gant.js"].map(function(x) { return "../" + x; }); + +function feed_sentence(window, s, finalize) +{ + var i; + console.log('******* feeding: ' + s); + for (i = 1 ; i <= s.length; ++i) { + console.log('======= ' + s.substr(0, i)); + window.analyzeSentence(s.substr(0, i), false); + } + if (finalize) { + window.analyzeSentence(s, true); + } +} + +function dump_nodes(window) { + var nodes = window.force.nodes(); + for(var i = 0 ; i < nodes.length; ++i) { + console.log('nodes[' + nodes[i].id + '/' + nodes[i].type + '].[xy] = (' + nodes[i].x + ',' + nodes[i].y + ')'); + } +} + +var env = jsdom.env({ + scripts: script_filenames, + html: "<html><body></body></html>", + created: function(errors, window) { + window.console.log = console.log; // slightly evil + window.process = process; // more evil + }, + done: function (errors, window) { + var i; + var s1 = "#a"; + var s2 = "#a is"; + var nodes; + + window.force + .nodes(window.nodes) + .links(window.links) + .alpha(0.1) + .start(); + console.log('---------'); + console.log(errors); + console.log('---------'); + //console.log(window.textAnalyser2("#a")); + feed_sentence(window, s1, true); + dump_nodes(window); + feed_sentence(window, s2, false); + console.log(window.force.alpha()); + dump_nodes(window); + debugger; + window.force.tick(); + console.log(window.force.alpha()); + dump_nodes(window); + //console.log(window.nodes); + //console.log(window.links); + process.exit(); + window.debug_print(window.force); + //process.exit(); + } +}); |
