forked from 0x2620/oxjs
merging changes
This commit is contained in:
parent
94fb1b4d1d
commit
221355f8ba
8 changed files with 8989 additions and 672 deletions
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="../build/css/ox.ui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="tests.css"/>
|
||||
<script type="text/javascript" src="../build/js/jquery-1.4.js"></script>
|
||||
<script type="text/javascript" src="../build/js/jquery-1.5.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.data.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.ui.js"></script>
|
||||
|
|
|
|||
|
|
@ -25,14 +25,16 @@ $(function() {
|
|||
|
||||
setBackground($tests, true);
|
||||
|
||||
tests('../build/js/ox.js', '../build/js/ox.data.js');
|
||||
tests(['../build/js/ox.js', '../build/js/ox.data.js']);
|
||||
|
||||
function tests() {
|
||||
var succeeded = 0, failed = 0,
|
||||
lines, spaces, command, expected, result, success,
|
||||
replace = ['', ''], fns = [], $test
|
||||
$.each($.isArray(arguments[0]) ? arguments[0] : arguments, function(i, script) {
|
||||
Ox.forEach(Ox.isArray(arguments[0]) ? arguments[0] : arguments, function(script, i) {
|
||||
Ox.print(script, Ox)
|
||||
$.get(script, function(data) {
|
||||
Ox.print(script, Ox)
|
||||
new Ox.Bar({size: 17})
|
||||
.css({padding: '3px 0 0 8px'})
|
||||
.html(Ox.basename(script))
|
||||
|
|
@ -49,15 +51,21 @@ $(function() {
|
|||
spaces = line.indexOf('>>> ');
|
||||
if (spaces > -1) {
|
||||
command = $.trim(line).substr(4).split(' // ')[0];
|
||||
Ox.print('command:', command)
|
||||
fn = command.match(/Ox\.\w+/);
|
||||
fn = command.match(/Ox\.\w+/g);
|
||||
Ox.print('fn', fn)
|
||||
//Ox.print(lines[l + 1].substr(spaces, lines[l + 1].length), eval(lines[l + 1].substr(spaces, lines[l + 1].length)))
|
||||
Ox.print(lines[l + 1].substr(spaces, lines[l + 1].length));
|
||||
expected = eval(lines[l + 1].substr(spaces, lines[l + 1].length));
|
||||
// fixme: if object, recursively check identity
|
||||
result = eval(command);
|
||||
if (fn) {
|
||||
fn = fn[0];
|
||||
fn = fn[fn.length - 1];
|
||||
/*
|
||||
success = typeof expected == 'object' ?
|
||||
expected.toString() == result.toString() : expected === result;
|
||||
*/
|
||||
Ox.print('command:', command, 'expected:', expected, 'result:', result)
|
||||
success = Ox.isEqual(expected, result);
|
||||
succeeded += success;
|
||||
failed += !success;
|
||||
$tests.html((succeeded + failed) + ' tests, ' +
|
||||
|
|
@ -83,8 +91,8 @@ $(function() {
|
|||
.html(
|
||||
Ox.basename(script) + ', line ' + l + ': <span style="font-weight: bold">' +
|
||||
Ox.encodeHTML(command).replace(replace[0], replace[1]) + ' ' +
|
||||
(success ? '=' : '!') + '=> ' + Ox.encodeHTML(expected.toString()) +
|
||||
(success ? '' : ' ==> ' + Ox.encodeHTML(result.toString())) + '</span>'
|
||||
(success ? '=' : '!') + '=> ' + Ox.encodeHTML(JSON.stringify(expected)) +
|
||||
(success ? '' : ' ==> ' + Ox.encodeHTML(JSON.stringify(result))) + '</span>'
|
||||
)
|
||||
.appendTo($test.$content);
|
||||
//*/
|
||||
|
|
@ -105,7 +113,7 @@ $(function() {
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 'html');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue