Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ded14024
Commit
ded14024
authored
Sep 05, 2006
by
Jörn Zaefferer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the testsuite code with the hope in mind to make the test suite run faster
parent
b5220adb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
112 deletions
+96
-112
test.js
build/test/js/test.js
+96
-112
No files found.
build/test/js/test.js
View file @
ded14024
var
queue
=
[];
var
queue
=
[];
var
blocking
=
false
;
var
blocking
=
false
;
var
fixture
;
function
reset
()
{
function
reset
(
fixture
)
{
if
(
fixture
)
{
synchronize
(
function
()
{
$
(
"#main"
).
html
(
fixture
);
document
.
getElementById
(
'main'
).
innerHTML
=
fixture
;
}
else
{
});
fixture
=
$
(
"#main"
).
html
();
}
}
}
function
synchronize
(
callback
)
{
function
synchronize
(
callback
)
{
...
@@ -26,14 +23,15 @@ function process() {
...
@@ -26,14 +23,15 @@ function process() {
}
}
function
runTests
(
files
)
{
function
runTests
(
files
)
{
var
fixture
=
null
;
var
fixture
=
document
.
getElementById
(
'main'
).
innerHTML
;
reset
();
var
startTime
=
new
Date
();
var
startTime
=
new
Date
();
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
runTest
(
files
,
i
);
runTest
(
files
,
i
);
reset
(
fixture
);
}
}
synchronize
(
function
()
{
synchronize
(
function
()
{
var
runTime
=
new
Date
()
-
startTime
;
var
runTime
=
new
Date
()
-
startTime
;
// lets use jQuery for this, its not important anyway
$
(
'body'
).
append
(
'<br/>Tests completed in '
+
runTime
+
' milliseconds.'
);
$
(
'body'
).
append
(
'<br/>Tests completed in '
+
runTime
+
' milliseconds.'
);
});
});
}
}
...
@@ -41,7 +39,14 @@ function runTests(files) {
...
@@ -41,7 +39,14 @@ function runTests(files) {
function
runTest
(
files
,
num
)
{
function
runTest
(
files
,
num
)
{
synchronize
(
function
()
{
synchronize
(
function
()
{
blocking
=
true
;
blocking
=
true
;
$
.
get
(
files
[
num
],
function
(
js
){
$
.
get
(
files
[
num
],
function
(
js
)
{
evaluateTest
(
files
,
num
,
js
);
});
});
}
function
evaluateTest
(
files
,
num
,
js
)
{
var
Test
=
[];
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
).
replace
(
/&/g
,
"&"
);
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
).
replace
(
/&/g
,
"&"
);
try
{
try
{
...
@@ -49,6 +54,7 @@ function runTest( files, num ) {
...
@@ -49,6 +54,7 @@ function runTest( files, num ) {
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
typeof
console
!=
"undefined"
)
if
(
typeof
console
!=
"undefined"
)
console
.
error
(
e
);
console
.
error
(
e
);
console
.
debug
(
js
);
Test
.
push
(
[
false
,
"Died on test #"
+
(
Test
.
length
+
1
)
+
": "
+
e
]
);
Test
.
push
(
[
false
,
"Died on test #"
+
(
Test
.
length
+
1
)
+
": "
+
e
]
);
}
}
...
@@ -86,27 +92,20 @@ function runTest( files, num ) {
...
@@ -86,27 +92,20 @@ function runTest( files, num ) {
document
.
getElementById
(
"tests"
).
appendChild
(
li
);
document
.
getElementById
(
"tests"
).
appendChild
(
li
);
Test
=
[];
reset
();
blocking
=
false
;
blocking
=
false
;
process
();
process
();
});
});
}
var
Test
=
[];
function
ok
(
a
,
msg
)
{
function
ok
(
a
,
msg
)
{
Test
.
push
(
[
!!
a
,
msg
]
);
Test
.
push
(
[
!!
a
,
msg
]
);
}
}
function
cmpOK
(
a
,
c
,
b
,
msg
)
{
function
cmpOK
(
a
,
c
,
b
,
msg
)
{
var
res
;
var
res
;
eval
(
"res = (a "
+
c
+
" b)"
);
eval
(
"res = (a "
+
c
+
" b)"
);
Test
.
push
(
[
res
,
msg
]
);
Test
.
push
(
[
res
,
msg
]
);
}
}
function
isSet
(
a
,
b
,
msg
)
{
function
isSet
(
a
,
b
,
msg
)
{
var
ret
=
true
;
var
ret
=
true
;
if
(
a
&&
b
&&
a
.
length
==
b
.
length
)
{
if
(
a
&&
b
&&
a
.
length
==
b
.
length
)
{
...
@@ -120,18 +119,18 @@ function isSet(a, b, msg) {
...
@@ -120,18 +119,18 @@ function isSet(a, b, msg) {
console
.
log
(
msg
,
a
,
b
);
console
.
log
(
msg
,
a
,
b
);
Test
.
push
(
[
ret
,
msg
]
);
Test
.
push
(
[
ret
,
msg
]
);
}
}
function
q
()
{
function
q
()
{
var
r
=
[];
var
r
=
[];
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
r
.
push
(
document
.
getElementById
(
arguments
[
i
]
)
);
r
.
push
(
document
.
getElementById
(
arguments
[
i
]
)
);
return
r
;
return
r
;
}
}
function
t
(
a
,
b
,
c
)
{
function
t
(
a
,
b
,
c
)
{
var
f
=
jQuery
.
find
(
b
);
var
f
=
jQuery
.
find
(
b
);
var
s
=
""
;
var
s
=
""
;
...
@@ -139,20 +138,5 @@ function t(a,b,c) {
...
@@ -139,20 +138,5 @@ function t(a,b,c) {
s
+=
(
s
&&
","
)
+
'"'
+
f
[
i
].
id
+
'"'
;
s
+=
(
s
&&
","
)
+
'"'
+
f
[
i
].
id
+
'"'
;
isSet
(
f
,
q
.
apply
(
q
,
c
),
a
+
" ("
+
b
+
")"
);
isSet
(
f
,
q
.
apply
(
q
,
c
),
a
+
" ("
+
b
+
")"
);
}
}
}
\ No newline at end of file
function
o
(
a
)
{
var
li
=
document
.
createElement
(
"li"
);
li
.
innerHTML
=
a
;
if
(
a
.
indexOf
(
"#"
)
==
0
)
li
.
className
=
"comment"
;
else
if
(
a
.
indexOf
(
"TODO"
)
>=
0
)
li
.
className
=
"todo"
;
else
if
(
a
.
indexOf
(
"not ok"
)
==
0
)
li
.
classname
=
"fail"
;
else
li
.
className
=
"pass"
;
document
.
getElementById
(
"test"
).
appendChild
(
li
);
}
//plan({noPlan: true});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment