Split long lines
[gnash.git] / testsuite / as3compile.all / dejagnu.as
blob1cf1d9eb532bc188d3865cd51d0720c3bc219d0e
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
20 package dejagnu {
22 import flash.text.*;
24 public class Dejagnu {
26 private static var passed = 0;
27 private static var failed = 0;
28 private static var xpassed = 0;
29 private static var xfailed = 0;
30 private static var untest = 0;
31 private static var unresolve = 0;
32 private static var tf:TextField = new TextField();
34 public static function fail (why) {
35 failed++;
36 var msg = 'FAILED: '+why;
37 xtrace(msg);
40 public static function xfail(why) {
41 xfailed++;
42 var msg = 'XFAILED: '+why;
43 xtrace(msg);
46 public static function pass(why) {
47 passed++;
48 var msg = 'PASSED: '+why;
49 trace (msg);
52 public static function xpass(why) {
53 xpassed++;
54 var msg = 'XPASSED: '+why;
55 trace (msg);
58 public static function totals(exp, msg) {
59 var obt = testcount();
60 if ( exp != undefined && obt != exp ) {
61 fail('Test run '+obt+' (expected '+exp+') ['+msg+']');
62 } else {
63 pass('Test run '+obt+' ['+msg+']');
67 public static function xtotals(exp, msg) {
68 var obt = testcount();
69 if ( exp != undefined && obt != exp ) {
70 xfail('Test run '+obt+' (expected '+exp+') ['+msg+']');
71 } else {
72 xpass('Test run '+obt+' ['+msg+']');
76 public static function check_equals(obt, exp, msg, expression) {
77 if (msg == null) msg = "";
78 if (obt == exp) {
79 pass(expression + ' == ' + exp + ' ' + msg);
81 else {
82 fail(expression + ': expected: "' + exp +
83 '" , obtained: "' + obt + '" ' + msg);
87 public static function xcheck_equals(obt, exp, msg, expression) {
88 if (msg == null) msg = "";
89 if (obt == exp) {
90 xpass(expression + ' == ' + exp + ' ' + msg);
92 else {
93 xfail(expression + ': expected: "' + exp +
94 '" , obtained: "' + obt + '" ' + msg);
98 public static function check(a, msg) {
99 if (a) {
100 pass(msg != undefined ? msg : a);
102 else {
103 fail(msg != undefined ? msg : a);
107 public static function xcheck(a, msg) {
108 if (a) {
109 xpass(msg != undefined ? msg : a);
111 else {
112 xfail(msg != undefined ? msg : a);
116 public static function note(msg) {
117 xtrace(msg);
120 public static function untested(msg) {
121 trace("UNTESTED: "+msg);
124 public static function unresolved(msg) {
125 trace("UNRESOLVED: "+msg);
128 /// Private functions.
130 private static function xtrace(msg) {
131 //tf.text += msg + "\n";
132 trace(msg);
135 private static function done() {
136 printtotals();
137 trace("__END_OF_TEST__");
140 private static function testcount() {
141 var c = 0;
142 if ( passed ) c += passed;
143 if ( failed ) c += failed;
144 if ( xpassed ) c += xpassed;
145 if ( xfailed ) c += xfailed;
146 return c;
149 private static function printtotals() {
150 xtrace('#passed: '+ passed);
151 xtrace('#failed: '+ failed);
152 if ( xpassed ) {
153 xtrace('#unexpected successes: '+ xpassed);
155 if ( xfailed ) {
156 xtrace('#expected failures: '+ xfailed);
158 xtrace('#total tests run: '+ testcount());