-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
23,877 additions
and
23,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11,002 changes: 5,501 additions & 5,501 deletions
11,002
lib/Runtime/Library/InJavascript/Intl.js.bc.32b.h
Large diffs are not rendered by default.
Oops, something went wrong.
11,005 changes: 5,502 additions & 5,503 deletions
11,005
lib/Runtime/Library/InJavascript/Intl.js.bc.64b.h
Large diffs are not rendered by default.
Oops, something went wrong.
9,640 changes: 4,820 additions & 4,820 deletions
9,640
lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.32b.h
Large diffs are not rendered by default.
Oops, something went wrong.
9,633 changes: 4,816 additions & 4,817 deletions
9,633
lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.64b.h
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,463 changes: 785 additions & 678 deletions
1,463
lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js.bc.32b.h
Large diffs are not rendered by default.
Oops, something went wrong.
1,463 changes: 785 additions & 678 deletions
1,463
lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js.bc.64b.h
Large diffs are not rendered by default.
Oops, something went wrong.
1,357 changes: 730 additions & 627 deletions
1,357
lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js.nojit.bc.32b.h
Large diffs are not rendered by default.
Oops, something went wrong.
1,357 changes: 730 additions & 627 deletions
1,357
lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js.nojit.bc.64b.h
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js"); | ||
|
||
function verifyProperties(obj, property, value) | ||
{ | ||
const descriptor = Object.getOwnPropertyDescriptor(obj, property); | ||
assert.areEqual(value, obj[property], "Object.fromEntries should set correct valued"); | ||
assert.isTrue(descriptor.enumerable, "Object.fromEntries should create enumerable properties"); | ||
assert.isTrue(descriptor.configurable, "Object.fromEntries should create configurable properties"); | ||
assert.isTrue(descriptor.writable, "Object.fromEntries should create writable properties"); | ||
obj[property] = "other value"; | ||
assert.areEqual("other value", obj[property], "should actually be able to write to properties created by Object.fromEntries"); | ||
assert.doesNotThrow(()=>{"use strict"; delete obj[property];}, "deleting properties created by Object.fromEntries should not throw"); | ||
assert.isUndefined(obj[property], "deleting properties created by Object.fromEntries should succeed"); | ||
} | ||
|
||
function verifyObject(expected, actual) | ||
{ | ||
for (let i in expected) | ||
{ | ||
assert.isTrue(actual.hasOwnProperty(i), "Object.fromEntries shouldn't create unexpected properties"); | ||
} | ||
for (let i in expected) | ||
{ | ||
verifyProperties(actual, i, expected[i]); | ||
} | ||
} | ||
|
||
|
||
const tests = [ | ||
{ | ||
name : "Object.fromEntries invalid parameters", | ||
body : function () { | ||
assert.throws(()=>{Object.fromEntries(null);}, TypeError, "Object.fromEntries throws when called with null parameter"); | ||
assert.throws(()=>{Object.fromEntries(undefined);}, TypeError, "Object.fromEntries throws when called with undefined parameter"); | ||
assert.throws(()=>{Object.fromEntries("something");}, TypeError, "Object.fromEntries throws when called with string literal parameter"); | ||
assert.throws(()=>{Object.fromEntries(456);}, TypeError, "Object.fromEntries throws when called with number literal parameter"); | ||
assert.throws(()=>{Object.fromEntries(Number());}, TypeError, "Object.fromEntries throws when called with Number Object parameter"); | ||
assert.doesNotThrow(()=>{Object.fromEntries(String());}, "Object.fromEntries does not throw when called with String Object parameter with length 0"); | ||
assert.throws(()=>{Object.fromEntries(String("anything"));}, TypeError, "Object.fromEntries throws when called with String Object parameter with length > 0"); | ||
assert.throws(()=>{Object.fromEntries({});}, TypeError, "Object.fromEntries throws when called with Object literal"); | ||
assert.throws(()=>{Object.fromEntries({a : "5", b : "10"});}, TypeError, "Object.fromEntries throws when called with Object literal"); | ||
} | ||
}, | ||
{ | ||
name : "Object.fromEntries basic cases", | ||
body : function () { | ||
const obj1 = Object.fromEntries([["first", 50], ["second", 30], ["third", 60], ["fourth", 70]]); | ||
verifyObject({first : 50, second : 30, third : 60, fourth : 70}, obj1); | ||
const obj2 = Object.fromEntries([Object("a12234"),Object("b2kls"),Object("c3deg")]); | ||
verifyObject({a : "1", b : "2", c : "3"}, obj2); | ||
} | ||
}, | ||
{ | ||
name : "Object.fromEntries does not call setters", | ||
body : function () { | ||
let calledSet = false; | ||
Object.defineProperty(Object.prototype, "prop", { | ||
set : function () { calledSet = true; } | ||
}); | ||
const obj = Object.fromEntries([["prop", 10]]); | ||
verifyProperties(obj, "prop", 10); | ||
assert.isFalse(calledSet, "Object.fromEntries should not call setters"); | ||
} | ||
}, | ||
{ | ||
name : "Object.fromEntries iterates over generators", | ||
body : function () { | ||
function* gen1 () | ||
{ | ||
yield ["val1", 10]; | ||
yield ["val2", 50]; | ||
yield ["val3", 60, "other stuff"]; | ||
} | ||
const obj = Object.fromEntries(gen1()); | ||
verifyObject({val1 : 10, val2 : 50, val3: 60}, obj); | ||
let unreachable = false; | ||
function* gen2 () | ||
{ | ||
yield ["val1", 10]; | ||
yield "val2"; | ||
unreachable = true; | ||
yield ["val3", 60, "other stuff"]; | ||
} | ||
assert.throws(()=>{Object.fromEntries(gen2())}, TypeError, "When generator provides invalid case Object.fromEntries should throw"); | ||
assert.isFalse(unreachable, "Object.fromEntries does not continue after invalid case provided"); | ||
} | ||
}, | ||
{ | ||
name : "Object.fromEntries access properties in correct order", | ||
body : function () { | ||
const accessedProps = []; | ||
const handler = { | ||
get : function (target, prop, receiver) { | ||
accessedProps.push(prop + Reflect.get(target, prop)); | ||
return Reflect.get(target, prop); | ||
} | ||
} | ||
|
||
function* gen () { | ||
yield new Proxy(["a", "b", "c"], handler); | ||
yield new Proxy(["e", "g", "h", "j"], handler); | ||
} | ||
const obj = Object.fromEntries(gen()); | ||
verifyObject({a : "b", e : "g"}, obj); | ||
const expected = ["0a", "1b", "0e", "1g"]; | ||
const len = accessedProps.length; | ||
assert.areEqual(4, len, "Object.fromEntries accesses correct number of properties"); | ||
for (let i = 0; i < len; ++i) | ||
{ | ||
assert.areEqual(expected[i], accessedProps[i], "Object.fromEntries accesses the correct properties"); | ||
} | ||
} | ||
}, | ||
{ | ||
name : "Object.fromEntries properties", | ||
body : function () { | ||
assert.areEqual("fromEntries", Object.fromEntries.name, "Object.fromEntries.name should be 'fromEntries'"); | ||
assert.areEqual(1, Object.fromEntries.length, "Object.fromEntries.length should be 1"); | ||
const descriptor = Object.getOwnPropertyDescriptor(Object, "fromEntries"); | ||
assert.isFalse(descriptor.enumerable, "Object.fromEntries should be enumerable"); | ||
assert.isTrue(descriptor.writable, "Object.fromEntries should be writable"); | ||
assert.isTrue(descriptor.configurable, "Object.fromEntries should be configurable"); | ||
assert.doesNotThrow(()=>{"use strict"; delete Object.fromEntries.length;}, "Deleting Object.fromEntries.length should succeed"); | ||
assert.areEqual(0, Object.fromEntries.length, "After deletion Object.fromEntries.length should be 0"); | ||
assert.doesNotThrow(()=>{"use strict"; delete Object.fromEntries;}, "Deleting Object.fromEntries should succeed"); | ||
assert.isUndefined(Object.fromEntries, "After deletion Object.fromEntries should be undefined"); | ||
} | ||
} | ||
]; | ||
|
||
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters