Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix negated instanceof in tests #6989

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/Array/array_splice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -121,7 +122,7 @@ try
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
if (!(e instanceof TypeError)) throw(e);
WScript.Echo(y);
WScript.Echo(x);
}
Expand All @@ -132,7 +133,7 @@ try
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
if (!(e instanceof TypeError)) throw(e);
WScript.Echo(y);
WScript.Echo(x);
}
Expand All @@ -143,7 +144,7 @@ try
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
if (!(e instanceof TypeError)) throw(e);
WScript.Echo(y);
WScript.Echo(x);
}
Expand Down
69 changes: 31 additions & 38 deletions test/Array/array_splice_double.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -43,10 +44,10 @@ WScript.Echo(a);
WScript.Echo(x);

//Test array
var b = [8.32,9.232];
var c = [11.232,12.234];
var b = [8.32, 9.232];
var c = [11.232, 12.234];

x = a.splice(5,1);
x = a.splice(5, 1);
WScript.Echo(x);
WScript.Echo(a);

Expand All @@ -72,7 +73,7 @@ f.x = 0;
f.y = 1;
f.z = 2;

x = a.splice(1,2, f, "hello");
x = a.splice(1, 2, f, "hello");
WScript.Echo(x);
WScript.Echo(a);

Expand Down Expand Up @@ -115,37 +116,31 @@ WScript.Echo(x.length);
x = new String("hello world");
x.foo = Array.prototype.splice;
y = undefined;
try
{
y = x.foo(0, 5);
try {
y = x.foo(0, 5);
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
WScript.Echo(y);
WScript.Echo(x);
catch (e) {
if (!(e instanceof TypeError)) throw (e);
WScript.Echo(y);
WScript.Echo(x);
}

try
{
y = x.foo(0, 5);
try {
y = x.foo(0, 5);
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
WScript.Echo(y);
WScript.Echo(x);
catch (e) {
if (!(e instanceof TypeError)) throw (e);
WScript.Echo(y);
WScript.Echo(x);
}

try
{
y = x.foo(0, 13);
try {
y = x.foo(0, 13);
}
catch(e)
{
if (!e instanceof TypeError) throw(e);
WScript.Echo(y);
WScript.Echo(x);
catch (e) {
if (!(e instanceof TypeError)) throw (e);
WScript.Echo(y);
WScript.Echo(x);
}

WScript.Echo("Test: splice when the item to replace is not writable."); // WOOB: 1139812
Expand All @@ -154,23 +149,21 @@ Object.defineProperty(a, "0", { value: 0 });
Object.defineProperty(a, "1", { value: 1 });
a.length = 2;
try {
Array.prototype.splice.apply(a, [0, 1, 'z']);
Array.prototype.splice.apply(a, [0, 1, 'z']);
} catch (ex) {
WScript.Echo("e instanceOf TypeError = " + (ex instanceof TypeError));
WScript.Echo("e instanceOf TypeError = " + (ex instanceof TypeError));
}
WScript.Echo("a.length = " + a.length);

a = new Array(1000);
x = a.splice(1, 17, "a");

function test0()
{
var arr = [0,1.12,2.23,3,4.32,5,6.23,7,8,9];
for(var __loopvar4 = 0; __loopvar4 < 2; __loopvar4++)
{
arr.length --;
arr.splice(3,1,31.23,32.32,33.23);
function test0() {
var arr = [0, 1.12, 2.23, 3, 4.32, 5, 6.23, 7, 8, 9];
for (var __loopvar4 = 0; __loopvar4 < 2; __loopvar4++) {
arr.length--;
arr.splice(3, 1, 31.23, 32.32, 33.23);
}
return arr.length;
}
WScript.Echo("arr.length = " + test0());
WScript.Echo("arr.length = " + test0());
12 changes: 5 additions & 7 deletions test/es5/RegExpStrictDelete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

Expand All @@ -8,21 +9,18 @@
var props = Object.getOwnPropertyNames(RegExp);
props.sort();

for (var i = 0, len = props.length; i < len; i++)
{
for (var i = 0, len = props.length; i < len; i++) {
var prop = props[i];
if (prop === 'prototype')
continue;
try
{
try {
WScript.Echo("Testing: delete RegExp[" + prop + "]");
var result = delete RegExp[prop];
if (result === false)
WScript.Echo("Error: strict delete returned false");
}
catch (err)
{
if (!err instanceof TypeError)
catch (err) {
if (!(err instanceof TypeError))
WScript.Echo("Error: strict delete threw a non-TypeError: " + err);
}
}
Loading