From 11da7285437d01f1ec8edadffcb4e3a19485dc6b Mon Sep 17 00:00:00 2001 From: Lukas Kurz Date: Tue, 23 Apr 2024 11:28:31 +0200 Subject: [PATCH 1/2] Fix incorrect code --- test/Array/array_splice.js | 7 ++++--- test/Array/array_splice_double.js | 7 ++++--- test/es5/RegExpStrictDelete.js | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/test/Array/array_splice.js b/test/Array/array_splice.js index f9599004c18..a0021425f77 100644 --- a/test/Array/array_splice.js +++ b/test/Array/array_splice.js @@ -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. //------------------------------------------------------------------------------------------------------- @@ -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); } @@ -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); } @@ -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); } diff --git a/test/Array/array_splice_double.js b/test/Array/array_splice_double.js index 29d8d744d11..eb97387b5c2 100644 --- a/test/Array/array_splice_double.js +++ b/test/Array/array_splice_double.js @@ -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. //------------------------------------------------------------------------------------------------------- @@ -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); } @@ -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); } @@ -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); } diff --git a/test/es5/RegExpStrictDelete.js b/test/es5/RegExpStrictDelete.js index e2652ed8922..378855fb57b 100644 --- a/test/es5/RegExpStrictDelete.js +++ b/test/es5/RegExpStrictDelete.js @@ -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. //------------------------------------------------------------------------------------------------------- @@ -22,7 +23,7 @@ for (var i = 0, len = props.length; i < len; i++) } catch (err) { - if (!err instanceof TypeError) + if (!(err instanceof TypeError)) WScript.Echo("Error: strict delete threw a non-TypeError: " + err); } } From c44098512f61ff9f8344728ae1be2309fcfb7599 Mon Sep 17 00:00:00 2001 From: Lukas Kurz Date: Tue, 23 Apr 2024 11:29:15 +0200 Subject: [PATCH 2/2] Fix formatting --- test/Array/array_splice_double.js | 68 ++++++++++++++----------------- test/es5/RegExpStrictDelete.js | 9 ++-- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/test/Array/array_splice_double.js b/test/Array/array_splice_double.js index eb97387b5c2..4e167efaf47 100644 --- a/test/Array/array_splice_double.js +++ b/test/Array/array_splice_double.js @@ -44,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); @@ -73,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); @@ -116,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 @@ -155,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()); \ No newline at end of file +WScript.Echo("arr.length = " + test0()); diff --git a/test/es5/RegExpStrictDelete.js b/test/es5/RegExpStrictDelete.js index 378855fb57b..a6e2a5e1459 100644 --- a/test/es5/RegExpStrictDelete.js +++ b/test/es5/RegExpStrictDelete.js @@ -9,20 +9,17 @@ 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) - { + catch (err) { if (!(err instanceof TypeError)) WScript.Echo("Error: strict delete threw a non-TypeError: " + err); }