distil 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.3
1
+ 0.10.4
data/distil.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{distil}
8
- s.version = "0.10.3"
8
+ s.version = "0.10.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Watkins"]
12
- s.date = %q{2010-04-25}
12
+ s.date = %q{2010-05-05}
13
13
  s.default_executable = %q{distil}
14
14
  s.description = %q{A build tool for Javascript and CSS that takes advantage of best-of-breed helper applications Javascript Lint and JSDoc Toolkit}
15
15
  s.executables = ["distil"]
@@ -45,7 +45,6 @@ Gem::Specification.new do |s|
45
45
  "lib/tasks/test-task.rb",
46
46
  "lib/test/HtmlTestReporter.js",
47
47
  "lib/test/Test.js",
48
- "lib/test/TestHelper.js",
49
48
  "lib/test/TestReporter.js",
50
49
  "lib/test/TestRunner.js",
51
50
  "lib/test/browser.rb",
@@ -211,6 +210,7 @@ Gem::Specification.new do |s|
211
210
  "vendor/jsl-0.3.0/src/config/IRIX6.5.mk",
212
211
  "vendor/jsl-0.3.0/src/config/Linux_All.mk",
213
212
  "vendor/jsl-0.3.0/src/config/Mac_OS10.0.mk",
213
+ "vendor/jsl-0.3.0/src/config/MinGW5.1.mk",
214
214
  "vendor/jsl-0.3.0/src/config/OSF1V4.0.mk",
215
215
  "vendor/jsl-0.3.0/src/config/OSF1V5.0.mk",
216
216
  "vendor/jsl-0.3.0/src/config/SunOS4.1.4.mk",
@@ -226,6 +226,7 @@ Gem::Specification.new do |s|
226
226
  "vendor/jsl-0.3.0/src/config/WINNT5.0.mk",
227
227
  "vendor/jsl-0.3.0/src/config/WINNT5.1.mk",
228
228
  "vendor/jsl-0.3.0/src/config/WINNT5.2.mk",
229
+ "vendor/jsl-0.3.0/src/config/WINNT6.0.mk",
229
230
  "vendor/jsl-0.3.0/src/config/dgux.mk",
230
231
  "vendor/jsl-0.3.0/src/editline/Makefile.ref",
231
232
  "vendor/jsl-0.3.0/src/editline/README",
data/lib/test/Test.js CHANGED
@@ -1,3 +1,230 @@
1
+ function TestHelper(scope, report, test, testName)
2
+ {
3
+ this.scope= scope;
4
+ this.report= report;
5
+ this.test= test;
6
+ this.testName= testName;
7
+ this._async= false;
8
+ }
9
+ TestHelper.prototype= {
10
+
11
+ __ASYNC_MARKER__: 'async_marker',
12
+
13
+ stringFromValue: function(v)
14
+ {
15
+ return String(v);
16
+ },
17
+
18
+ compareArrays: function(a1, a2)
19
+ {
20
+ if (a1.length==a2.length)
21
+ {
22
+ var len=a1.length;
23
+ var i;
24
+
25
+ for (i=0; i<len; ++i)
26
+ if (a1[i]!==a2[i])
27
+ return false;
28
+ return true;
29
+ }
30
+
31
+ return false;
32
+ },
33
+
34
+ log: function()
35
+ {
36
+ this.report.log.apply(this.report, arguments);
37
+ },
38
+
39
+ passed: function()
40
+ {
41
+ if (this._finished)
42
+ return;
43
+
44
+ this.report.passed(this.test, this.testName);
45
+ this.finishAsync();
46
+ },
47
+
48
+ clearTimer: function()
49
+ {
50
+ if (!this._timer)
51
+ return;
52
+ window.clearTimeout(this._timer);
53
+ this._timer= 0;
54
+ },
55
+
56
+ finishAsync: function()
57
+ {
58
+ if (!this._async || this._finished)
59
+ return;
60
+
61
+ this._finished= true;
62
+ this.clearTimer();
63
+ try
64
+ {
65
+ if (this.teardown)
66
+ this.teardown.call(this.scope);
67
+ }
68
+ catch (e)
69
+ {
70
+ this.report.exceptionInTeardown(this.test, this.testName, e);
71
+ }
72
+
73
+ this.report.endTest(this.test, this.testName);
74
+ if (this.ontestcomplete)
75
+ this.ontestcomplete();
76
+ },
77
+
78
+ /** Create an asynchronous handler for this method. If the test
79
+ * doesn't complete before the timeout expires, then the test
80
+ * fails.
81
+ */
82
+ async: function(timeout)
83
+ {
84
+ var helper= this;
85
+
86
+ function timeoutFn()
87
+ {
88
+ helper.report.timeoutExpired(helper.test, helper.testName, timeout);
89
+ helper.finishAsync();
90
+ }
91
+
92
+ this._timer= window.setTimeout(timeoutFn, timeout);
93
+ this._async= true;
94
+ return this.__ASYNC_MARKER__;
95
+ },
96
+
97
+ assert: function(value, msg)
98
+ {
99
+ this.assertTrue(value, msg);
100
+ },
101
+
102
+ assertEqual: function(value, expected, msg)
103
+ {
104
+ if ('object'===typeof(value) && 'object'===typeof(expected) &&
105
+ value.splice && expected.splice)
106
+ {
107
+ if (this.compareArrays(value, expected))
108
+ return;
109
+ }
110
+ else if (value===expected)
111
+ return;
112
+
113
+ this.fail(msg||(this.stringFromValue(value) + '===' +
114
+ this.stringFromValue(expected)));
115
+ },
116
+
117
+ assertNotEqual: function(value, expected, msg)
118
+ {
119
+ if (value!==expected)
120
+ return;
121
+ this.fail(msg||(this.stringFromValue(value) + '!==' +
122
+ this.stringFromValue(expected)));
123
+ },
124
+
125
+ assertTrue: function(value, msg)
126
+ {
127
+ if (true===value)
128
+ return;
129
+ this.fail(msg||(this.stringFromValue(value) + ' is not true'));
130
+ },
131
+
132
+ assertFalse: function(value, msg)
133
+ {
134
+ if (false===value)
135
+ return;
136
+ this.fail(msg||(this.stringFromValue(value) + ' is not false'));
137
+ },
138
+
139
+ assertNull: function(value, msg)
140
+ {
141
+ if (null===value)
142
+ return;
143
+ this.fail(msg||(this.stringFromValue(value) + ' is not null'));
144
+ },
145
+
146
+ assertNotNull: function(value, msg)
147
+ {
148
+ if (null!==value)
149
+ return;
150
+ this.fail(msg||(this.stringFromValue(value) + ' is null'));
151
+ },
152
+
153
+ assertUndefined: function(value, msg)
154
+ {
155
+ if ('undefined'===typeof(value))
156
+ return;
157
+ this.fail(msg||(this.stringFromValue(value) + ' is not undefined'));
158
+ },
159
+
160
+ assertNotUndefined: function(value, msg)
161
+ {
162
+ if ('undefined'!==typeof(value))
163
+ return;
164
+ this.fail(msg||(this.stringFromValue(value) + ' is undefined'));
165
+ },
166
+
167
+ assertMatch: function(regex, value, msg)
168
+ {
169
+ if (regex.exec(value))
170
+ return;
171
+ this.fail(msg||(this.stringFromValue(value) + ' did not match /' + regex.source + '/'));
172
+ },
173
+
174
+ assertNotMatch: function(regex, value, msg)
175
+ {
176
+ if (!regex.exec(value))
177
+ return;
178
+ this.fail(msg||(this.stringFromValue(value) + ' matched /' + regex.source + '/'));
179
+ },
180
+
181
+ assertInstanceOf: function(value, klass, msg)
182
+ {
183
+ if (value instanceof klass)
184
+ return;
185
+ this.fail(msg||(this.stringFromValue(value) + ' is not an instance'));
186
+ },
187
+
188
+ assertNotInstanceOf: function(value, klass, msg)
189
+ {
190
+ if (!(value instanceof klass))
191
+ return;
192
+ this.fail(msg||(this.stringFromValue(value) + ' is an instance'));
193
+ },
194
+
195
+ fail: function(msg)
196
+ {
197
+ if (this._finished)
198
+ return;
199
+
200
+ msg= msg||'failed';
201
+ this.report.failed(this.test, this.testName, msg);
202
+
203
+ this.finishAsync();
204
+
205
+ var error= new Error(msg);
206
+ error.name= 'AssertionError';
207
+ throw error;
208
+ },
209
+
210
+ skip: function(why)
211
+ {
212
+ if (this._finished)
213
+ return;
214
+
215
+ why= why||'Test skipped';
216
+ this.report.skipped(this.test, this.testName, why);
217
+
218
+ this.finishAsync();
219
+
220
+ var error= new Error(why);
221
+ error.name= 'AssertionError';
222
+ throw error;
223
+ }
224
+
225
+ };
226
+
227
+
1
228
  var Test= {
2
229
 
3
230
  /** Register a group of tests. This might do some clever processing of
@@ -14,14 +241,6 @@ var Test= {
14
241
  this._tests={};
15
242
  this.numberOfRegisteredTests= 0;
16
243
  },
17
-
18
- pending: function(arg)
19
- {
20
- },
21
-
22
- spec: function(name, decl)
23
- {
24
- },
25
244
 
26
245
  numberOfRegisteredTests: 0,
27
246
  _tests: {}
@@ -2,7 +2,6 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>@title@</title>
5
- <script src="/lib/test/TestHelper.js" type="text/javascript" charset="utf-8"></script>
6
5
  <script src="/lib/test/Test.js" type="text/javascript" charset="utf-8"></script>
7
6
  @scripts@
8
7
  </head>
@@ -2,7 +2,6 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Unit Tests</title>
5
- <script src="/lib/test/TestHelper.js" type="text/javascript" charset="utf-8"></script>
6
5
  <script src="/lib/test/Test.js" type="text/javascript" charset="utf-8"></script>
7
6
  <script src="/lib/test/HtmlTestReporter.js" type="text/javascript" charset="utf-8"></script>
8
7
  <script src="/lib/test/TestRunner.js" type="text/javascript" charset="utf-8"></script>
@@ -333,7 +333,7 @@ endif
333
333
  # against fdlibm to pull in only what is needed
334
334
  $(OBJDIR)/jsmath.o: jsmath.c jsmath.h jslibmath.h $(FDLIBM_LIBRARY)
335
335
  ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
336
- $(CC) -Fo$(JSMATH_PRELINK) -c $(CFLAGS) $<
336
+ $(CC) -Fo$(JSMATH_PRELINK) -c $(CFLAGS) $<
337
337
  else
338
338
  $(CC) -o $(JSMATH_PRELINK) -c $(CFLAGS) $<
339
339
  endif
@@ -0,0 +1,98 @@
1
+ # -*- Mode: makefile -*-
2
+ #
3
+ # Hacked together by Adam Rogers [adam (at) jargon (dot) ca] from
4
+ # Linux_All.mk and WINNT5.1.mk to enable building using GNU tools
5
+ # under MinGW on a Win32 platform. [September 6 2008]
6
+ #
7
+
8
+
9
+ #
10
+ # Config for all versions of Linux
11
+ #
12
+
13
+ CC = gcc
14
+ CCC = g++
15
+ LD = g++
16
+ CFLAGS += -Wall -Wno-format
17
+
18
+ OS_CFLAGS = -D_X86_=1 -DXP_WIN -DXP_WIN32 -DWIN32 -D_WINDOWS -D_WIN32 -DWINVER=0x500 -D_WIN32_WINNT=0x500 -D_MINGW -DEXPORT_JS_API
19
+
20
+ ifdef BUILD_IDG
21
+ OS_CFLAGS += -DBUILD_IDG
22
+ endif
23
+
24
+ ifdef BUILD_OPT
25
+ OS_CFLAGS += -s
26
+ endif
27
+
28
+ JSDLL_CFLAGS = -DEXPORT_JS_API
29
+ PREBUILT_CPUCFG = 1
30
+
31
+ LIB_LINK_FLAGS= --add-stdcall-alias -L./fdlibm/$(OBJDIR) -lfdm
32
+ EXE_LINK_FLAGS=
33
+
34
+ # LIB_LINK_FLAGS=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lwinmm
35
+ # EXE_LINK_FLAGS=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid
36
+
37
+ DEFFILE=$(OBJDIR)/libjs.def
38
+ STATICLIB=$(OBJDIR)/libjs_implib.a
39
+ XMKSHLIBOPTS += -Wl,--output-def=$(DEFFILE) -Wl,--out-implib=$(STATICLIB)
40
+
41
+
42
+ RANLIB = ranlib
43
+ MKSHLIB = $(LD) -shared $(XMKSHLIBOPTS)
44
+
45
+ #.c.o:
46
+ # $(CC) -c -MD $*.d $(CFLAGS) $<
47
+
48
+ CPU_ARCH = $(shell uname -m)
49
+ # don't filter in x86-64 architecture
50
+ ifneq (x86_64,$(CPU_ARCH))
51
+ ifeq (86,$(findstring 86,$(CPU_ARCH)))
52
+ CPU_ARCH = x86
53
+ # OS_CFLAGS+= -DX86_WINDOWS
54
+
55
+ ifeq (gcc, $(CC))
56
+ # if using gcc on x86, check version for opt bug
57
+ # (http://bugzilla.mozilla.org/show_bug.cgi?id=24892)
58
+ GCC_VERSION := $(shell gcc -v 2>&1 | grep version | awk '{ print $$3 }')
59
+ GCC_LIST:=$(sort 2.91.66 $(GCC_VERSION) )
60
+
61
+ ifeq (2.91.66, $(firstword $(GCC_LIST)))
62
+ CFLAGS+= -DGCC_OPT_BUG
63
+ endif
64
+ endif
65
+ endif
66
+ endif
67
+
68
+ GFX_ARCH = win32
69
+
70
+ OS_LIBS = -lm -lc
71
+
72
+ ASFLAGS += -x assembler-with-cpp
73
+
74
+
75
+ ifeq ($(CPU_ARCH),alpha)
76
+
77
+ # Ask the C compiler on alpha linux to let us work with denormalized
78
+ # double values, which are required by the ECMA spec.
79
+
80
+ OS_CFLAGS += -mieee
81
+ endif
82
+
83
+ # Use the editline library to provide line-editing support.
84
+ ifdef JS_EDITLINE
85
+ JS_EDITLINE = 1
86
+ endif
87
+
88
+ ifeq ($(CPU_ARCH),x86_64)
89
+ # Use VA_COPY() standard macro on x86-64
90
+ # FIXME: better use it everywhere
91
+ OS_CFLAGS += -DHAVE_VA_COPY -DVA_COPY=va_copy
92
+ endif
93
+
94
+ ifeq ($(CPU_ARCH),x86_64)
95
+ # We need PIC code for shared libraries
96
+ # FIXME: better patch rules.mk & fdlibm/Makefile*
97
+ OS_CFLAGS += -DPIC -fPIC
98
+ endif
@@ -0,0 +1,117 @@
1
+ # -*- Mode: makefile -*-
2
+ #
3
+ # ***** BEGIN LICENSE BLOCK *****
4
+ # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
+ #
6
+ # The contents of this file are subject to the Mozilla Public License Version
7
+ # 1.1 (the "License"); you may not use this file except in compliance with
8
+ # the License. You may obtain a copy of the License at
9
+ # http://www.mozilla.org/MPL/
10
+ #
11
+ # Software distributed under the License is distributed on an "AS IS" basis,
12
+ # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
+ # for the specific language governing rights and limitations under the
14
+ # License.
15
+ #
16
+ # The Original Code is Mozilla Communicator client code, released
17
+ # March 31, 1998.
18
+ #
19
+ # The Initial Developer of the Original Code is
20
+ # Netscape Communications Corporation.
21
+ # Portions created by the Initial Developer are Copyright (C) 1998
22
+ # the Initial Developer. All Rights Reserved.
23
+ #
24
+ # Contributor(s):
25
+ #
26
+ # Alternatively, the contents of this file may be used under the terms of
27
+ # either the GNU General Public License Version 2 or later (the "GPL"), or
28
+ # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
+ # in which case the provisions of the GPL or the LGPL are applicable instead
30
+ # of those above. If you wish to allow use of your version of this file only
31
+ # under the terms of either the GPL or the LGPL, and not to allow others to
32
+ # use your version of this file under the terms of the MPL, indicate your
33
+ # decision by deleting the provisions above and replace them with the notice
34
+ # and other provisions required by the GPL or the LGPL. If you do not delete
35
+ # the provisions above, a recipient may use your version of this file under
36
+ # the terms of any one of the MPL, the GPL or the LGPL.
37
+ #
38
+ # ***** END LICENSE BLOCK *****
39
+
40
+ #
41
+ # Config for Windows NT using MS Visual C++ (version?)
42
+ #
43
+
44
+ CC = cl
45
+
46
+ RANLIB = echo
47
+
48
+ PDBFILE = $(basename $(@F)).pdb
49
+
50
+ #.c.o:
51
+ # $(CC) -c -MD $*.d $(CFLAGS) $<
52
+
53
+ CPU_ARCH = x86 # XXX fixme
54
+ GFX_ARCH = win32
55
+
56
+ # MSVC compiler options for both debug/optimize
57
+ # -nologo - suppress copyright message
58
+ # -W3 - Warning level 3
59
+ # -Gm - enable minimal rebuild
60
+ # -Z7 - put debug info into the executable, not in .pdb file
61
+ # -Zi - put debug info into .pdb file
62
+ # -YX - automatic precompiled headers
63
+ # -GX - enable C++ exception support
64
+ WIN_CFLAGS = -nologo -W3
65
+
66
+ # MSVC compiler options for debug builds linked to MSVCRTD.DLL
67
+ # -MDd - link with MSVCRTD.LIB (Dynamically-linked, multi-threaded, debug C-runtime)
68
+ # -Od - minimal optimization
69
+ WIN_IDG_CFLAGS = -MDd -Od -Z7
70
+
71
+ # MSVC compiler options for debug builds linked to MSVCRT.DLL
72
+ # -MD - link with MSVCRT.LIB (Dynamically-linked, multi-threaded, debug C-runtime)
73
+ # -Od - minimal optimization
74
+ WIN_DEBUG_CFLAGS = -MD -Od -Zi -Fd$(OBJDIR)/$(PDBFILE)
75
+
76
+ # MSVC compiler options for release (optimized) builds
77
+ # -MD - link with MSVCRT.LIB (Dynamically-linked, multi-threaded, C-runtime)
78
+ # -O2 - Optimize for speed
79
+ # -G5 - Optimize for Pentium
80
+ WIN_OPT_CFLAGS = -MD -O2
81
+
82
+ ifdef BUILD_OPT
83
+ OPTIMIZER = $(WIN_OPT_CFLAGS)
84
+ else
85
+ ifdef BUILD_IDG
86
+ OPTIMIZER = $(WIN_IDG_CFLAGS)
87
+ else
88
+ OPTIMIZER = $(WIN_DEBUG_CFLAGS)
89
+ endif
90
+ endif
91
+
92
+ OS_CFLAGS = -D_X86_=1 -DXP_WIN -DXP_WIN32 -DWIN32 -D_WINDOWS -D_WIN32 -DWINVER=0x500 -D_WIN32_WINNT=0x500 $(WIN_CFLAGS)
93
+ JSDLL_CFLAGS = -DEXPORT_JS_API
94
+ OS_LIBS = -lm -lc
95
+
96
+ PREBUILT_CPUCFG = 1
97
+ USE_MSVC = 1
98
+
99
+ LIB_LINK_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
100
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib oldnames.lib \
101
+ winmm.lib \
102
+ -nologo\
103
+ -subsystem:windows -dll -debug -pdb:$(OBJDIR)/$(PDBFILE)\
104
+ -machine:I386\
105
+ -opt:ref -opt:noicf
106
+
107
+ EXE_LINK_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
108
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib oldnames.lib -nologo\
109
+ -subsystem:console -debug -pdb:$(OBJDIR)/$(PDBFILE)\
110
+ -machine:I386\
111
+ -opt:ref -opt:noicf
112
+
113
+ # CAFEDIR = t:/cafe
114
+ # JCLASSPATH = $(CAFEDIR)/Java/Lib/classes.zip
115
+ # JAVAC = $(CAFEDIR)/Bin/sj.exe
116
+ # JAVAH = $(CAFEDIR)/Java/Bin/javah.exe
117
+ # JCFLAGS = -I$(CAFEDIR)/Java/Include -I$(CAFEDIR)/Java/Include/win32
@@ -1813,7 +1813,7 @@ ProcessSettingErr_Garbage:
1813
1813
  return LintConfError(cx, path, lineno, "invalid include setting: garbage after path");
1814
1814
  }
1815
1815
  */
1816
- }
1816
+ }
1817
1817
  else if (strncasecmp(linepos, "output-format", strlen("output-format")) == 0) {
1818
1818
  linepos += strlen("output-format");
1819
1819
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 10
8
- - 3
9
- version: 0.10.3
8
+ - 4
9
+ version: 0.10.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeff Watkins
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-25 00:00:00 -07:00
17
+ date: 2010-05-05 00:00:00 -07:00
18
18
  default_executable: distil
19
19
  dependencies: []
20
20
 
@@ -57,7 +57,6 @@ files:
57
57
  - lib/tasks/test-task.rb
58
58
  - lib/test/HtmlTestReporter.js
59
59
  - lib/test/Test.js
60
- - lib/test/TestHelper.js
61
60
  - lib/test/TestReporter.js
62
61
  - lib/test/TestRunner.js
63
62
  - lib/test/browser.rb
@@ -223,6 +222,7 @@ files:
223
222
  - vendor/jsl-0.3.0/src/config/IRIX6.5.mk
224
223
  - vendor/jsl-0.3.0/src/config/Linux_All.mk
225
224
  - vendor/jsl-0.3.0/src/config/Mac_OS10.0.mk
225
+ - vendor/jsl-0.3.0/src/config/MinGW5.1.mk
226
226
  - vendor/jsl-0.3.0/src/config/OSF1V4.0.mk
227
227
  - vendor/jsl-0.3.0/src/config/OSF1V5.0.mk
228
228
  - vendor/jsl-0.3.0/src/config/SunOS4.1.4.mk
@@ -238,6 +238,7 @@ files:
238
238
  - vendor/jsl-0.3.0/src/config/WINNT5.0.mk
239
239
  - vendor/jsl-0.3.0/src/config/WINNT5.1.mk
240
240
  - vendor/jsl-0.3.0/src/config/WINNT5.2.mk
241
+ - vendor/jsl-0.3.0/src/config/WINNT6.0.mk
241
242
  - vendor/jsl-0.3.0/src/config/dgux.mk
242
243
  - vendor/jsl-0.3.0/src/editline/Makefile.ref
243
244
  - vendor/jsl-0.3.0/src/editline/README
@@ -1,225 +0,0 @@
1
- function TestHelper(scope, report, test, testName)
2
- {
3
- this.scope= scope;
4
- this.report= report;
5
- this.test= test;
6
- this.testName= testName;
7
- this._async= false;
8
- }
9
- TestHelper.prototype= {
10
-
11
- __ASYNC_MARKER__: 'async_marker',
12
-
13
- stringFromValue: function(v)
14
- {
15
- return String(v);
16
- },
17
-
18
- compareArrays: function(a1, a2)
19
- {
20
- if (a1.length==a2.length)
21
- {
22
- var len=a1.length;
23
- var i;
24
-
25
- for (i=0; i<len; ++i)
26
- if (a1[i]!==a2[i])
27
- return false;
28
- return true;
29
- }
30
-
31
- return false;
32
- },
33
-
34
- log: function()
35
- {
36
- this.report.log.apply(this.report, arguments);
37
- },
38
-
39
- passed: function()
40
- {
41
- if (this._finished)
42
- return;
43
-
44
- this.report.passed(this.test, this.testName);
45
- this.finishAsync();
46
- },
47
-
48
- clearTimer: function()
49
- {
50
- if (!this._timer)
51
- return;
52
- window.clearTimeout(this._timer);
53
- this._timer= 0;
54
- },
55
-
56
- finishAsync: function()
57
- {
58
- if (!this._async || this._finished)
59
- return;
60
-
61
- this._finished= true;
62
- this.clearTimer();
63
- try
64
- {
65
- if (this.teardown)
66
- this.teardown.call(this.scope);
67
- }
68
- catch (e)
69
- {
70
- this.report.exceptionInTeardown(this.test, this.testName, e);
71
- }
72
-
73
- this.report.endTest(this.test, this.testName);
74
- if (this.ontestcomplete)
75
- this.ontestcomplete();
76
- },
77
-
78
- /** Create an asynchronous handler for this method. If the test
79
- * doesn't complete before the timeout expires, then the test
80
- * fails.
81
- */
82
- async: function(timeout)
83
- {
84
- var helper= this;
85
-
86
- function timeoutFn()
87
- {
88
- helper.report.timeoutExpired(helper.test, helper.testName, timeout);
89
- helper.finishAsync();
90
- }
91
-
92
- this._timer= window.setTimeout(timeoutFn, timeout);
93
- this._async= true;
94
- return this.__ASYNC_MARKER__;
95
- },
96
-
97
- assert: function(value, msg)
98
- {
99
- this.assertTrue(value, msg);
100
- },
101
-
102
- assertEqual: function(value, expected, msg)
103
- {
104
- if ('object'===typeof(value) && 'object'===typeof(expected) &&
105
- value.splice && expected.splice)
106
- {
107
- if (this.compareArrays(value, expected))
108
- return;
109
- }
110
- else if (value===expected)
111
- return;
112
-
113
- this.fail(msg||(this.stringFromValue(value) + '===' +
114
- this.stringFromValue(expected)));
115
- },
116
-
117
- assertNotEqual: function(value, expected, msg)
118
- {
119
- if (value!==expected)
120
- return;
121
- this.fail(msg||(this.stringFromValue(value) + '!==' +
122
- this.stringFromValue(expected)));
123
- },
124
-
125
- assertTrue: function(value, msg)
126
- {
127
- if (true===value)
128
- return;
129
- this.fail(msg||(this.stringFromValue(value) + ' is not true'));
130
- },
131
-
132
- assertFalse: function(value, msg)
133
- {
134
- if (false===value)
135
- return;
136
- this.fail(msg||(this.stringFromValue(value) + ' is not false'));
137
- },
138
-
139
- assertNull: function(value, msg)
140
- {
141
- if (null===value)
142
- return;
143
- this.fail(msg||(this.stringFromValue(value) + ' is not null'));
144
- },
145
-
146
- assertNotNull: function(value, msg)
147
- {
148
- if (null!==value)
149
- return;
150
- this.fail(msg||(this.stringFromValue(value) + ' is null'));
151
- },
152
-
153
- assertUndefined: function(value, msg)
154
- {
155
- if ('undefined'===typeof(value))
156
- return;
157
- this.fail(msg||(this.stringFromValue(value) + ' is not undefined'));
158
- },
159
-
160
- assertNotUndefined: function(value, msg)
161
- {
162
- if ('undefined'!==typeof(value))
163
- return;
164
- this.fail(msg||(this.stringFromValue(value) + ' is undefined'));
165
- },
166
-
167
- assertMatch: function(regex, value, msg)
168
- {
169
- if (regex.exec(value))
170
- return;
171
- this.fail(msg||(this.stringFromValue(value) + ' did not match /' + regex.source + '/'));
172
- },
173
-
174
- assertNotMatch: function(regex, value, msg)
175
- {
176
- if (!regex.exec(value))
177
- return;
178
- this.fail(msg||(this.stringFromValue(value) + ' matched /' + regex.source + '/'));
179
- },
180
-
181
- assertInstanceOf: function(value, klass, msg)
182
- {
183
- if (value instanceof klass)
184
- return;
185
- this.fail(msg||(this.stringFromValue(value) + ' is not an instance'));
186
- },
187
-
188
- assertNotInstanceOf: function(value, klass, msg)
189
- {
190
- if (!(value instanceof klass))
191
- return;
192
- this.fail(msg||(this.stringFromValue(value) + ' is an instance'));
193
- },
194
-
195
- fail: function(msg)
196
- {
197
- if (this._finished)
198
- return;
199
-
200
- msg= msg||'failed';
201
- this.report.failed(this.test, this.testName, msg);
202
-
203
- this.finishAsync();
204
-
205
- var error= new Error(msg);
206
- error.name= 'AssertionError';
207
- throw error;
208
- },
209
-
210
- skip: function(why)
211
- {
212
- if (this._finished)
213
- return;
214
-
215
- why= why||'Test skipped';
216
- this.report.skipped(this.test, this.testName, why);
217
-
218
- this.finishAsync();
219
-
220
- var error= new Error(why);
221
- error.name= 'AssertionError';
222
- throw error;
223
- }
224
-
225
- };