tests: Port avmplus ecma3 Types tests

This commit is contained in:
Nathan Adams 2023-07-28 00:43:42 +02:00
parent a8410aa34e
commit d3606e3c9d
30 changed files with 537 additions and 0 deletions

View File

@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
// var SECTION = "8.1";
// var VERSION = "ECMA_1";
// var TITLE = "The undefined type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
var x;
array[item++] = Assert.expectEq(
"var x; typeof x",
"undefined",
typeof x);
var x;
array[item++] = Assert.expectEq(
"var x; typeof x == 'undefined",
true,
typeof x == 'undefined');
var x;
array[item++] = Assert.expectEq(
"var x; x == void 0",
true,
x == void 0);
return array;
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,3 @@
var x; typeof x PASSED!
var x; typeof x == 'undefined PASSED!
var x; x == void 0 PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
// var SECTION = "8.2";
// var VERSION = "ECMA_1";
// var TITLE = "The null type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
var x = null;
array[item++] = Assert.expectEq(
"var x = null; typeof x",
null,
x);
array[item++] = Assert.expectEq(
"typeof null",
"object",
typeof null);
return array;
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,2 @@
var x = null; typeof x PASSED!
typeof null PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
// var SECTION = "8.3";
// var VERSION = "ECMA_1";
// var TITLE = "The Boolean type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
var x:Boolean;
array[item++] = Assert.expectEq(
"var x:Boolean; typeof x",
"boolean",
typeof x);
var x:Boolean;
array[item++] = Assert.expectEq(
"var x:Boolean; typeof x == 'boolean'",
true,
typeof x == 'boolean');
var x:Boolean;
array[item++] = Assert.expectEq(
"var x:Boolean; x == false",
true,
x == false);
var x:Boolean;
array[item++] = Assert.expectEq(
"var x:Boolean; !x == true",
true,
!x == true);
return array;
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,4 @@
var x:Boolean; typeof x PASSED!
var x:Boolean; typeof x == 'boolean' PASSED!
var x:Boolean; x == false PASSED!
var x:Boolean; !x == true PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,86 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
// var SECTION = "8.4";
// var VERSION = "ECMA_1";
// var TITLE = "The String type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
array[item++] = Assert.expectEq(
"var s = ''; s.length",
0,
(s = '', s.length ) );
array[item++] = Assert.expectEq(
"var s = ''; s.charAt(0)",
"",
(s = '', s.charAt(0) ) );
for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) {
TEST_STRING += ("\\u"+ DecimalToHexString( i ) );
EXPECT_STRING += String.fromCharCode(i);
}
//TEST_STRING = '\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A'
array[item++] = Assert.expectEq(
"var s = '" + TEST_STRING+ "'; s",
EXPECT_STRING,
(s = '\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A', s ) );
array[item++] = Assert.expectEq(
"var s = '" + TEST_STRING+ "'; s.length",
0x007B-0x0041,
(s = '\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A', s.length ) );
return array;
}
function DecimalToHexString( n ) {
n = Number( n );
var h = "";
for ( var i = 3; i >= 0; i-- ) {
if ( n >= Math.pow(16, i) ){
var t = Math.floor( n / Math.pow(16, i));
n -= t * Math.pow(16, i);
if ( t >= 10 ) {
if ( t == 10 ) {
h += "A";
}
if ( t == 11 ) {
h += "B";
}
if ( t == 12 ) {
h += "C";
}
if ( t == 13 ) {
h += "D";
}
if ( t == 14 ) {
h += "E";
}
if ( t == 15 ) {
h += "F";
}
} else {
h += String( t );
}
} else {
h += "0";
}
}
return h;
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,4 @@
var s = ''; s.length PASSED!
var s = ''; s.charAt(0) PASSED!
var s = '\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A'; s PASSED!
var s = '\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A'; s.length PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,136 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
// var SECTION = "8.4";
// var VERSION = "ECMA_1";
// var TITLE = "The Number type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
//NaN values of ECMAScript
var s:Number = 'string'
array[item++] = Assert.expectEq(
"var s:Number = 'string'",
NaN,s );
var k:Number = 'string'
array[item++] = Assert.expectEq(
"Two NaN values are different from each other",
true,
(k!=s) );
//Positive Infinity and Negative Infinity
array[item++] = Assert.expectEq(
"The special value positive Infinity",
Infinity,
Number.POSITIVE_INFINITY );
array[item++] = Assert.expectEq(
"The special value negative Infinity",
-Infinity,
Number.NEGATIVE_INFINITY );
//Positive zero and Negative Zero
var x:Number = +0;
array[item++] = Assert.expectEq(
"positive zero",
+0,
x );
array[item++] = Assert.expectEq(
"positive zero",
true,
x==0 );
var y:Number = -0;
array[item++] = Assert.expectEq(
"Negative zero",
-0,
y );
array[item++] = Assert.expectEq(
"Negative zero",
true,
y==0 );
array[item++] = Assert.expectEq(
"Negative zero==Positive zero",
true,
y==x );
//Finite Non-zero values
//Finite nonzero values that are Normalised having the form s*m*2**e
// where s is +1 or -1, m is a positive integer less than 2**53 but not
// less than s**52 and e is an integer ranging from -1074 to 971
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is -1074",4.4501477170144023e-308,(1*((Math.pow(2,53))-1)*(Math.pow(2,-1074))) );
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is -1074",2.2250738585072014e-308,(1*(Math.pow(2,52))*(Math.pow(2,-1074))) );
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is 971", "1e+308",(1*(Math.pow(2,52))*(Math.pow(2,971)))+"" );
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is 971", "1.79769313486231e+308",(1*((Math.pow(2,53))-1)*(Math.pow(2,971)))+"" );
array[item++] = Assert.expectEq( "Negative finite Non zero values where e is -1074",-2.2250738585072014e-308,(-1*(Math.pow(2,52))*(Math.pow(2,-1074))) );
array[item++] = Assert.expectEq( "Negative finite Non zero values where e is 971", "-1e+308",(-1*(Math.pow(2,52))*(Math.pow(2,971)))+"" );
//Finite nonzero values that are denormalised having the form s*m*2**e
// where s is +1 or -1, m is a positive integer less than 2**52
// and e is -1074
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is -1074",1.1125369292536007e-308,(1*(Math.pow(2,51))*(Math.pow(2,-1074))) );
array[item++] = Assert.expectEq( "Positive finite Non zero values where e is -1074",-1.1125369292536007e-308,(-1*(Math.pow(2,51))*(Math.pow(2,-1074))) );
//When number value for Y is closest to 2**1024 should convert to Infinity where x is
// nonzero real mathematical quantity
var Y:Number = 1e+308*2
array[item++] = Assert.expectEq( "the number value for x closest to 2**1024",Infinity,Y);
array[item++] = Assert.expectEq( "the number value for x closest to 2**1024",Infinity,(1*(Math.pow(2,53))*(Math.pow(2,971))));
//When number value for z is closest to -2**1024 should convert to Infinity where x is
// nonzero real mathematical quantity
var z:Number = -1e+308*3
array[item++] = Assert.expectEq( "the number value for x closest to -2**1024",-Infinity,z);
//When number value for l is closest to +0 should convert to -0 where l is
// nonzero real mathematical quantity and less than 0
// Expected result should be -0, however, base 10 approximations of a base 2 number results in loss of precision
var l:Number = 1e-308*2
array[item++] = Assert.expectEq( "the number value for x closest to +0",1.9999999999999998e-308,l);
var m:Number = -1e-308*3
array[item++] = Assert.expectEq( "the number value for x closest to +0",-2.9999999999999997e-308,m);
return array;
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,22 @@
var s:Number = 'string' PASSED!
Two NaN values are different from each other PASSED!
The special value positive Infinity PASSED!
The special value negative Infinity PASSED!
positive zero PASSED!
positive zero PASSED!
Negative zero PASSED!
Negative zero PASSED!
Negative zero==Positive zero PASSED!
Positive finite Non zero values where e is -1074 PASSED!
Positive finite Non zero values where e is -1074 PASSED!
Positive finite Non zero values where e is 971 PASSED!
Positive finite Non zero values where e is 971 PASSED!
Negative finite Non zero values where e is -1074 PASSED!
Negative finite Non zero values where e is 971 PASSED!
Positive finite Non zero values where e is -1074 PASSED!
Positive finite Non zero values where e is -1074 PASSED!
the number value for x closest to 2**1024 PASSED!
the number value for x closest to 2**1024 PASSED!
the number value for x closest to -2**1024 PASSED!
the number value for x closest to +0 PASSED!
the number value for x closest to +0 PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true

View File

@ -0,0 +1,74 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
import flash.display.MovieClip; public class Test extends MovieClip {}
}
import com.adobe.test.Assert;
import com.adobe.test.Utils;
// var SECTION = "8.6.1";
// var VERSION = "ECMA_1";
// var TITLE = "Property attributes of Object type";
var testcases = getTestCases();
function getTestCases() {
var array = new Array();
var item = 0;
var OBJ_PROT = Object.prototype;
try{
Object.prototype=null
}catch(e:ReferenceError){
thisError=e.toString();
}finally{
array[item++]=Assert.expectEq("Verifying the read only property of Object.prototype","ReferenceError: Error #1074",Utils.referenceError(thisError));
}
array[item++] = Assert.expectEq(
"var OBJ_PROT = Object.prototype; Object.prototype = null; Object.prototype == OBJ_PROT",
true,
(OBJ_PROT = Object.prototype, Object.prototype == OBJ_PROT ) );
try{
Object.prototype=0
}catch(e:ReferenceError){
thisError=e.toString();
}finally{
array[item++]=Assert.expectEq("Verifying the read only property of Object.prototype","ReferenceError: Error #1074",Utils.referenceError(thisError));
}
array[item++] = Assert.expectEq(
"Object.prototype=0; Object.prototype",
Object.prototype,
Object.prototype );
var OBJ_PROT1 = Object.prototype;
delete( Object.prototype );
array[item++] = Assert.expectEq( "var OBJ_PROT1 = Object.prototype; delete( Object.prototype ); OBJ_PROT1 == Object.prototype", true, OBJ_PROT1 == Object.prototype);
array[item++] = Assert.expectEq( "delete( Object.prototype )", false, delete( Object.prototype ) );
var string = '';
for ( prop in Object ) {
string += ( prop == 'prototype' ) ? prop : '';
}
array[item++] = Assert.expectEq("var string = ''; for ( prop in Object ) { string += ( prop == 'prototype' ) ? prop: '' } string;","",string);
return ( array );
}
function MyObject( value ) {
this.value = value;
// the new Function() changes to function() {}.
this.valueOf = function() { return this.value; }
this.toString = function() { return this.value+''; }
this.valueOf = function() { return this.value; }
this.toString = function() { return this.value +'';}
}

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,7 @@
Verifying the read only property of Object.prototype PASSED!
var OBJ_PROT = Object.prototype; Object.prototype = null; Object.prototype == OBJ_PROT PASSED!
Verifying the read only property of Object.prototype PASSED!
Object.prototype=0; Object.prototype PASSED!
var OBJ_PROT1 = Object.prototype; delete( Object.prototype ); OBJ_PROT1 == Object.prototype PASSED!
delete( Object.prototype ) PASSED!
var string = ''; for ( prop in Object ) { string += ( prop == 'prototype' ) ? prop: '' } string; PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1