Skip to content

Commit cc270c7

Browse files
committed
Add the test262 helper file
1 parent af38970 commit cc270c7

1 file changed

Lines changed: 367 additions & 0 deletions

File tree

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
declare function $FAIL(message: any): void;
2+
declare function $PRINT(message: any): void;
3+
declare function accessorPropertyAttributesAreCorrect(obj: any, name: any, get: any, set: any, setVerifyHelpProp: any, enumerable: any, configurable: any): boolean;
4+
declare function arrayContains(arr: any, expected: any): boolean;
5+
declare function compareArray(aExpected: any, aActual: any): boolean;
6+
declare function testRun(id: any, path: any, description: any, codeString: any, result: any, error: any): void;
7+
declare var print: any;
8+
declare function dataPropertyAttributesAreCorrect(obj: any, name: any, value: any, writable: any, enumerable: any, configurable: any): boolean;
9+
declare var HoursPerDay: number;
10+
declare var MinutesPerHour: number;
11+
declare var SecondsPerMinute: number;
12+
declare var msPerDay: number;
13+
declare var msPerSecond: number;
14+
declare var msPerMinute: number;
15+
declare var msPerHour: number;
16+
declare var date_1899_end: number;
17+
declare var date_1900_start: number;
18+
declare var date_1969_end: number;
19+
declare var date_1970_start: number;
20+
declare var date_1999_end: number;
21+
declare var date_2000_start: number;
22+
declare var date_2099_end: number;
23+
declare var date_2100_start: number;
24+
declare var $LocalTZ: any, $DST_start_month: any, $DST_start_sunday: any, $DST_start_hour: any, $DST_start_minutes: any, $DST_end_month: any, $DST_end_sunday: any, $DST_end_hour: any, $DST_end_minutes: any;
25+
declare function Day(t: any): number;
26+
declare function TimeWithinDay(t: any): number;
27+
declare function DaysInYear(y: any): number;
28+
declare function DayFromYear(y: any): number;
29+
declare function TimeFromYear(y: any): number;
30+
declare function YearFromTime(t: any): number;
31+
declare function InLeapYear(t: any): number;
32+
declare function DayWithinYear(t: any): number;
33+
declare function MonthFromTime(t: any): number;
34+
declare function DateFromTime(t: any): number;
35+
declare function WeekDay(t: any): number;
36+
declare var LocalTZA: number;
37+
declare function DaysInMonth(m: any, leap: any): any;
38+
declare function GetSundayInMonth(t: any, m: any, count: any): any;
39+
declare function DaylightSavingTA(t: any): number;
40+
declare function LocalTime(t: any): any;
41+
declare function UTC(t: any): number;
42+
declare function HourFromTime(t: any): number;
43+
declare function MinFromTime(t: any): number;
44+
declare function SecFromTime(t: any): number;
45+
declare function msFromTime(t: any): number;
46+
declare function MakeTime(hour: any, min: any, sec: any, ms: any): any;
47+
declare function MakeDay(year: any, month: any, date: any): number;
48+
declare function MakeDate(day: any, time: any): any;
49+
declare function TimeClip(time: any): any;
50+
declare function ConstructDate(year: any, month: any, date: any, hours: any, minutes: any, seconds: any, ms: any): any;
51+
declare function __consolePrintHandle__(msg: any): void;
52+
declare function fnExists(): boolean;
53+
declare var __globalObject: any;
54+
declare function fnGlobalObject(): any;
55+
declare function testPrint(message: any): void;
56+
/**
57+
* It is not yet clear that runTestCase should pass the global object
58+
* as the 'this' binding in the call to testcase.
59+
*/
60+
declare var runTestCase: (testcase: any) => void;
61+
declare function assertTruthy(value: any): void;
62+
/**
63+
* falsy means we expect no error.
64+
* truthy means we expect some error.
65+
* A non-empty string means we expect an error whose .name is that string.
66+
*/
67+
declare var expectedErrorName: boolean;
68+
/**
69+
* What was thrown, or the string 'Falsy' if something falsy was thrown.
70+
* null if test completed normally.
71+
*/
72+
declare var actualError: any;
73+
declare function testStarted(expectedErrName: any): void;
74+
declare function testFinished(): void;
75+
declare function Presenter(): void;
76+
declare var presenter: any;
77+
declare var prec: any;
78+
declare function isEqual(num1: any, num2: any): boolean;
79+
declare function getPrecision(num: any): number;
80+
declare function ToInteger(p: any): any;
81+
declare function checkSequence<T>(arr: Promise<T>, message: string): void;
82+
declare var objectStore: {
83+
object: Object;
84+
};
85+
declare var functionStore: {
86+
fun: () => string;
87+
};
88+
declare function createEmulatedProxy<T>(target: T, emulatedProps: any, success?: any): T;
89+
declare function Section(parentSection: any, id: any, name: any): void;
90+
declare var NotEarlyErrorString: string;
91+
declare var EarlyErrorRePat: string;
92+
declare var NotEarlyError: Error;
93+
declare var $ERROR: any;
94+
declare function BrowserRunner(): void;
95+
declare function TestLoader(): void;
96+
declare function Controller(): void;
97+
declare var controller: any;
98+
declare function isSiteDebugMode(): boolean;
99+
/**
100+
* @description Helper handler method for tagged string templates
101+
*/
102+
declare function testHandler(literals: any): string;
103+
/**
104+
* @description Tests that obj meets the requirements for built-in objects
105+
* defined by the introduction of chapter 15 of the ECMAScript Language Specification.
106+
* @param {Object} obj the object to be tested.
107+
* @param {boolean} isFunction whether the specification describes obj as a function.
108+
* @param {boolean} isConstructor whether the specification describes obj as a constructor.
109+
* @param {String[]} properties an array with the names of the built-in properties of obj,
110+
* excluding length, prototype, or properties with non-default attributes.
111+
* @param {number} length for functions only: the length specified for the function
112+
* or derived from the argument list.
113+
* @author Norbert Lindenberg
114+
*/
115+
declare function testBuiltInObject(obj: any, isFunction: any, isConstructor: any, properties: any, length: any): boolean;
116+
/**
117+
* @description This is a helper file for testing detached typed arrays
118+
* @author Andrei Borodin (anborod)
119+
*/
120+
declare var lib: {
121+
init: () => void;
122+
dispose: () => void;
123+
detachItem: (item: any) => any;
124+
createDetachCallback: (arr: any, detachAfterNumIterations: any, valueToReturn: any) => (item: any) => any;
125+
createDetachValueOfObject: (arr: any, detachAfterNumIterations: any, value: any) => {
126+
valueOf: () => any;
127+
};
128+
createDetachToStringObject: (arr: any, detachAfterNumIterations: any, value: any) => {
129+
toString: () => string;
130+
};
131+
runTestCaseWrapper: (func: any) => void;
132+
expectTypeError: (func: any, reason: any) => void;
133+
expectRangeError: (func: any, reason: any) => void;
134+
expectError: (errorType: any, name: any, func: any, reason: any) => void;
135+
isDetached: (obj: any) => boolean;
136+
};
137+
declare function testIntlOptions(givenOptions: any, expectedOptions: any): void;
138+
/**
139+
* This file contains shared functions for the tests in the conformance test
140+
* suite for the ECMAScript Internationalization API.
141+
* @author Norbert Lindenberg
142+
*/
143+
/**
144+
* @description Calls the provided function for every service constructor in
145+
* the Intl object, until f returns a falsy value. It returns the result of the
146+
* last call to f, mapped to a boolean.
147+
* @param {Function} f the function to call for each service constructor in
148+
* the Intl object.
149+
* @param {Function} Constructor the constructor object to test with.
150+
* @result {Boolean} whether the test succeeded.
151+
*/
152+
declare function testWithIntlConstructors(f: any): boolean;
153+
/**
154+
* Returns the name of the given constructor object, which must be one of
155+
* Intl.Collator, Intl.NumberFormat, or Intl.DateTimeFormat.
156+
* @param {object} Constructor a constructor
157+
* @return {string} the name of the constructor
158+
*/
159+
declare function getConstructorName(Constructor: any): string;
160+
/**
161+
* Taints a named data property of the given object by installing
162+
* a setter that throws an exception.
163+
* @param {object} obj the object whose data property to taint
164+
* @param {string} property the property to taint
165+
*/
166+
declare function taintDataProperty(obj: any, property: any): void;
167+
/**
168+
* Taints a named method of the given object by replacing it with a function
169+
* that throws an exception.
170+
* @param {object} obj the object whose method to taint
171+
* @param {string} property the name of the method to taint
172+
*/
173+
declare function taintMethod(obj: any, property: any): void;
174+
/**
175+
* Taints the given properties (and similarly named properties) by installing
176+
* setters on Object.prototype that throw exceptions.
177+
* @param {Array} properties an array of property names to taint
178+
*/
179+
declare function taintProperties(properties: any): void;
180+
/**
181+
* Taints the Array object by creating a setter for the property "0" and
182+
* replacing some key methods with functions that throw exceptions.
183+
*/
184+
declare function taintArray(): void;
185+
declare var languages: string[];
186+
declare var scripts: string[];
187+
declare var countries: string[];
188+
declare var localeSupportInfo: {};
189+
/**
190+
* Gets locale support info for the given constructor object, which must be one
191+
* of Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat.
192+
* @param {object} Constructor the constructor for which to get locale support info
193+
* @return {object} locale support info with the following properties:
194+
* supported: array of fully supported language tags
195+
* byFallback: array of language tags that are supported through fallbacks
196+
* unsupported: array of unsupported language tags
197+
*/
198+
declare function getLocaleSupportInfo(Constructor: any): any;
199+
/**
200+
* @description Tests whether locale is a String value representing a
201+
* structurally valid and canonicalized BCP 47 language tag, as defined in
202+
* sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API
203+
* Specification.
204+
* @param {String} locale the string to be tested.
205+
* @result {Boolean} whether the test succeeded.
206+
*/
207+
declare function isCanonicalizedStructurallyValidLanguageTag(locale: any): boolean;
208+
/**
209+
* Tests whether the named options property is correctly handled by the given constructor.
210+
* @param {object} Constructor the constructor to test.
211+
* @param {string} property the name of the options property to test.
212+
* @param {string} type the type that values of the property are expected to have
213+
* @param {Array} [values] an array of allowed values for the property. Not needed for boolean.
214+
* @param {any} fallback the fallback value that the property assumes if not provided.
215+
* @param {object} testOptions additional options:
216+
* @param {boolean} isOptional whether support for this property is optional for implementations.
217+
* @param {boolean} noReturn whether the resulting value of the property is not returned.
218+
* @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent.
219+
* @param {object} extra additional option to pass along, properties are value -> {option: value}.
220+
* @return {boolean} whether the test succeeded.
221+
*/
222+
declare function testOption(Constructor: any, property: any, type: any, values: any, fallback: any, testOptions: any): boolean;
223+
/**
224+
* Tests whether the named property of the given object has a valid value
225+
* and the default attributes of the properties of an object literal.
226+
* @param {Object} obj the object to be tested.
227+
* @param {string} property the name of the property
228+
* @param {Function|Array} valid either a function that tests value for validity and returns a boolean,
229+
* an array of valid values.
230+
* @exception if the property has an invalid value.
231+
*/
232+
declare function testProperty(obj: any, property: any, valid: any): void;
233+
/**
234+
* Tests whether the named property of the given object, if present at all, has a valid value
235+
* and the default attributes of the properties of an object literal.
236+
* @param {Object} obj the object to be tested.
237+
* @param {string} property the name of the property
238+
* @param {Function|Array} valid either a function that tests value for validity and returns a boolean,
239+
* an array of valid values.
240+
* @exception if the property is present and has an invalid value.
241+
*/
242+
declare function mayHaveProperty(obj: any, property: any, valid: any): void;
243+
/**
244+
* Tests whether the given object has the named property with a valid value
245+
* and the default attributes of the properties of an object literal.
246+
* @param {Object} obj the object to be tested.
247+
* @param {string} property the name of the property
248+
* @param {Function|Array} valid either a function that tests value for validity and returns a boolean,
249+
* an array of valid values.
250+
* @exception if the property is missing or has an invalid value.
251+
*/
252+
declare function mustHaveProperty(obj: any, property: any, valid: any): void;
253+
/**
254+
* Tests whether the given object does not have the named property.
255+
* @param {Object} obj the object to be tested.
256+
* @param {string} property the name of the property
257+
* @exception if the property is present.
258+
*/
259+
declare function mustNotHaveProperty(obj: any, property: any): void;
260+
/**
261+
* Properties of the RegExp constructor that may be affected by use of regular
262+
* expressions, and the default values of these properties. Properties are from
263+
* https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties
264+
*/
265+
declare var regExpProperties: string[];
266+
declare var regExpPropertiesDefaultValues: any;
267+
/**
268+
* Tests that executing the provided function (which may use regular expressions
269+
* in its implementation) does not create or modify unwanted properties on the
270+
* RegExp constructor.
271+
*/
272+
declare function testForUnwantedRegExpChanges(testFunc: any): void;
273+
/**
274+
* Tests whether name is a valid BCP 47 numbering system name
275+
* and not excluded from use in the ECMAScript Internationalization API.
276+
* @param {string} name the name to be tested.
277+
* @return {boolean} whether name is a valid BCP 47 numbering system name and
278+
* allowed for use in the ECMAScript Internationalization API.
279+
*/
280+
declare function isValidNumberingSystem(name: any): boolean;
281+
/**
282+
* Provides the digits of numbering systems with simple digit mappings,
283+
* as specified in 11.3.2.
284+
*/
285+
declare var numberingSystemDigits: {
286+
arab: string;
287+
arabext: string;
288+
beng: string;
289+
deva: string;
290+
fullwide: string;
291+
gujr: string;
292+
guru: string;
293+
hanidec: string;
294+
khmr: string;
295+
knda: string;
296+
laoo: string;
297+
latn: string;
298+
mlym: string;
299+
mong: string;
300+
mymr: string;
301+
orya: string;
302+
tamldec: string;
303+
telu: string;
304+
thai: string;
305+
tibt: string;
306+
};
307+
/**
308+
* Tests that number formatting is handled correctly. The function checks that the
309+
* digit sequences in formatted output are as specified, converted to the
310+
* selected numbering system, and embedded in consistent localized patterns.
311+
* @param {Array} locales the locales to be tested.
312+
* @param {Array} numberingSystems the numbering systems to be tested.
313+
* @param {Object} options the options to pass to Intl.NumberFormat. Options
314+
* must include {useGrouping: false}, and must cause 1.1 to be formatted
315+
* pre- and post-decimal digits.
316+
* @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings
317+
* in unlocalized format with Western digits.
318+
*/
319+
declare function testNumberFormat(locales: any, numberingSystems: any, options: any, testData: any): void;
320+
/**
321+
* Return the components of date-time formats.
322+
* @return {Array} an array with all date-time components.
323+
*/
324+
declare function getDateTimeComponents(): string[];
325+
/**
326+
* Return the valid values for the given date-time component, as specified
327+
* by the table in section 12.1.1.
328+
* @param {string} component a date-time component.
329+
* @return {Array} an array with the valid values for the component.
330+
*/
331+
declare function getDateTimeComponentValues(component: any): any;
332+
/**
333+
* Tests that the given value is valid for the given date-time component.
334+
* @param {string} component a date-time component.
335+
* @param {string} value the value to be tested.
336+
* @return {boolean} true if the test succeeds.
337+
* @exception if the test fails.
338+
*/
339+
declare function testValidDateTimeComponentValue(component: any, value: any): boolean;
340+
/**
341+
* Verifies that the actual array matches the expected one in length, elements,
342+
* and element order.
343+
* @param {Array} expected the expected array.
344+
* @param {Array} actual the actual array.
345+
* @return {boolean} true if the test succeeds.
346+
* @exception if the test fails.
347+
*/
348+
declare function testArraysAreSame(expected: any, actual: any): boolean;
349+
/**
350+
* @description Helper methods for TypedArrays
351+
*/
352+
declare function CreateTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Float32Array, typeof Float64Array, typeof Uint8ClampedArray];
353+
declare function CreateTypedArrayInstances(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray];
354+
declare function CreateIntegerTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Uint8ClampedArray];
355+
declare function CreateIntegerTypedArrays(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Uint8ClampedArray];
356+
declare function CreateTypedRedcuedSetOfArrayTypes(): [typeof Float64Array];
357+
declare function CreateTypedRedcuedSetOfArrays(obj: any): [Float64Array];
358+
declare function CreateTypedArraysFrom(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray];
359+
declare function CreateTypedArraysOf(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray];
360+
declare function CreateTypedArraysFromMapFn(obj: any, mapFn: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray];
361+
declare function CreateTypedArraysFromThisObj(obj: any, mapFn: any, thisArg: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray];
362+
declare function CreatestringsOf(obj: any): string[];
363+
declare function CreateSignedTypedArrayInstances(obj: any): [Int8Array, Int16Array, Int32Array, Float32Array, Float64Array];
364+
declare function CreateUnSignedTypedArrayInstances(obj: any): [Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray];
365+
declare var $LOG: any;
366+
declare var WScript: any;
367+
declare var $DONE: any;

0 commit comments

Comments
 (0)