1- export const file1 = `// Copyright (C) 2017 Ecma International. All rights reserved.
1+ // @ts -nocheck
2+ function assert_file ( ) {
3+ // Copyright (C) 2017 Ecma International. All rights reserved.
24// This code is governed by the BSD license found in the LICENSE file.
35/*---
46description: |
@@ -104,9 +106,9 @@ assert.throws = function (expectedErrorConstructor, func, message) {
104106assert . _formatIdentityFreeValue = function formatIdentityFreeValue ( value ) {
105107 switch ( value === null ? 'null' : typeof value ) {
106108 case 'string' :
107- return typeof JSON !== "undefined" ? JSON.stringify(value) : \ `"$\ {value}"\ `;
109+ return typeof JSON !== "undefined" ? JSON . stringify ( value ) : `"${ value } "` ;
108110 case 'bigint' :
109- return \`$\ {value}n\ `;
111+ return ` $ {value } n`;
110112 case 'number' :
111113 if ( value === 0 && 1 / value === - Infinity ) return '-0' ;
112114 // falls through
@@ -128,8 +130,12 @@ assert._toString = function (value) {
128130 }
129131 throw err ;
130132 }
131- };` ;
132- export const file2 = `/// Copyright (c) 2012 Ecma International. All rights reserved.
133+ } ;
134+
135+ }
136+
137+ function sta ( ) {
138+ // Copyright (c) 2012 Ecma International. All rights reserved.
133139// This code is governed by the BSD license found in the LICENSE file.
134140/*---
135141description: |
@@ -153,4 +159,71 @@ Test262Error.thrower = function (message) {
153159
154160function $DONOTEVALUATE ( ) {
155161 throw "Test262: This statement should not be evaluated." ;
156- }` ;
162+ }
163+ }
164+
165+ function compareArray ( ) {
166+ // Copyright (C) 2017 Ecma International. All rights reserved.
167+ // This code is governed by the BSD license found in the LICENSE file.
168+ /*---
169+ description: |
170+ Compare the contents of two arrays
171+ defines: [compareArray]
172+ ---*/
173+
174+ function compareArray ( a , b ) {
175+ if ( b . length !== a . length ) {
176+ return false ;
177+ }
178+
179+ for ( var i = 0 ; i < a . length ; i ++ ) {
180+ if ( ! compareArray . isSameValue ( b [ i ] , a [ i ] ) ) {
181+ return false ;
182+ }
183+ }
184+ return true ;
185+ }
186+
187+ compareArray . isSameValue = function ( a , b ) {
188+ if ( a === 0 && b === 0 ) return 1 / a === 1 / b ;
189+ if ( a !== a && b !== b ) return true ;
190+
191+ return a === b ;
192+ } ;
193+
194+ compareArray . format = function ( arrayLike ) {
195+ return `[${ [ ] . map . call ( arrayLike , String ) . join ( ', ' ) } ]` ;
196+ } ;
197+
198+ assert . compareArray = function ( actual , expected , message ) {
199+ message = message === undefined ? '' : message ;
200+
201+ if ( typeof message === 'symbol' ) {
202+ message = message . toString ( ) ;
203+ }
204+
205+ assert ( actual != null , `Actual argument shouldn't be nullish. ${ message } ` ) ;
206+ assert ( expected != null , `Expected argument shouldn't be nullish. ${ message } ` ) ;
207+ var format = compareArray . format ;
208+ var result = compareArray ( actual , expected ) ;
209+
210+ // The following prevents actual and expected from being iterated and evaluated
211+ // more than once unless absolutely necessary.
212+ if ( ! result ) {
213+ assert ( false , `Actual ${ format ( actual ) } and expected ${ format ( expected ) } should have the same contents. ${ message } ` ) ;
214+ }
215+ } ;
216+ }
217+
218+ function toSource ( f ) {
219+ const str = f . toString ( ) ;
220+ const start = str . indexOf ( '{' ) + 2 ;
221+ const end = str . lastIndexOf ( '}' ) ;
222+ return str . slice ( start , end ) ;
223+ }
224+
225+ export const Test262HarnessFiles = {
226+ 'https://github.com/tc39/test262/blob/main/harness/assert.js' : toSource ( assert_file ) ,
227+ 'https://github.com/tc39/test262/blob/main/harness/sta.js' : toSource ( sta ) ,
228+ 'https://github.com/tc39/test262/blob/main/harness/compareArray.js' : toSource ( compareArray ) ,
229+ } ;
0 commit comments