2012-05-27 19:31:16 +00:00
|
|
|
Ox.load({Geo: {}, Image: {}, UI: {}, Unicode: {}}, function() {
|
2011-10-07 01:19:00 +00:00
|
|
|
Ox.getJSON('../dev/Ox/json/Ox.json', function(files) {
|
|
|
|
|
|
|
|
var $body = $('body')
|
|
|
|
.css({
|
|
|
|
overflowY: 'auto'
|
|
|
|
}),
|
|
|
|
$tests = new Ox.Bar({
|
|
|
|
size: 20
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
padding: '6px 0 6px 8px',
|
|
|
|
fontSize: '16px',
|
|
|
|
fontWeight: 'bold'
|
|
|
|
})
|
|
|
|
.appendTo($body);
|
|
|
|
colors = [
|
|
|
|
['255, 64, 64', '224, 32, 32', '240, 16, 16'],
|
|
|
|
['64, 192, 64', '32, 160, 32', '40, 176, 48'],
|
|
|
|
['96, 96, 255', '64, 64, 224', '80, 80, 240']
|
|
|
|
];
|
|
|
|
|
|
|
|
setBackground($tests, true);
|
|
|
|
|
2012-05-24 10:17:12 +00:00
|
|
|
tests(
|
|
|
|
Ox.flatten(files).sort().map(function(file) {
|
|
|
|
return '../dev/' + file;
|
|
|
|
}).concat([
|
|
|
|
'../dev/Ox.Geo/Ox.Geo.js',
|
|
|
|
'../dev/Ox.Image/Ox.Image.js',
|
|
|
|
'../dev/Ox.Unicode/Ox.Unicode.js'
|
2012-05-27 16:39:34 +00:00
|
|
|
]).map(function(file) {
|
|
|
|
return file + '?' + Ox.random(1000000);
|
|
|
|
})
|
2012-05-24 10:17:12 +00:00
|
|
|
);
|
2011-10-07 01:19:00 +00:00
|
|
|
|
|
|
|
function tests() {
|
|
|
|
var passed = 0, failed = 0,
|
|
|
|
lines, spaces, command, expected, result, passed,
|
2012-05-25 16:28:05 +00:00
|
|
|
replace = ['', ''], fns = [], $test;
|
2011-10-07 01:19:00 +00:00
|
|
|
Ox.forEach(Ox.isArray(arguments[0]) ? arguments[0] : arguments, function(script, i) {
|
|
|
|
Ox.test(script, function(results) {
|
|
|
|
var tests = {};
|
|
|
|
results.forEach(function(result) {
|
|
|
|
tests[result.section] = tests[result.section] || {};
|
|
|
|
tests[result.section][result.name] = tests[result.section][result.name] || [];
|
|
|
|
tests[result.section][result.name].push(result);
|
|
|
|
});
|
|
|
|
Ox.forEach(tests, function(functions, section) {
|
|
|
|
Ox.Bar({size: 14})
|
|
|
|
.css({padding: '1px 0 1px 4px'})
|
2012-05-27 16:39:34 +00:00
|
|
|
.html(Ox.basename(script).split('?')[0] + ' ' + (section || ''))
|
2011-10-07 01:19:00 +00:00
|
|
|
.appendTo($body);
|
|
|
|
Ox.forEach(functions, function(arr, fn) {
|
|
|
|
var $test = Ox.CollapsePanel({
|
|
|
|
collapsed: true,
|
|
|
|
title: fn + '()'
|
|
|
|
})
|
|
|
|
.appendTo($body);
|
|
|
|
setBackground($test.find('.OxBar'), true);
|
|
|
|
arr.forEach(function(test) {
|
|
|
|
passed += test.passed;
|
|
|
|
failed += !test.passed;
|
|
|
|
$tests.html(
|
|
|
|
(passed + failed) + ' tests, '
|
|
|
|
+ passed + ' passed, ' + failed + ' failed'
|
|
|
|
);
|
|
|
|
if (!test.passed) {
|
|
|
|
setBackground($tests, false);
|
|
|
|
setBackground($test.find('.OxBar'), false);
|
|
|
|
}
|
|
|
|
Ox.Element()
|
|
|
|
.css({
|
|
|
|
padding: '2px 0 2px 4px',
|
|
|
|
background: 'rgb(' + colors[+test.passed][2] + ')'
|
|
|
|
})
|
|
|
|
.html(
|
|
|
|
'<span style="font-family: Monaco">'
|
2012-05-27 10:40:02 +00:00
|
|
|
+ Ox.encodeHTMLEntities(test.statement) + ' '
|
2011-10-07 01:19:00 +00:00
|
|
|
+ (test.passed ? '=' : '!') + '=> '
|
2012-05-27 10:40:02 +00:00
|
|
|
+ Ox.encodeHTMLEntities(test.expected)
|
|
|
|
+ (test.passed ? '' : ' ==> ' + Ox.encodeHTMLEntities(test.actual))
|
2011-10-07 01:19:00 +00:00
|
|
|
+ '</tt>'
|
|
|
|
)
|
|
|
|
.appendTo($test.$content);
|
|
|
|
});
|
|
|
|
$test.$content.css({
|
|
|
|
marginTop: -$test.$content.height() + 'px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setBackground($element, passed) {
|
|
|
|
['-moz-linear-gradient', '-webkit-linear-gradient'].forEach(function(v) {
|
|
|
|
$element.css({
|
|
|
|
background: v + '(top, rgb(' +
|
|
|
|
colors[+passed][0] + '), rgb(' +
|
|
|
|
colors[+passed][1] + '))'
|
|
|
|
});
|
|
|
|
});
|
2012-05-25 16:28:05 +00:00
|
|
|
$.browser.msie && $element.css({
|
|
|
|
background: 'rgb(' + colors[+passed][0] + ')'
|
|
|
|
});
|
2011-10-07 01:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|