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
Hide 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,118 +39,104 @@ function runTests(files) {
...
@@ -41,118 +39,104 @@ 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
)
{
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
).
replace
(
/&/g
,
"&"
);
evaluateTest
(
files
,
num
,
js
);
try
{
eval
(
js
);
}
catch
(
e
)
{
if
(
typeof
console
!=
"undefined"
)
console
.
error
(
e
);
Test
.
push
(
[
false
,
"Died on test #"
+
(
Test
.
length
+
1
)
+
": "
+
e
]
);
}
var
good
=
0
,
bad
=
0
;
var
ol
=
document
.
createElement
(
"ol"
);
var
li
=
""
,
state
=
"pass"
;
for
(
var
i
=
0
;
i
<
Test
.
length
;
i
++
)
{
var
li
=
document
.
createElement
(
"li"
);
li
.
className
=
Test
[
i
][
0
]
?
"pass"
:
"fail"
;
li
.
innerHTML
=
Test
[
i
][
1
];
ol
.
appendChild
(
li
);
if
(
!
Test
[
i
][
0
]
)
{
state
=
"fail"
;
bad
++
;
}
else
good
++
;
}
var
li
=
document
.
createElement
(
"li"
);
li
.
className
=
state
;
var
b
=
document
.
createElement
(
"b"
);
b
.
innerHTML
=
files
[
num
]
+
" <b style='color:black;'>(<b class='fail'>"
+
bad
+
"</b>, <b class='pass'>"
+
good
+
"</b>, "
+
Test
.
length
+
")</b>"
;
b
.
onclick
=
function
(){
var
n
=
this
.
nextSibling
;
if
(
jQuery
.
css
(
n
,
"display"
)
==
"none"
)
n
.
style
.
display
=
"block"
;
else
n
.
style
.
display
=
"none"
;
};
li
.
appendChild
(
b
);
li
.
appendChild
(
ol
);
document
.
getElementById
(
"tests"
).
appendChild
(
li
);
Test
=
[];
reset
();
blocking
=
false
;
process
();
});
});
});
});
}
}
var
Test
=
[];
function
evaluateTest
(
files
,
num
,
js
)
{
var
Test
=
[];
function
ok
(
a
,
msg
)
{
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
).
replace
(
/&/g
,
"&"
);
Test
.
push
(
[
!!
a
,
msg
]
);
}
try
{
eval
(
js
);
function
cmpOK
(
a
,
c
,
b
,
msg
)
{
}
catch
(
e
)
{
var
res
;
if
(
typeof
console
!=
"undefined"
)
eval
(
"res = (a "
+
c
+
" b)"
);
console
.
error
(
e
);
Test
.
push
(
[
res
,
msg
]
);
console
.
debug
(
js
);
}
Test
.
push
(
[
false
,
"Died on test #"
+
(
Test
.
length
+
1
)
+
": "
+
e
]
);
}
function
isSet
(
a
,
b
,
msg
)
{
var
ret
=
true
;
if
(
a
&&
b
&&
a
.
length
==
b
.
length
)
{
for
(
var
i
in
a
)
if
(
a
[
i
]
!=
b
[
i
]
)
ret
=
false
;
}
else
ret
=
false
;
if
(
!
ret
&&
console
)
console
.
log
(
msg
,
a
,
b
);
Test
.
push
(
[
ret
,
msg
]
);
}
function
q
()
{
var
good
=
0
,
bad
=
0
;
var
r
=
[]
;
var
ol
=
document
.
createElement
(
"ol"
)
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
var
li
=
""
,
state
=
"pass"
;
r
.
push
(
document
.
getElementById
(
arguments
[
i
]
)
);
for
(
var
i
=
0
;
i
<
Test
.
length
;
i
++
)
{
var
li
=
document
.
createElement
(
"li"
);
li
.
className
=
Test
[
i
][
0
]
?
"pass"
:
"fail"
;
li
.
innerHTML
=
Test
[
i
][
1
];
ol
.
appendChild
(
li
);
return
r
;
if
(
!
Test
[
i
][
0
]
)
{
}
state
=
"fail"
;
bad
++
;
}
else
good
++
;
}
function
t
(
a
,
b
,
c
)
{
var
li
=
document
.
createElement
(
"li"
);
var
f
=
jQuery
.
find
(
b
)
;
li
.
className
=
state
;
var
s
=
""
;
var
b
=
document
.
createElement
(
"b"
);
for
(
var
i
=
0
;
i
<
f
.
length
;
i
++
)
b
.
innerHTML
=
files
[
num
]
+
" <b style='color:black;'>(<b class='fail'>"
+
bad
+
"</b>, <b class='pass'>"
+
good
+
"</b>, "
+
Test
.
length
+
")</b>"
;
s
+=
(
s
&&
","
)
+
'"'
+
f
[
i
].
id
+
'"'
;
b
.
onclick
=
function
(){
var
n
=
this
.
nextSibling
;
if
(
jQuery
.
css
(
n
,
"display"
)
==
"none"
)
n
.
style
.
display
=
"block"
;
else
n
.
style
.
display
=
"none"
;
};
li
.
appendChild
(
b
);
isSet
(
f
,
q
.
apply
(
q
,
c
),
a
+
" ("
+
b
+
")"
);
li
.
appendChild
(
ol
);
}
function
o
(
a
)
{
document
.
getElementById
(
"tests"
).
appendChild
(
li
);
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});
blocking
=
false
;
process
();
function
ok
(
a
,
msg
)
{
Test
.
push
(
[
!!
a
,
msg
]
);
}
function
cmpOK
(
a
,
c
,
b
,
msg
)
{
var
res
;
eval
(
"res = (a "
+
c
+
" b)"
);
Test
.
push
(
[
res
,
msg
]
);
}
function
isSet
(
a
,
b
,
msg
)
{
var
ret
=
true
;
if
(
a
&&
b
&&
a
.
length
==
b
.
length
)
{
for
(
var
i
in
a
)
if
(
a
[
i
]
!=
b
[
i
]
)
ret
=
false
;
}
else
ret
=
false
;
if
(
!
ret
&&
console
)
console
.
log
(
msg
,
a
,
b
);
Test
.
push
(
[
ret
,
msg
]
);
}
function
q
()
{
var
r
=
[];
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
r
.
push
(
document
.
getElementById
(
arguments
[
i
]
)
);
return
r
;
}
function
t
(
a
,
b
,
c
)
{
var
f
=
jQuery
.
find
(
b
);
var
s
=
""
;
for
(
var
i
=
0
;
i
<
f
.
length
;
i
++
)
s
+=
(
s
&&
","
)
+
'"'
+
f
[
i
].
id
+
'"'
;
isSet
(
f
,
q
.
apply
(
q
,
c
),
a
+
" ("
+
b
+
")"
);
}
}
\ No newline at end of file
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