this-value-ignored.js (1068B)
1 // Copyright 2012 Mozilla Corporation. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 10.1.1_1 6 description: Tests that the this-value is ignored in Collator. 7 author: Norbert Lindenberg 8 includes: [testIntl.js] 9 ---*/ 10 11 testWithIntlConstructors(function (Constructor) { 12 var obj, newObj; 13 14 // variant 1: use constructor in a "new" expression 15 obj = new Constructor(); 16 newObj = Intl.Collator.call(obj); 17 assert.notSameValue(obj, newObj, "Collator object created with \"new\" was not ignored as this-value."); 18 19 // variant 2: use constructor as a function 20 if (Constructor !== Intl.Collator && 21 Constructor !== Intl.NumberFormat && 22 Constructor !== Intl.DateTimeFormat) 23 { 24 // Newer Intl constructors are not callable as a function. 25 return; 26 } 27 obj = Constructor(); 28 newObj = Intl.Collator.call(obj); 29 assert.notSameValue(obj, newObj, "Collator object created with constructor as function was not ignored as this-value."); 30 }); 31 32 reportCompare(0, 0);