1 // Dejagnu.sc - SWFC script for dejagnu-like testing.
3 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
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 _root.Dejagnu = _global.Dejagnu = {
33 fail : function (why) {
35 var msg = 'FAILED: '+why;
39 xfail: function (why) {
41 var msg = 'XFAILED: '+why;
45 pass: function (why) {
47 var msg = 'PASSED: '+why;
51 xpass: function (why) {
53 var msg = 'XPASSED: '+why;
57 totals: function (expectedTestsRun, msg) {
58 if ( arguments.length > 1 )
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 )
71 this.fail("TOTAL tests run: "+ttr+", expected: "+expectedTestsRun+" ["+msg+"]");
74 this.xtrace('#passed: '+ this.passed);
75 this.xtrace('#failed: '+ this.failed);
77 this.xtrace('#unexpected successes: '+ this.xpassed);
80 this.xtrace('#expected failures: '+ this.xfailed);
86 xtotals: function (expectedTestsRun, msg) {
87 if ( arguments.length > 1 )
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 )
100 this.xfail("TOTAL tests run: "+ttr+", expected: "+expectedTestsRun+" ["+msg+"]");
104 this.xpass("TOTAL tests run: "+ttr+" ["+msg+"]");
107 this.xtrace('#passed: '+ this.passed);
108 this.xtrace('#failed: '+ this.failed);
109 if ( this.xpassed ) {
110 this.xtrace('#unexpected successes: '+ this.xpassed);
112 if ( this.xfailed ) {
113 this.xtrace('#expected failures: '+ this.xfailed);
119 check_equals: function (obt, exp, msg, expression) {
120 if(msg == null) msg = "";
122 this.pass(expression+' == '+exp+" "+msg);
124 this.fail(expression+': expected: "'+exp+'" , obtained: "'+obt+'" '+msg);
127 xcheck_equals: function (obt, exp, msg, expression) {
128 if(msg == null) msg = "";
130 this.xpass(expression+' == '+exp+" "+msg);
132 this.xfail(expression+': expected: '+exp+' , obtained: '+obt+" "+msg);
135 check: function (a, msg) {
137 this.pass(msg != undefined ? msg : a);
139 this.fail(msg != undefined ? msg : a);
142 xcheck: function (a, msg) {
144 this.xpass(msg != undefined ? msg : a);
146 this.xfail(msg != undefined ? msg : a);
149 note: function (msg) {
153 xtrace: function (msg) {
154 _level0.textout._height += 20;
155 _level0.textout.text += msg + "\n";
159 untested: function (msg) {
160 trace("UNTESTED: "+msg);
163 unresolved: function (msg) {
164 trace("UNRESOLVED: "+msg);
169 trace("__END_OF_TEST__");
170 loadMovie("fscommand:quit", _level0);
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;