mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
65 lines
2.5 KiB
JavaScript
65 lines
2.5 KiB
JavaScript
//@ skip
|
|
// To execute this test, need to specify the JSC_exposeInternalModuleLoader environment variable and execute it on non Windows platform.
|
|
function shouldBe(actual, expected) {
|
|
if (actual !== expected)
|
|
throw new Error(`bad value: ${String(actual)}`);
|
|
}
|
|
|
|
function shouldResolve(name, referrer, expected)
|
|
{
|
|
var promise = Loader.resolve(name, referrer);
|
|
return promise.then(function (actual) {
|
|
shouldBe(actual, expected);
|
|
});
|
|
}
|
|
|
|
function shouldThrow(name, referrer, errorMessage)
|
|
{
|
|
var notThrown = false;
|
|
return Loader.resolve(name, referrer).then(function (error) {
|
|
notThrown = true;
|
|
}).catch(function (error) {
|
|
shouldBe(String(error), errorMessage);
|
|
}).then(function () {
|
|
if (notThrown)
|
|
throw new Error("not thrown");
|
|
});
|
|
}
|
|
|
|
var error = null;
|
|
|
|
// On windows platform, all "/" becomes "\".
|
|
Promise.all([
|
|
shouldResolve('tmp.js', '/home/WebKit/', '/home/WebKit/tmp.js'),
|
|
shouldResolve('tmp.js', '/home/', '/home/tmp.js'),
|
|
shouldResolve('/tmp.js', '/home/WebKit/', '/tmp.js'),
|
|
shouldResolve('///tmp.js', '/home/WebKit/', '/tmp.js'),
|
|
shouldResolve('.///tmp.js', '/home/WebKit/', '/home/WebKit/tmp.js'),
|
|
shouldResolve('./../tmp.js', '/home/WebKit/', '/home/tmp.js'),
|
|
shouldResolve('./../../tmp.js', '/home/WebKit/', '/tmp.js'),
|
|
shouldResolve('./../../../tmp.js', '/home/WebKit/', '/tmp.js'),
|
|
shouldResolve('./../../home/../tmp.js', '/home/WebKit/', '/tmp.js'),
|
|
shouldResolve('./../../../home/WebKit/../tmp.js', '/home/WebKit/', '/home/tmp.js'),
|
|
shouldResolve('../home/WebKit/tmp.js', '/home/WebKit/', '/home/home/WebKit/tmp.js'),
|
|
shouldResolve('../home/WebKit/../tmp.js', '/home/WebKit/', '/home/home/tmp.js'),
|
|
shouldResolve('./tmp.js', '/home/WebKit/hello.js', '/home/WebKit/tmp.js'),
|
|
|
|
shouldResolve('./tmp.js', 'C:/', 'C:/tmp.js'),
|
|
shouldResolve('./tmp.js', 'C:/home/', 'C:/home/tmp.js'),
|
|
shouldResolve('../tmp.js', 'C:/home/', 'C:/tmp.js'),
|
|
shouldResolve('../../tmp.js', 'C:/home/', 'C:/tmp.js'),
|
|
shouldResolve('./hello/tmp.js', 'C:/home/', 'C:/home/hello/tmp.js'),
|
|
shouldResolve('/tmp.js', 'C:/home/', 'C:/tmp.js'),
|
|
|
|
shouldThrow('/tmp.js', '', `Error: Could not resolve the referrer name ''.`),
|
|
shouldThrow('/tmp.js', 'hello', `Error: Could not resolve the referrer name 'hello'.`),
|
|
shouldThrow('tmp.js', 'hello', `Error: Could not resolve the referrer name 'hello'.`),
|
|
]).catch(function (e) {
|
|
error = e;
|
|
});
|
|
|
|
// Force to run all pending tasks.
|
|
drainMicrotasks();
|
|
if (error)
|
|
throw error;
|