From 403c63afd7a9cc7ec2995d5200a6df8527fa3558 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 25 May 2023 08:54:27 -0300 Subject: Revert "contract: BlackBox stub & NormalizedArrayMap" This reverts commit 86e8b47b5aeeae5f2fc3b87bb5930fb4c25f88ab. --- test/unit/contract/black-box.js | 81 ----------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 test/unit/contract/black-box.js (limited to 'test/unit') diff --git a/test/unit/contract/black-box.js b/test/unit/contract/black-box.js deleted file mode 100644 index 21c05b52..00000000 --- a/test/unit/contract/black-box.js +++ /dev/null @@ -1,81 +0,0 @@ -import {BlackBox} from '../../../src/contract.js'; -import {mockFunction} from '../../lib/generic-mock.js'; -import {showAggregate} from '../../../src/util/sugar.js'; - -import t from 'tap'; - -t.test(`BlackBox - caching`, t => { - t.plan(8); - - const obj1 = {foo: 3, bar: 4}; - const obj2 = {baz: 5, qux: 6}; - - let {value: fn, close: closeMock} = - mockFunction((object, key) => object[key] ** 2) - - fn = fn - .args([obj1, 'foo']).next() - .args([obj2, 'qux']).next() - .args([obj1, 'bar']).next() - .args([obj2, 'baz']); - - const bb = new BlackBox(fn); - const evaluate = bb.getEvaluator(); - - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - t.equal(evaluate(obj2, 'qux'), 6 ** 2); - t.equal(evaluate(obj2, 'qux'), 6 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - - t.equal(evaluate(obj1, 'bar'), 4 ** 2); - t.equal(evaluate(obj2, 'baz'), 5 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - - try { - closeMock(); - } catch (error) { - showAggregate(error); - throw error; - } -}); - -t.test(`BlackBox - no caching`, t => { - t.plan(8); - - const obj1 = {foo: 3, bar: 4}; - const obj2 = {baz: 5, qux: 6}; - - let {value: fn, close: closeMock} = - mockFunction((object, key) => object[key] ** 2) - - fn = fn - .args([obj1, 'foo']).repeat(2) - .args([obj2, 'qux']).repeat(2) - .args([obj1, 'foo']).next() - .args([obj1, 'bar']).next() - .args([obj2, 'baz']).next() - .args([obj1, 'foo']); - - const bb = new BlackBox(fn); - const evaluate = bb.getEvaluator(); - - bb.caching = false; - - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - t.equal(evaluate(obj2, 'qux'), 6 ** 2); - t.equal(evaluate(obj2, 'qux'), 6 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - - t.equal(evaluate(obj1, 'bar'), 4 ** 2); - t.equal(evaluate(obj2, 'baz'), 5 ** 2); - t.equal(evaluate(obj1, 'foo'), 3 ** 2); - - try { - closeMock(); - } catch (error) { - showAggregate(error); - throw error; - } -}); -- cgit 1.3.0-6-gf8a5