tests: Add tests for `Add`, `Equals`, `Less` and `GetProperty` actions

This commit is contained in:
Toad06 2022-04-12 19:46:36 +02:00 committed by Mike Welsh
parent b2b1b5fa25
commit 65d58f4733
34 changed files with 966 additions and 0 deletions

View File

@ -100,6 +100,9 @@ macro_rules! swf_tests_approx {
// Inside the folder is expected to be "test.swf" and "output.txt" with the correct output.
swf_tests! {
(action_to_integer, "avm1/action_to_integer", 1),
(add_swf4, "avm1/add_swf4", 1),
(add_swf5, "avm1/add_swf5", 1),
(add, "avm1/add", 1),
(add2, "avm1/add2", 1),
(add_property, "avm1/add_property", 1),
(arguments, "avm1/arguments", 1),
@ -551,6 +554,9 @@ swf_tests! {
(edittext_width_height, "avm1/edittext_width_height", 1),
(empty_movieclip_can_attach_movies, "avm1/empty_movieclip_can_attach_movies", 1),
(equals_swf4, "avm1/equals_swf4", 1),
(equals_swf4_alt, "avm1/equals_swf4_alt", 1),
(equals_swf5, "avm1/equals_swf5", 1),
(equals, "avm1/equals", 1),
(equals2_swf5, "avm1/equals2_swf5", 1),
(equals2_swf6, "avm1/equals2_swf6", 1),
(equals2_swf7, "avm1/equals2_swf7", 1),
@ -568,6 +574,9 @@ swf_tests! {
(function_base_clip, "avm1/function_base_clip", 2),
(funky_function_calls, "avm1/funky_function_calls", 1),
(get_bytes_total, "avm1/get_bytes_total", 1),
(getproperty_swf4, "avm1/getproperty_swf4", 1),
(getproperty_swf5, "avm1/getproperty_swf5", 1),
(getproperty, "avm1/getproperty", 1),
(get_variable_in_scope, "avm1/get_variable_in_scope", 1),
(global_array, "avm1/global_array", 1),
(global_is_bare, "avm1/global_is_bare", 1),
@ -615,6 +624,9 @@ swf_tests! {
(issue_4377, "avm1/issue_4377", 1),
(issue_710, "avm1/issue_710", 1),
(lessthan_swf4, "avm1/lessthan_swf4", 1),
(lessthan_swf4_alt, "avm1/lessthan_swf4_alt", 1),
(lessthan_swf5, "avm1/lessthan_swf5", 1),
(lessthan, "avm1/lessthan", 1),
(lessthan2_swf5, "avm1/lessthan2_swf5", 1),
(lessthan2_swf6, "avm1/lessthan2_swf6", 1),
(lessthan2_swf7, "avm1/lessthan2_swf7", 1),

View File

@ -0,0 +1,54 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "4";
}};
trace("// 'ab' + 'cd'");
a = "ab" + "cd";
trace(a);
trace("");
trace("// 300 + '150' + true");
a = 300 + "150" + true;
trace(a);
trace("");
trace("// '300' + '150a'");
a = "300" + "150a";
trace(a);
trace("");
trace("// '300' + '0x96' + '010'");
a = "300" + "0x96" + "010";
trace(a);
trace("");
trace("// '300' + undefined");
a = "300" + undefined;
trace(a);
trace("");
trace("// '300' + null");
a = "300" + null;
trace(a);
trace("");
trace("// '300' + NaN");
a = "300" + NaN;
trace(a);
trace("");
trace("// '300' + Infinity");
a = "300" + Infinity;
trace(a);
trace("");
trace("// obj_1 + obj_2");
a = obj_1 + obj_2;
trace(a);

View File

@ -0,0 +1,28 @@
// 'ab' + 'cd'
NaN
// 300 + '150' + true
451
// '300' + '150a'
NaN
// '300' + '0x96' + '010'
458
// '300' + undefined
NaN
// '300' + null
NaN
// '300' + NaN
NaN
// '300' + Infinity
Infinity
// obj_1 + obj_2
OBJ_1
OBJ_2
5

Binary file not shown.

View File

@ -0,0 +1,54 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "4";
}};
trace("// 'ab' + 'cd'");
a = "ab" + "cd";
trace(a);
trace("");
trace("// 300 + '150' + true");
a = 300 + "150" + true;
trace(a);
trace("");
trace("// '300' + '150a'");
a = "300" + "150a";
trace(a);
trace("");
trace("// '300' + '0x96' + '010'");
a = "300" + "0x96" + "010";
trace(a);
trace("");
trace("// '300' + undefined");
a = "300" + undefined;
trace(a);
trace("");
trace("// '300' + null");
a = "300" + null;
trace(a);
trace("");
trace("// '300' + NaN");
a = "300" + NaN;
trace(a);
trace("");
trace("// '300' + Infinity");
a = "300" + Infinity;
trace(a);
trace("");
trace("// obj_1 + obj_2");
a = obj_1 + obj_2;
trace(a);

View File

@ -0,0 +1,28 @@
// 'ab' + 'cd'
0
// 300 + '150' + true
451
// '300' + '150a'
450
// '300' + '0x96' + '010'
310
// '300' + undefined
300
// '300' + null
300
// '300' + NaN
NaN
// '300' + Infinity
Infinity
// obj_1 + obj_2
OBJ_1
OBJ_2
5

Binary file not shown.

View File

@ -0,0 +1,54 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "4";
}};
trace("// 'ab' + 'cd'");
a = "ab" + "cd";
trace(a);
trace("");
trace("// 300 + '150' + true");
a = 300 + "150" + true;
trace(a);
trace("");
trace("// '300' + '150a'");
a = "300" + "150a";
trace(a);
trace("");
trace("// '300' + '0x96' + '010'");
a = "300" + "0x96" + "010";
trace(a);
trace("");
trace("// '300' + undefined");
a = "300" + undefined;
trace(a);
trace("");
trace("// '300' + null");
a = "300" + null;
trace(a);
trace("");
trace("// '300' + NaN");
a = "300" + NaN;
trace(a);
trace("");
trace("// '300' + Infinity");
a = "300" + Infinity;
trace(a);
trace("");
trace("// obj_1 + obj_2");
a = obj_1 + obj_2;
trace(a);

View File

@ -0,0 +1,28 @@
// 'ab' + 'cd'
NaN
// 300 + '150' + true
451
// '300' + '150a'
NaN
// '300' + '0x96' + '010'
NaN
// '300' + undefined
300
// '300' + null
300
// '300' + NaN
NaN
// '300' + Infinity
Infinity
// obj_1 + obj_2
OBJ_1
OBJ_2
5

Binary file not shown.

View File

@ -0,0 +1,60 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "1";
}};
trace("// '100' == '100ABC'");
a = "100" == "100ABC";
trace(a);
trace("");
trace("// '0x10' == '16'");
a = "0x10" == "16";
trace(a);
trace("");
trace("// '010' == '8'");
a = "010" == "8";
trace(a);
trace("");
trace("// 'true' == '0x1'");
a = "true" == "0x1";
trace(a);
trace("");
trace("// undefined == 0");
a = undefined == 0;
trace(a);
trace("");
trace("// null == 0");
a = null == 0;
trace(a);
trace("");
trace("// 'Infinity' == Infinity");
a = "Infinity" == Infinity;
trace(a);
trace("");
trace("// n = NaN;\n// n == NaN");
n = NaN;
a = n == NaN;
trace(a);
trace("");
trace("// n == n");
a = n == n;
trace(a);
trace("");
trace("// obj_1 == obj_2");
a = obj_1 == obj_2;
trace(a);

View File

@ -0,0 +1,32 @@
// '100' == '100ABC'
false
// '0x10' == '16'
true
// '010' == '8'
true
// 'true' == '0x1'
false
// undefined == 0
false
// null == 0
false
// 'Infinity' == Infinity
false
// n = NaN;
// n == NaN
false
// n == n
false
// obj_1 == obj_2
OBJ_2
OBJ_1
true

Binary file not shown.

View File

@ -0,0 +1,60 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "1";
}};
trace("// '100' == '100ABC'");
a = "100" == "100ABC";
trace(a);
trace("");
trace("// '0x10' == '16'");
a = "0x10" == "16";
trace(a);
trace("");
trace("// '010' == '8'");
a = "010" == "8";
trace(a);
trace("");
trace("// 'true' == '0x1'");
a = "true" == "0x1";
trace(a);
trace("");
trace("// undefined == 0");
a = undefined == 0;
trace(a);
trace("");
trace("// null == 0");
a = null == 0;
trace(a);
trace("");
trace("// 'Infinity' == Infinity");
a = "Infinity" == Infinity;
trace(a);
trace("");
trace("// n = NaN;\n// n == NaN");
n = NaN;
a = n == NaN;
trace(a);
trace("");
trace("// n == n");
a = n == n;
trace(a);
trace("");
trace("// obj_1 == obj_2");
a = obj_1 == obj_2;
trace(a);

View File

@ -0,0 +1,32 @@
// '100' == '100ABC'
1
// '0x10' == '16'
0
// '010' == '8'
0
// 'true' == '0x1'
1
// undefined == 0
1
// null == 0
1
// 'Infinity' == Infinity
0
// n = NaN;
// n == NaN
0
// n == n
0
// obj_1 == obj_2
OBJ_2
OBJ_1
1

Binary file not shown.

View File

@ -0,0 +1,60 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "1";
}};
trace("// '100' == '100ABC'");
a = "100" == "100ABC";
trace(a);
trace("");
trace("// '0x10' == '16'");
a = "0x10" == "16";
trace(a);
trace("");
trace("// '010' == '8'");
a = "010" == "8";
trace(a);
trace("");
trace("// 'true' == '0x1'");
a = "true" == "0x1";
trace(a);
trace("");
trace("// undefined == 0");
a = undefined == 0;
trace(a);
trace("");
trace("// null == 0");
a = null == 0;
trace(a);
trace("");
trace("// 'Infinity' == Infinity");
a = "Infinity" == Infinity;
trace(a);
trace("");
trace("// n = NaN;\n// n == NaN");
n = NaN;
a = n == NaN;
trace(a);
trace("");
trace("// n == n");
a = n == n;
trace(a);
trace("");
trace("// obj_1 == obj_2");
a = obj_1 == obj_2;
trace(a);

View File

@ -0,0 +1,32 @@
// '100' == '100ABC'
false
// '0x10' == '16'
false
// '010' == '8'
false
// 'true' == '0x1'
false
// undefined == 0
true
// null == 0
true
// 'Infinity' == Infinity
false
// n = NaN;
// n == NaN
false
// n == n
false
// obj_1 == obj_2
OBJ_2
OBJ_1
true

Binary file not shown.

View File

@ -0,0 +1,28 @@
// GetProperty: -0.8
number
0
// GetProperty: -1
undefined
undefined
// GetProperty: '013'
string
/
// GetProperty: '0x13'
string
HIGH
// GetProperty: '11ABC'
undefined
undefined
// GetProperty: 'ABC'
undefined
undefined
// GetProperty: obj
OBJ
string
/

Binary file not shown.

View File

@ -0,0 +1,28 @@
// GetProperty: -0.8
number
0
// GetProperty: -1
undefined
undefined
// GetProperty: '013'
string
// GetProperty: '0x13'
number
0
// GetProperty: '11ABC'
string
/
// GetProperty: 'ABC'
number
0
// GetProperty: obj
OBJ
string
/

Binary file not shown.

View File

@ -0,0 +1,28 @@
// GetProperty: -0.8
number
0
// GetProperty: -1
undefined
undefined
// GetProperty: '013'
string
// GetProperty: '0x13'
undefined
undefined
// GetProperty: '11ABC'
undefined
undefined
// GetProperty: 'ABC'
undefined
undefined
// GetProperty: obj
OBJ
string
/

Binary file not shown.

View File

@ -0,0 +1,75 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "2";
}};
trace("// '100' < '100ABC'");
a = "100" < "100ABC";
trace(a);
trace("");
trace("// '100' < '101ABC'");
a = "100" < "101ABC";
trace(a);
trace("");
trace("// '0x10' < '16'");
a = "0x10" < "16";
trace(a);
trace("");
trace("// '010' < '10'");
a = "010" < "10";
trace(a);
trace("");
trace("// 'true' < '0x1'");
a = "true" < "0x1";
trace(a);
trace("");
trace("// 'true' < '0x2'");
a = "true" < "0x2";
trace(a);
trace("");
trace("// undefined < '0'");
a = undefined < "0";
trace(a);
trace("");
trace("// undefined < 1");
a = undefined < "1";
trace(a);
trace("");
trace("// null < '0'");
a = null < "0";
trace(a);
trace("");
trace("// null < '1'");
a = null < "1";
trace(a);
trace("");
trace("// n = NaN;\n// n < NaN");
n = NaN;
a = n < NaN;
trace(a);
trace("");
trace("// n < n");
a = n < n;
trace(a);
trace("");
trace("// obj_1 < obj_2");
a = obj_1 < obj_2;
trace(a);

View File

@ -0,0 +1,41 @@
// '100' < '100ABC'
false
// '100' < '101ABC'
false
// '0x10' < '16'
false
// '010' < '10'
true
// 'true' < '0x1'
false
// 'true' < '0x2'
false
// undefined < '0'
false
// undefined < 1
false
// null < '0'
false
// null < '1'
false
// n = NaN;
// n < NaN
false
// n < n
false
// obj_1 < obj_2
OBJ_1
OBJ_2
true

Binary file not shown.

View File

@ -0,0 +1,75 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "2";
}};
trace("// '100' < '100ABC'");
a = "100" < "100ABC";
trace(a);
trace("");
trace("// '100' < '101ABC'");
a = "100" < "101ABC";
trace(a);
trace("");
trace("// '0x10' < '16'");
a = "0x10" < "16";
trace(a);
trace("");
trace("// '010' < '10'");
a = "010" < "10";
trace(a);
trace("");
trace("// 'true' < '0x1'");
a = "true" < "0x1";
trace(a);
trace("");
trace("// 'true' < '0x2'");
a = "true" < "0x2";
trace(a);
trace("");
trace("// undefined < '0'");
a = undefined < "0";
trace(a);
trace("");
trace("// undefined < 1");
a = undefined < "1";
trace(a);
trace("");
trace("// null < '0'");
a = null < "0";
trace(a);
trace("");
trace("// null < '1'");
a = null < "1";
trace(a);
trace("");
trace("// n = NaN;\n// n < NaN");
n = NaN;
a = n < NaN;
trace(a);
trace("");
trace("// n < n");
a = n < n;
trace(a);
trace("");
trace("// obj_1 < obj_2");
a = obj_1 < obj_2;
trace(a);

View File

@ -0,0 +1,41 @@
// '100' < '100ABC'
0
// '100' < '101ABC'
1
// '0x10' < '16'
1
// '010' < '10'
0
// 'true' < '0x1'
0
// 'true' < '0x2'
0
// undefined < '0'
0
// undefined < 1
1
// null < '0'
0
// null < '1'
1
// n = NaN;
// n < NaN
0
// n < n
0
// obj_1 < obj_2
OBJ_1
OBJ_2
1

Binary file not shown.

View File

@ -0,0 +1,75 @@
// SWF hand-edited with JPEXS.
obj_1 = { valueOf:function() {
trace("OBJ_1");
return 1;
}};
obj_2 = { valueOf:function() {
trace("OBJ_2");
return "2";
}};
trace("// '100' < '100ABC'");
a = "100" < "100ABC";
trace(a);
trace("");
trace("// '100' < '101ABC'");
a = "100" < "101ABC";
trace(a);
trace("");
trace("// '0x10' < '16'");
a = "0x10" < "16";
trace(a);
trace("");
trace("// '010' < '10'");
a = "010" < "10";
trace(a);
trace("");
trace("// 'true' < '0x1'");
a = "true" < "0x1";
trace(a);
trace("");
trace("// 'true' < '0x2'");
a = "true" < "0x2";
trace(a);
trace("");
trace("// undefined < '0'");
a = undefined < "0";
trace(a);
trace("");
trace("// undefined < 1");
a = undefined < "1";
trace(a);
trace("");
trace("// null < '0'");
a = null < "0";
trace(a);
trace("");
trace("// null < '1'");
a = null < "1";
trace(a);
trace("");
trace("// n = NaN;\n// n < NaN");
n = NaN;
a = n < NaN;
trace(a);
trace("");
trace("// n < n");
a = n < n;
trace(a);
trace("");
trace("// obj_1 < obj_2");
a = obj_1 < obj_2;
trace(a);

View File

@ -0,0 +1,41 @@
// '100' < '100ABC'
false
// '100' < '101ABC'
false
// '0x10' < '16'
false
// '010' < '10'
false
// 'true' < '0x1'
false
// 'true' < '0x2'
false
// undefined < '0'
false
// undefined < 1
true
// null < '0'
false
// null < '1'
true
// n = NaN;
// n < NaN
false
// n < n
false
// obj_1 < obj_2
OBJ_1
OBJ_2
true

Binary file not shown.