mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 19:48:12 +00:00

PR-URL: https://github.com/nodejs/node/pull/35415 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
/**
|
|
* @fileoverview Test normalization.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const helpers = require('./helpers.js');
|
|
const sourceHelpers = require('../source_helpers.js');
|
|
|
|
const { ScriptMutator } = require('../script_mutator.js');
|
|
|
|
const sandbox = sinon.createSandbox();
|
|
|
|
function testLoad(testPath, expectedPath) {
|
|
const mutator = new ScriptMutator({}, helpers.DB_DIR);
|
|
const source = helpers.loadTestData(testPath);
|
|
const dependencies = mutator.resolveInputDependencies([source]);
|
|
const code = sourceHelpers.generateCode(source, dependencies);
|
|
helpers.assertExpectedResult(expectedPath, code);
|
|
}
|
|
|
|
describe('V8 dependencies', () => {
|
|
it('test', () => {
|
|
testLoad(
|
|
'mjsunit/test_load.js',
|
|
'mjsunit/test_load_expected.js');
|
|
|
|
});
|
|
it('does not loop indefinitely', () => {
|
|
testLoad(
|
|
'mjsunit/test_load_self.js',
|
|
'mjsunit/test_load_self_expected.js');
|
|
});
|
|
});
|
|
|
|
describe('Chakra dependencies', () => {
|
|
it('test', () => {
|
|
testLoad(
|
|
'chakra/load.js',
|
|
'chakra/load_expected.js');
|
|
});
|
|
});
|
|
|
|
describe('JSTest dependencies', () => {
|
|
afterEach(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
it('test', () => {
|
|
const fakeStubs = sourceHelpers.loadSource(
|
|
helpers.BASE_DIR, 'JSTests/fake_stub.js');
|
|
sandbox.stub(sourceHelpers, 'loadResource').callsFake(() => fakeStubs);
|
|
testLoad('JSTests/load.js', 'JSTests/load_expected.js');
|
|
});
|
|
});
|
|
|
|
describe('SpiderMonkey dependencies', () => {
|
|
it('test', () => {
|
|
testLoad(
|
|
'spidermonkey/test/load.js',
|
|
'spidermonkey/test/load_expected.js');
|
|
});
|
|
});
|