Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Unified Diff: sky/tests/framework/observe.sky

Issue 695413003: Remove ArrayFuzzer from observe.sky test (was timing out). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/tests/framework/observe-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tests/framework/observe.sky
diff --git a/sky/tests/framework/observe.sky b/sky/tests/framework/observe.sky
index d95143cbf1ea5b5a174291789f654a11ff32267b..2fa89259ba64fabfcf745328c1e8807f63f04aea 100644
--- a/sky/tests/framework/observe.sky
+++ b/sky/tests/framework/observe.sky
@@ -1710,139 +1710,6 @@ describe('ArrayObserver Tests', function() {
applySplicesAndAssertDeepEqual(model, copy);
});
- function ArrayFuzzer() {}
-
- ArrayFuzzer.valMax = 16;
- ArrayFuzzer.arrayLengthMax = 128;
- ArrayFuzzer.operationCount = 64;
-
- function randDouble(start, end) {
- return Math.random()*(end-start) + start;
- }
-
- function randInt(start, end) {
- return Math.round(randDouble(start, end));
- }
-
- function randASCIIChar() {
- return String.fromCharCode(randInt(32, 126));
- }
-
- function randValue() {
- switch(randInt(0, 5)) {
- case 0:
- return {};
- case 1:
- return undefined;
- case 2:
- return null;
- case 3:
- return randInt(0, ArrayFuzzer.valMax);
- case 4:
- return randDouble(0, ArrayFuzzer.valMax);
- case 5:
- return randASCIIChar();
- }
- }
-
- function randArray() {
- var args = [];
- var count = randInt(0, ArrayFuzzer.arrayLengthMax);
- while(count-- > 0)
- args.push(randValue());
-
- return args;
- }
-
- function randomArrayOperation(arr) {
- function empty() {
- return [];
- }
-
- var operations = {
- push: randArray,
- unshift: randArray,
- pop: empty,
- shift: empty,
- splice: function() {
- var args = [];
- args.push(randInt(-arr.length*2, arr.length*2), randInt(0, arr.length*2));
- args = args.concat(randArray());
- return args;
- }
- };
-
- // Do a splice once for each of the other operations.
- var operationList = ['splice', 'update',
- 'splice', 'delete',
- 'splice', 'push',
- 'splice', 'pop',
- 'splice', 'shift',
- 'splice', 'unshift'];
-
- var op = {
- name: operationList[randInt(0, operationList.length - 1)]
- };
-
- switch(op.name) {
- case 'delete':
- op.index = randInt(0, arr.length - 1);
- delete arr[op.index];
- break;
-
- case 'update':
- op.index = randInt(0, arr.length);
- op.value = randValue();
- arr[op.index] = op.value;
- break;
-
- default:
- op.args = operations[op.name]();
- arr[op.name].apply(arr, op.args);
- break;
- }
-
- return op;
- }
-
- function randomArrayOperations(arr, count) {
- var ops = []
- for (var i = 0; i < count; i++) {
- ops.push(randomArrayOperation(arr));
- }
-
- return ops;
- }
-
- ArrayFuzzer.prototype.go = function() {
- var orig = this.arr = randArray();
- randomArrayOperations(this.arr, ArrayFuzzer.operationCount);
- var copy = this.copy = this.arr.slice();
- this.origCopy = this.copy.slice();
-
- var observer = new ArrayObserver(this.arr);
- observer.open(function(splices) {
- ArrayObserver.applySplices(copy, orig, splices);
- });
-
- this.ops = randomArrayOperations(this.arr, ArrayFuzzer.operationCount);
- observer.deliver();
- observer.close();
- }
-
-
- it('Array Tracker Fuzzer', function() {
- var testCount = 64;
-
- for (var i = 0; i < testCount; i++) {
- var fuzzer = new ArrayFuzzer();
- fuzzer.go();
- ensureNonSparse(fuzzer.arr);
- ensureNonSparse(fuzzer.copy);
- assert.deepEqual(fuzzer.arr, fuzzer.copy);
- }
- });
-
it('Array Tracker No Proxies Edits', function() {
var model = [];
observer = new ArrayObserver(model);
« no previous file with comments | « no previous file | sky/tests/framework/observe-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698