Some more tests (minor)
[gnash.git] / testsuite / misc-swfc.all / Dejagnu.sc
blobd377f067910ee306a1b4610549f182209af293b6
1         // Dejagnu.sc - SWFC script 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.
10         //
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.
15         //
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
19         //
20         //
21         // Original author: David Rorex - drorex@gmail.com
22         //
23         //
25         _root.Dejagnu = _global.Dejagnu = {
26             passed:0,
27             failed:0,
28             xpassed:0,
29             xfailed:0,
30             untest:0,
31             unresolve:0,
33             fail : function (why) {
34                 this.failed++;
35                 var msg = 'FAILED: '+why;
36                 this.xtrace(msg);
37             },
39             xfail: function (why) {
40                 this.xfailed++;
41                 var msg = 'XFAILED: '+why;
42                 this.xtrace(msg);
43             },
45             pass: function (why) {
46                 this.passed++;
47                 var msg = 'PASSED: '+why;
48                 trace (msg);
49             },
51             xpass: function (why) {
52                 this.xpassed++;
53                 var msg = 'XPASSED: '+why;
54                 trace (msg);
55             },
57             totals: function (expectedTestsRun, msg) {
58                 if ( arguments.length > 1 )
59                 {
60                         ttr = 0;
61                         if ( this.passed ) ttr += this.passed;
62                         if ( this.failed ) ttr += this.failed;
63                         if ( this.xpassed ) ttr += this.xpassed;
64                         if ( this.xfailed ) ttr += this.xfailed;
65                         if ( this.untest ) ttr += this.untest;
66                         if ( this.unresolv ) ttr += this.unresolv;
67                         this.note("Total tests run: "+ttr+" typeof expected: "+typeof(expectedTestsRun));
69                         if ( expectedTestsRun != ttr )
70                         {
71                                 this.fail("TOTAL tests run: "+ttr+", expected: "+expectedTestsRun+" ["+msg+"]");
72                         }
73                 }
74                 this.xtrace('#passed: '+ this.passed);
75                 this.xtrace('#failed: '+ this.failed);
76                 if ( this.xpassed ) {
77                     this.xtrace('#unexpected successes: '+ this.xpassed);
78                 }
79                 if ( this.xfailed ) {
80                     this.xtrace('#expected failures: '+ this.xfailed);
81                 }
82            
83                 this.done();
84             },
86             xtotals: function (expectedTestsRun, msg) {
87                 if ( arguments.length > 1 )
88                 {
89                         ttr = 0;
90                         if ( this.passed ) ttr += this.passed;
91                         if ( this.failed ) ttr += this.failed;
92                         if ( this.xpassed ) ttr += this.xpassed;
93                         if ( this.xfailed ) ttr += this.xfailed;
94                         if ( this.untest ) ttr += this.untest;
95                         if ( this.unresolv ) ttr += this.unresolv;
96                         this.note("Total tests run: "+ttr+" typeof expected: "+typeof(expectedTestsRun));
98                         if ( expectedTestsRun != ttr )
99                         {
100                                 this.xfail("TOTAL tests run: "+ttr+", expected: "+expectedTestsRun+" ["+msg+"]");
101                         }
102                         else
103                         {
104                                 this.xpass("TOTAL tests run: "+ttr+" ["+msg+"]");
105                         }
106                 }
107                 this.xtrace('#passed: '+ this.passed);
108                 this.xtrace('#failed: '+ this.failed);
109                 if ( this.xpassed ) {
110                     this.xtrace('#unexpected successes: '+ this.xpassed);
111                 }
112                 if ( this.xfailed ) {
113                     this.xtrace('#expected failures: '+ this.xfailed);
114                 }
115            
116                 this.done();
117             },
119             check_equals: function (obt, exp, msg, expression) {
120                 if(msg == null) msg = "";
121                 if ( obt == exp ) 
122                     this.pass(expression+' == '+exp+" "+msg);
123                 else 
124                     this.fail(expression+': expected: "'+exp+'" , obtained: "'+obt+'" '+msg);
125             },
127             xcheck_equals: function (obt, exp, msg, expression) {
128                 if(msg == null) msg = "";
129                 if ( obt == exp ) 
130                     this.xpass(expression+' == '+exp+" "+msg);
131                 else 
132                     this.xfail(expression+': expected: '+exp+' , obtained: '+obt+" "+msg);
133             },
135             check: function (a, msg) {
136                 if ( a ) 
137                     this.pass(msg != undefined ? msg : a);
138                 else 
139                     this.fail(msg != undefined ? msg : a);
140             },
142             xcheck: function (a, msg) {
143                 if ( a ) 
144                     this.xpass(msg != undefined ? msg : a);
145                 else 
146                     this.xfail(msg != undefined ? msg : a);
147             },
149             note: function (msg) {
150                 this.xtrace(msg);
151             },
153             xtrace: function (msg) {
154                 _level0.textout._height += 20;
155                 _level0.textout.text += msg + "\n";
156                 trace(msg);
157             },
159             untested: function (msg) {
160                 trace("UNTESTED: "+msg);
161             },
163             unresolved: function (msg) {
164                 trace("UNRESOLVED: "+msg);
165             },
167             done: function () {
168                 _root.stop();
169                 trace("__END_OF_TEST__");
170                 loadMovie("fscommand:quit", _level0);
171             }
173         };
175         if(_level0.dejagnu_module_initialized != 1) {
176             // create a textfield to output to
177             _level0.createTextField("textout", 99, 10, 10, 600, 0);
178             _level0.textout.autoSize = true;
179             _level0.dejagnu_module_initialized = 1;
180         }
182 // helper functions
183 #include "check.sc"