From 4ea2931f169d4a4b5a9a4a7c731cc92bf7b3e13c Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Fri, 14 Jul 2017 11:37:24 -0400 Subject: [PATCH] Update all harness files to pass linting. (#1153) ``` $ python tools/lint/lint.py --whitelist lint.whitelist harness/*.js Linting 25 files. Linting complete. 0 errors found. ``` - Renames detachArrayBuffer-$262.detachArrayBuffer.js -> detachArrayBuffer-host-detachArrayBuffer.js (previous naming prevents command-click from terminal) Signed-off-by: Rick Waldron --- harness/arrayContains.js | 9 +++++++-- harness/assert.js | 7 +++++++ harness/assertRelativeDateMs.js | 11 +++++++---- harness/atomicsHelper.js | 11 ++++++++--- harness/byteConversionValues.js | 16 ++++++++-------- harness/compareArray.js | 9 +++++++-- harness/dateConstants.js | 4 ++++ harness/decimalToHexString.js | 4 ++++ harness/detachArrayBuffer.js | 10 ++++++++++ harness/doneprintHandle.js | 7 +++++++ harness/fnGlobalObject.js | 8 +++++++- harness/nans.js | 15 +++++++++------ harness/nativeFunctionMatcher.js | 11 +++++++---- harness/promiseHelper.js | 11 ++++++++++- harness/propertyHelper.js | 7 +++++++ harness/proxyTrapsHelper.js | 8 ++++++++ harness/regExpUtils.js | 7 +++++++ harness/simdUtilities.js | 7 +++++++ harness/sta.js | 12 ++++++++++-- harness/tcoHelper.js | 15 ++++++++++++--- harness/testAtomics.js | 5 +++++ harness/testBuiltInObject.js | 4 ++++ harness/testIntl.js | 13 ++++++++----- harness/testTypedArray.js | 4 ++++ harness/timer.js | 6 ++++++ test/harness/arrayContains.js | 2 +- ... detachArrayBuffer-host-detachArrayBuffer.js} | 5 +++-- test/harness/detachArrayBuffer.js | 3 ++- 28 files changed, 186 insertions(+), 45 deletions(-) rename test/harness/{detachArrayBuffer-$262.detachArrayBuffer.js => detachArrayBuffer-host-detachArrayBuffer.js} (88%) diff --git a/harness/arrayContains.js b/harness/arrayContains.js index 5f758b933a..d68a42184a 100644 --- a/harness/arrayContains.js +++ b/harness/arrayContains.js @@ -1,6 +1,11 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Verify that a subArray is contained within an array. +---*/ + /** - * Verify that a subArray is contained within an array. - * * @param {Array} array * @param {Array} subArray */ diff --git a/harness/assert.js b/harness/assert.js index 1bd3d31fd1..4f4df41a1a 100644 --- a/harness/assert.js +++ b/harness/assert.js @@ -1,3 +1,10 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of assertion functions used throughout test262 +---*/ + function assert(mustBeTrue, message) { if (mustBeTrue === true) { return; diff --git a/harness/assertRelativeDateMs.js b/harness/assertRelativeDateMs.js index 20eb4b259c..a4ad32c527 100644 --- a/harness/assertRelativeDateMs.js +++ b/harness/assertRelativeDateMs.js @@ -1,10 +1,13 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Verify that the given date object's Number representation describes the + correct number of milliseconds since the Unix epoch relative to the local + time zone (as interpreted at the specified date). +---*/ + /** - * Verify that the given date object's Number representation describes the - * correct number of milliseconds since the Unix epoch relative to the local - * time zone (as interpreted at the specified date). - * * @param {Date} date * @param {Number} expectedMs */ diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js index 5854a3630d..5265061708 100644 --- a/harness/atomicsHelper.js +++ b/harness/atomicsHelper.js @@ -1,4 +1,9 @@ -// The amount of slack allowed for testing time-related Atomics methods (i.e. -// wait and wake). The absolute value of the difference of the observed time -// and the expected time must be epsilon-close. +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + The amount of slack allowed for testing time-related Atomics methods (i.e. + wait and wake). The absolute value of the difference of the observed time + and the expected time must be epsilon-close. +---*/ var $ATOMICS_MAX_TIME_EPSILON = 100; diff --git a/harness/byteConversionValues.js b/harness/byteConversionValues.js index a2074aefcb..bc7b9efdb2 100644 --- a/harness/byteConversionValues.js +++ b/harness/byteConversionValues.js @@ -1,13 +1,13 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - -/** - * Provide a list for original and expected values for different byte - * conversions. - * This helper is mostly used on tests for TypedArray and DataView, and each - * array from the expected values must match the original values array on every - * index containing its original value. - */ +/*--- +description: | + Provide a list for original and expected values for different byte + conversions. + This helper is mostly used on tests for TypedArray and DataView, and each + array from the expected values must match the original values array on every + index containing its original value. +---*/ var byteConversionValues = { values: [ 127, // 2 ** 7 - 1 diff --git a/harness/compareArray.js b/harness/compareArray.js index 228a6aaaec..44b92ea029 100644 --- a/harness/compareArray.js +++ b/harness/compareArray.js @@ -1,5 +1,10 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Compare the contents of two arrays +---*/ -//----------------------------------------------------------------------------- function compareArray(a, b) { if (b.length !== a.length) { return false; @@ -16,4 +21,4 @@ function compareArray(a, b) { assert.compareArray = function(actual, expected, message) { assert(compareArray(actual, expected), `Expected [${actual.join(", ")}] and [${expected.join(", ")}] to have the same contents. ${message}`); -} +}; diff --git a/harness/dateConstants.js b/harness/dateConstants.js index ebf2d75e54..14213b8b52 100644 --- a/harness/dateConstants.js +++ b/harness/dateConstants.js @@ -1,5 +1,9 @@ // Copyright (C) 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of date-centric values +---*/ var date_1899_end = -2208988800001; var date_1900_start = -2208988800000; diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js index 36a2bb5b49..c531c5f88f 100644 --- a/harness/decimalToHexString.js +++ b/harness/decimalToHexString.js @@ -1,5 +1,9 @@ // Copyright (C) 2017 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of various encoding operations. +---*/ function decimalToHexString(n) { var hex = "0123456789ABCDEF"; diff --git a/harness/detachArrayBuffer.js b/harness/detachArrayBuffer.js index 6e9982e997..df526d6627 100644 --- a/harness/detachArrayBuffer.js +++ b/harness/detachArrayBuffer.js @@ -1,3 +1,13 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. + +---*/ + function $DETACHBUFFER(buffer) { if (!$262 || typeof $262.detachArrayBuffer !== "function") { throw new Test262Error("No method available to detach an ArrayBuffer"); diff --git a/harness/doneprintHandle.js b/harness/doneprintHandle.js index e5e43821d9..625feef572 100644 --- a/harness/doneprintHandle.js +++ b/harness/doneprintHandle.js @@ -1,3 +1,10 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + +---*/ + function __consolePrintHandle__(msg){ print(msg); } diff --git a/harness/fnGlobalObject.js b/harness/fnGlobalObject.js index 9b39cdd9e0..1907c25209 100644 --- a/harness/fnGlobalObject.js +++ b/harness/fnGlobalObject.js @@ -1,4 +1,10 @@ -//----------------------------------------------------------------------------- +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Produce a reliable global object +---*/ + var __globalObject = Function("return this;")(); function fnGlobalObject() { return __globalObject; diff --git a/harness/nans.js b/harness/nans.js index c2392e1328..e541dba02b 100644 --- a/harness/nans.js +++ b/harness/nans.js @@ -1,9 +1,12 @@ -/** - * A collection of NaN values produced from expressions that have been observed - * to create distinct bit representations on various platforms. These provide a - * weak basis for assertions regarding the consistent canonicalization of NaN - * values in Array buffers. - */ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A collection of NaN values produced from expressions that have been observed + to create distinct bit representations on various platforms. These provide a + weak basis for assertions regarding the consistent canonicalization of NaN + values in Array buffers. +---*/ var distinctNaNs = [ 0/0, Infinity/Infinity, -(0/0), Math.pow(-1, 0.5), -Math.pow(-1, 0.5) ]; diff --git a/harness/nativeFunctionMatcher.js b/harness/nativeFunctionMatcher.js index f902f34141..0a2d248a35 100644 --- a/harness/nativeFunctionMatcher.js +++ b/harness/nativeFunctionMatcher.js @@ -1,5 +1,8 @@ -/** - * This regex makes a best-effort determination that the tested string matches - * the NativeFunction grammar production without requiring a correct tokeniser. - */ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This regex makes a best-effort determination that the tested string matches + the NativeFunction grammar production without requiring a correct tokeniser. +---*/ const NATIVE_FUNCTION_RE = /\bfunction\b[\s\S]*\([\s\S]*\)[\s\S]*\{[\s\S]*\[[\s\S]*\bnative\b[\s\S]+\bcode\b[\s\S]*\][\s\S]*\}/; diff --git a/harness/promiseHelper.js b/harness/promiseHelper.js index 0bdff33e44..66ae36daf9 100644 --- a/harness/promiseHelper.js +++ b/harness/promiseHelper.js @@ -1,4 +1,13 @@ -//----------------------------------------------------------------------------- +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Check that an array contains a numeric sequence starting at 1 + and incrementing by 1 for each entry in the array. Used by + Promise tests to assert the order of execution in deep Promise + resolution pipelines. +---*/ + function checkSequence(arr, message) { arr.forEach(function(e, i) { if (e !== (i+1)) { diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js index 1f04ea7f78..da69764dc1 100644 --- a/harness/propertyHelper.js +++ b/harness/propertyHelper.js @@ -1,3 +1,10 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to safely verify the correctness of + property descriptors. +---*/ function verifyProperty(obj, name, desc, options) { assert( diff --git a/harness/proxyTrapsHelper.js b/harness/proxyTrapsHelper.js index 402684cfbc..a438be9f05 100644 --- a/harness/proxyTrapsHelper.js +++ b/harness/proxyTrapsHelper.js @@ -1,3 +1,11 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +---*/ + function allowProxyTraps(overrides) { function throwTest262Error(msg) { return function () { throw new Test262Error(msg); }; diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js index 2db568ab29..bdb956427a 100644 --- a/harness/regExpUtils.js +++ b/harness/regExpUtils.js @@ -1,3 +1,10 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of RegExp objects. +---*/ + function buildString({ loneCodePoints, ranges }) { const CHUNK_SIZE = 10000; let result = String.fromCodePoint(...loneCodePoints); diff --git a/harness/simdUtilities.js b/harness/simdUtilities.js index c8396a7773..ba711a5ecb 100644 --- a/harness/simdUtilities.js +++ b/harness/simdUtilities.js @@ -1,5 +1,12 @@ // Copyright (C) 2016 ecmascript_simd authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of SIMD objects. + + No longer used in any tests. +---*/ + function minNum(x, y) { return x != x ? y : diff --git a/harness/sta.js b/harness/sta.js index 39fc5b98b6..341c21e765 100644 --- a/harness/sta.js +++ b/harness/sta.js @@ -1,5 +1,13 @@ -/// Copyright (c) 2012 Ecma International. All rights reserved. -/// This code is governed by the BSD license found in the LICENSE file. +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Provides both: + + - An error class to avoid false positives when testing for thrown exceptions + - A function to explicitly throw an exception using the Test262Error class +---*/ + function Test262Error(message) { this.message = message || ""; diff --git a/harness/tcoHelper.js b/harness/tcoHelper.js index 5e9bee2257..ecae612934 100644 --- a/harness/tcoHelper.js +++ b/harness/tcoHelper.js @@ -1,4 +1,13 @@ -// This defines the number of consecutive recursive function calls that must be -// made in order to prove that stack frames are properly destroyed according to -// ES2015 tail call optimization semantics. +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +---*/ + + + + var $MAX_ITERATIONS = 100000; diff --git a/harness/testAtomics.js b/harness/testAtomics.js index 2570e3ab81..81f6af3a60 100644 --- a/harness/testAtomics.js +++ b/harness/testAtomics.js @@ -1,5 +1,10 @@ // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of SharedArrayBuffer objects. +---*/ + /** * Calls the provided function for a each bad index that should throw a diff --git a/harness/testBuiltInObject.js b/harness/testBuiltInObject.js index c3ce749825..c78c0d732a 100644 --- a/harness/testBuiltInObject.js +++ b/harness/testBuiltInObject.js @@ -1,5 +1,9 @@ // Copyright 2012 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A function used to assert the correctness of built-in objects. +---*/ /** * @description Tests that obj meets the requirements for built-in objects diff --git a/harness/testIntl.js b/harness/testIntl.js index ddf953acd3..01315b175e 100644 --- a/harness/testIntl.js +++ b/harness/testIntl.js @@ -1,11 +1,14 @@ -// Copyright 2011-2012 Norbert Lindenberg. All rights reserved. -// Copyright 2012-2013 Mozilla Corporation. All rights reserved. +// Copyright (C) 2011 2012 Norbert Lindenberg. All rights reserved. +// Copyright (C) 2012 2013 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This file contains shared functions for the tests in the conformance test + suite for the ECMAScript Internationalization API. +author: Norbert Lindenberg +---*/ /** - * This file contains shared functions for the tests in the conformance test - * suite for the ECMAScript Internationalization API. - * @author Norbert Lindenberg */ diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js index aece79d8e5..2699214ca3 100644 --- a/harness/testTypedArray.js +++ b/harness/testTypedArray.js @@ -1,5 +1,9 @@ // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +---*/ /** * Array containing every typed array constructor. diff --git a/harness/timer.js b/harness/timer.js index f1089108be..2737939890 100644 --- a/harness/timer.js +++ b/harness/timer.js @@ -1,3 +1,9 @@ +// Copyright (C) 2017 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used in website/scripts/sth.js +---*/ //setTimeout is not available, hence this script was loaded if (Promise === undefined && this.setTimeout === undefined) { if(/\$DONE()/.test(code)) diff --git a/test/harness/arrayContains.js b/test/harness/arrayContains.js index 3f83e30878..bc51ec0f0b 100644 --- a/test/harness/arrayContains.js +++ b/test/harness/arrayContains.js @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Rick Waldron. All rights reserved. +// Copyright (C) 2017 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/harness/detachArrayBuffer-$262.detachArrayBuffer.js b/test/harness/detachArrayBuffer-host-detachArrayBuffer.js similarity index 88% rename from test/harness/detachArrayBuffer-$262.detachArrayBuffer.js rename to test/harness/detachArrayBuffer-host-detachArrayBuffer.js index 2d1d0a433c..2455167567 100644 --- a/test/harness/detachArrayBuffer-$262.detachArrayBuffer.js +++ b/test/harness/detachArrayBuffer-host-detachArrayBuffer.js @@ -6,7 +6,7 @@ description: > $DETACHBUFFER - $DETACHBUFFER relies on the presence of a definition for $262.detachArrayBuffer + $DETACHBUFFER relies on the presence of a host definition for $262.detachArrayBuffer includes: [detachArrayBuffer.js,sta.js] ---*/ @@ -14,7 +14,8 @@ includes: [detachArrayBuffer.js,sta.js] var $262 = { detachArrayBuffer() { throw new Test262Error('$262.detachArrayBuffer called.'); - } + }, + destroy() {} }; var ab = new ArrayBuffer(1); diff --git a/test/harness/detachArrayBuffer.js b/test/harness/detachArrayBuffer.js index 22d3b6c11a..71eb7dfa01 100644 --- a/test/harness/detachArrayBuffer.js +++ b/test/harness/detachArrayBuffer.js @@ -7,9 +7,10 @@ description: > $DETACHBUFFER $DETACHBUFFER relies on the presence of a definition for $262.detachArrayBuffer. + Without a definition, calling $DETACHBUFFER will result in a ReferenceError -includes: [detachArrayBuffer.js,sta.js] +includes: [sta.js] ---*/ var ab = new ArrayBuffer(1);