@@ -8,11 +8,12 @@ var LIBS = {
8
8
} ;
9
9
var SRC_262 = __dirname + '/../tests/test262' ;
10
10
var SRC_DIR = SRC_262 + '/test/intl402' ;
11
- var DEST_DIR = SRC_262 + '/pages' ;
11
+ var DEST_DIR = SRC_262 + '/pages/intl402 ' ;
12
12
var INCLUDE_DIR = SRC_262 + '/harness' ;
13
13
14
14
var WRAPPER_START = [
15
- '//<html><head><meta http-equiv="X-UA-Compatible" content="IE=EDGE"><meta charset=utf-8></head><body><button onclick="runner()">Run</button> results: <span id="results">not yet run</span><script src="../../../dist/Intl.complete.js"></script><script>' ,
15
+ '//<html><head><meta http-equiv="X-UA-Compatible" content="IE=EDGE"><meta charset=utf-8></head><body><button onclick="runner()">Run</button> results: <span id="results">not yet run</span><script src="{{libPath}}"></script><script>' ,
16
+ '"use strict";' ,
16
17
// stuff defined in harness/*.js yet not pulled in via $INCLUDE()
17
18
'var __globalObject = Function("return this;")();' ,
18
19
'function fnGlobalObject() {' ,
@@ -110,10 +111,10 @@ var shims = {
110
111
shims [ 'Array.prototype.every' ] = shims [ 'Array.prototype.forEach' ] ;
111
112
112
113
function processTest ( content ) {
113
- var includes = [ ] ;
114
+ var includes = [ LIBS . fs . readFileSync ( LIBS . path . resolve ( INCLUDE_DIR , 'assert.js' ) ) . toString ( ) ] ;
114
115
content = content . replace ( / i n c l u d e s \: \[ ( .* ) ] / g, function ( all , path ) {
115
- path = LIBS . path . resolve ( INCLUDE_DIR , path ) ;
116
- includes . push ( LIBS . fs . readFileSync ( path ) . toString ( ) ) ;
116
+ var p = LIBS . path . resolve ( INCLUDE_DIR , path ) ;
117
+ includes . push ( LIBS . fs . readFileSync ( p ) . toString ( ) ) ;
117
118
return path ;
118
119
} ) ;
119
120
@@ -176,10 +177,10 @@ function processTest(content) {
176
177
177
178
178
179
// Turns test into an HTML page.
179
- function wrapTest ( content ) {
180
+ function wrapTest ( content , libPath ) {
180
181
// The weird "//" makes these html files also valid node.js scripts :)
181
182
return [
182
- WRAPPER_START ,
183
+ WRAPPER_START . replace ( '{{libPath}}' , libPath ) ,
183
184
content ,
184
185
WRAPPER_END
185
186
] . join ( '\n' ) ;
@@ -211,31 +212,41 @@ function listTests() {
211
212
}
212
213
213
214
function isValidTest ( testPath ) {
214
- // these are just trouble
215
- if ( testPath === '9.2.5_11_g_ii_2.js' ) {
215
+ // Collator tests are not supported
216
+ if ( [ 'Collator' , 'localeCompare' , 'toLocaleLowerCase' , 'toLocaleUpperCase' , '8.0_L15.js' ] . some ( function ( name ) {
217
+ return testPath . indexOf ( name ) !== - 1 ;
218
+ } ) ) {
216
219
return false ;
217
220
}
218
- if ( testPath . indexOf ( '13.1' ) === 0 ) {
221
+ // these are failing with: "Client code can adversely affect behavior: setter"
222
+ // and they were in previous incarnations
223
+ if ( [ '12.2.2_b.js' , '12.3.2_TLT_2.js' , '12.1.1_22.js' , '9.2.6_2.js' ] . some ( function ( name ) {
224
+ return testPath . indexOf ( name ) !== - 1 ;
225
+ } ) ) {
219
226
return false ;
220
227
}
221
- if ( testPath . indexOf ( '10' ) === 0 ) {
228
+ // Initialization issues, probably related to the v1 vs v2 vs v3
229
+ if ( [ '12.1.1_1.js' , '11.1.1_1.js' , '11.1.2.1_4.js' , '11.3_a.js' , '12.3_a.js' , '12.1.2.1_4.js' ] . some ( function ( name ) {
230
+ return testPath . indexOf ( name ) !== - 1 ;
231
+ } ) ) {
222
232
return false ;
223
233
}
224
-
225
- // this one requires more than one include, we need to fix the regex for that
226
- // and it was in previous incarnations
227
- if ( testPath === '8.0_L15.js' ) {
234
+ // timeZone is not supported by this polyfill
235
+ // Initialization issues, probably related to the v1 vs v2 vs v3
236
+ if ( [ '12.3.3.js' ] . some ( function ( name ) {
237
+ return testPath . indexOf ( name ) !== - 1 ;
238
+ } ) ) {
228
239
return false ;
229
240
}
230
- // these are failing with: "Client code can adversely affect behavior: setter"
231
- // and they were in previous incarnations
232
- if ( testPath === '12.2.2_b.js' ||
233
- testPath === '11.2.2_b.js' || // this one was in previous incarnations
234
- testPath === '9.2.1_2.js' ||
235
- testPath === '9.2.6_2.js' ) {
241
+ // other tests that are not very important
242
+ // 1. testing for the name of the functions
243
+ // TODO: to enable this test we will have to revisit almost all property methods to make it behave
244
+ // correctly instead of using bind and Object.defineProperty()
245
+ if ( [ 'name.js' ] . some ( function ( name ) {
246
+ return testPath . indexOf ( name ) !== - 1 ;
247
+ } ) ) {
236
248
return false ;
237
249
}
238
-
239
250
return true ;
240
251
}
241
252
@@ -251,9 +262,11 @@ module.exports = function(grunt) {
251
262
var srcPath = LIBS . path . resolve ( SRC_DIR , testPath ) ,
252
263
destPath = LIBS . path . resolve ( DEST_DIR , testPath ) ,
253
264
content ;
265
+ var libPath = LIBS . path . relative ( LIBS . path . dirname ( srcPath ) , LIBS . path . resolve ( __dirname , '../dist/Intl.complete.js' ) ) ;
266
+ console . log ( libPath , srcPath , LIBS . path . resolve ( __dirname , '../dist/Intl.complete.js' ) ) ;
254
267
content = 'function runTheTest () {' + grunt . file . read ( srcPath ) + ' }' ;
255
268
content = processTest ( content ) ;
256
- content = wrapTest ( content ) ;
269
+ content = wrapTest ( content , libPath ) ;
257
270
destPath = destPath . replace ( / \. j s $ / , '.html' ) ;
258
271
grunt . file . write ( destPath , content ) ;
259
272
} ) ;
0 commit comments