Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-mtasc.all / Dejagnu.as
blob1166bf226d5fcd044c1a7515c4a2fd9c0f68a36d
1 // Dejagnu.as - MTASC class for dejagnu-like testing.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
4 // Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 // Original author: David Rorex - drorex@gmail.com
25 class Dejagnu {
26 static var passed = 0;
27 static var failed = 0;
28 static var xpassed = 0;
29 static var xfailed = 0;
30 static var untest = 0;
31 static var unresolve = 0;
33 // This is a trick to force our 'init' function
34 // to be automatically called at the start of the movie.
35 static var inithack = init();
37 static function init() {
38 if(_level0.dejagnu_module_initialized == 1) return;
40 // create a textfield to output to
41 _level0.createTextField("textout", 99, 10, 10, 500, 500);
42 _level0.dejagnu_module_initialized = 1;
45 static function fail (why) {
46 failed++;
47 var msg = 'FAILED: '+why;
48 xtrace(msg);
51 static function xfail(why) {
52 xfailed++;
53 var msg = 'XFAILED: '+why;
54 xtrace(msg);
57 static function pass(why) {
58 passed++;
59 var msg = 'PASSED: '+why;
60 trace (msg);
63 static function xpass(why) {
64 xpassed++;
65 var msg = 'XPASSED: '+why;
66 trace (msg);
69 static function testcount() {
70 var c = 0;
71 if ( passed ) c += passed;
72 if ( failed ) c += failed;
73 if ( xpassed ) c += xpassed;
74 if ( xfailed ) c += xfailed;
75 return c;
78 static function printtotals() {
79 xtrace('#passed: '+ passed);
80 xtrace('#failed: '+ failed);
81 if ( xpassed ) {
82 xtrace('#unexpected successes: '+ xpassed);
84 if ( xfailed ) {
85 xtrace('#expected failures: '+ xfailed);
87 xtrace('#total tests run: '+ testcount());
90 static function totals(exp, msg) {
91 var obt = testcount();
92 if ( exp != undefined && obt != exp ) {
93 fail('Test run '+obt+' (expected '+exp+') ['+msg+']');
94 } else {
95 pass('Test run '+obt+' ['+msg+']');
99 static function xtotals(exp, msg) {
100 var obt = testcount();
101 if ( exp != undefined && obt != exp ) {
102 xfail('Test run '+obt+' (expected '+exp+') ['+msg+']');
103 } else {
104 xpass('Test run '+obt+' ['+msg+']');
108 static function check_equals(obt, exp, msg) {
109 if(msg == null) msg = "";
110 if ( obt == exp )
111 pass(obt+' == '+exp+' '+msg);
112 else
113 fail('expected: "'+exp+'" , obtained: "'+obt+'" '+msg);
116 static function xcheck_equals(obt, exp, msg) {
117 if(msg == null) msg = "";
118 if ( obt == exp )
119 xpass(obt+' == '+exp+' '+msg);
120 else
121 xfail('expected: '+exp+' , obtained: '+obt+" "+msg);
124 static function check(a, msg) {
125 if ( a )
126 pass(msg != undefined ? msg : a);
127 else
128 fail(msg != undefined ? msg : a);
131 static function xcheck(a, msg) {
132 if ( a )
133 xpass(msg != undefined ? msg : a);
134 else
135 xfail(msg != undefined ? msg : a);
138 static function note(msg) {
139 xtrace(msg);
142 static function xtrace(msg) {
143 _level0.textout.text += msg + "\n";
144 trace(msg);
147 static function untested(msg) {
148 trace("UNTESTED: "+msg);
151 static function unresolved(msg) {
152 trace("UNRESOLVED: "+msg);
155 static function done() {
156 printtotals();
157 trace("__END_OF_TEST__");
158 loadMovie('fscommand:quit', _root);