mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
change browser tests to use JSON.stringify
This commit is contained in:
parent
2de1161db2
commit
75af920f1d
2 changed files with 10 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var Resurrect = require('./lib/resurrect');
|
var Resurrect = require('../lib/resurrect');
|
||||||
var compare = require('fast-json-patch').compare;
|
var compare = require('fast-json-patch').compare;
|
||||||
var system = require('system');
|
var system = require('system');
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ var test = function(status) {
|
||||||
return engine.world;
|
return engine.world;
|
||||||
}, demo, frames);
|
}, demo, frames);
|
||||||
|
|
||||||
worldEnd = resurrect.resurrect(resurrect.stringify(worldEnd, precisionLimiter));
|
worldEnd = JSON.parse(resurrect.stringify(worldEnd, precisionLimiter));
|
||||||
worldStart = resurrect.resurrect(resurrect.stringify(worldStart, precisionLimiter));
|
worldStart = JSON.parse(resurrect.stringify(worldStart, precisionLimiter));
|
||||||
|
|
||||||
if (fs.exists(worldStartPath)) {
|
if (fs.exists(worldStartPath)) {
|
||||||
var worldStartRef = resurrect.resurrect(fs.read(worldStartPath));
|
var worldStartRef = JSON.parse(fs.read(worldStartPath));
|
||||||
var worldStartDiff = compare(worldStartRef, worldStart);
|
var worldStartDiff = compare(worldStartRef, worldStart);
|
||||||
|
|
||||||
if (worldStartDiff.length !== 0) {
|
if (worldStartDiff.length !== 0) {
|
||||||
|
@ -84,18 +84,18 @@ var test = function(status) {
|
||||||
|
|
||||||
if (forceUpdate) {
|
if (forceUpdate) {
|
||||||
hasCreated = true;
|
hasCreated = true;
|
||||||
fs.write(worldStartPath, resurrect.stringify(worldStart, precisionLimiter, 2), 'w');
|
fs.write(worldStartPath, JSON.stringify(worldStart, precisionLimiter, 2), 'w');
|
||||||
} else {
|
} else {
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hasCreated = true;
|
hasCreated = true;
|
||||||
fs.write(worldStartPath, resurrect.stringify(worldStart, precisionLimiter, 2), 'w');
|
fs.write(worldStartPath, JSON.stringify(worldStart, precisionLimiter, 2), 'w');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.exists(worldEndPath)) {
|
if (fs.exists(worldEndPath)) {
|
||||||
var worldEndRef = resurrect.resurrect(fs.read(worldEndPath));
|
var worldEndRef = JSON.parse(fs.read(worldEndPath));
|
||||||
var worldEndDiff = compare(worldEndRef, worldEnd);
|
var worldEndDiff = compare(worldEndRef, worldEnd);
|
||||||
|
|
||||||
if (worldEndDiff.length !== 0) {
|
if (worldEndDiff.length !== 0) {
|
||||||
|
@ -105,14 +105,14 @@ var test = function(status) {
|
||||||
|
|
||||||
if (forceUpdate) {
|
if (forceUpdate) {
|
||||||
hasCreated = true;
|
hasCreated = true;
|
||||||
fs.write(worldEndPath, resurrect.stringify(worldEnd, precisionLimiter, 2), 'w');
|
fs.write(worldEndPath, JSON.stringify(worldEnd, precisionLimiter, 2), 'w');
|
||||||
} else {
|
} else {
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hasCreated = true;
|
hasCreated = true;
|
||||||
fs.write(worldEndPath, resurrect.stringify(worldEnd, precisionLimiter, 2), 'w');
|
fs.write(worldEndPath, JSON.stringify(worldEnd, precisionLimiter, 2), 'w');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasChanged) {
|
if (hasChanged) {
|
||||||
|
@ -167,7 +167,7 @@ page.onError = function(msg, trace) {
|
||||||
|
|
||||||
if (trace && trace.length) {
|
if (trace && trace.length) {
|
||||||
trace.forEach(function(t) {
|
trace.forEach(function(t) {
|
||||||
msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line + (t.function ? ' (fn: ' + t.function +')' : ''));
|
msgStack.push(' at ' + (t.file || t.sourceURL) + ': ' + t.line + (t.function ? ' (fn: ' + t.function +')' : ''));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue