2011-10-01 02:21:55 +00:00
|
|
|
Ox.load({UI: {}, Geo: {}}, function() {
|
2011-04-23 00:20:24 +00:00
|
|
|
|
|
|
|
//Ox.UI.ready(function() {
|
2010-01-07 20:21:07 +00:00
|
|
|
|
2011-02-09 17:56:35 +00:00
|
|
|
var $body = $('body')
|
2010-01-07 20:21:07 +00:00
|
|
|
.css({
|
2011-02-09 17:56:35 +00:00
|
|
|
overflowY: 'auto'
|
2010-01-07 20:21:07 +00:00
|
|
|
}),
|
|
|
|
$tests = new Ox.Bar({
|
|
|
|
size: 20
|
|
|
|
})
|
|
|
|
.css({
|
2011-02-09 17:56:35 +00:00
|
|
|
padding: '6px 0 6px 8px',
|
|
|
|
fontSize: '16px',
|
|
|
|
fontWeight: 'bold'
|
2010-01-07 20:21:07 +00:00
|
|
|
})
|
2011-08-12 21:00:42 +00:00
|
|
|
.appendTo($body);
|
2010-01-07 20:21:07 +00:00
|
|
|
colors = [
|
2011-02-09 17:56:35 +00:00
|
|
|
['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']
|
2010-01-07 20:21:07 +00:00
|
|
|
];
|
2011-02-09 17:56:35 +00:00
|
|
|
|
2010-01-07 20:21:07 +00:00
|
|
|
setBackground($tests, true);
|
|
|
|
|
2011-10-01 02:21:55 +00:00
|
|
|
tests(['../build/Ox.js', '../build/Ox.Geo/Ox.Geo.js']);
|
2010-01-07 20:21:07 +00:00
|
|
|
|
|
|
|
function tests() {
|
2011-08-15 12:18:14 +00:00
|
|
|
var passed = 0, failed = 0,
|
|
|
|
lines, spaces, command, expected, result, passed,
|
2011-02-09 17:56:35 +00:00
|
|
|
replace = ['', ''], fns = [], $test
|
2011-02-22 10:02:28 +00:00
|
|
|
Ox.forEach(Ox.isArray(arguments[0]) ? arguments[0] : arguments, function(script, i) {
|
2011-08-12 21:00:42 +00:00
|
|
|
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'})
|
|
|
|
.html(Ox.basename(script) + ' ' + section)
|
|
|
|
.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) {
|
2011-08-15 12:18:14 +00:00
|
|
|
passed += test.passed;
|
|
|
|
failed += !test.passed;
|
2011-08-12 21:00:42 +00:00
|
|
|
$tests.html(
|
2011-08-15 12:18:14 +00:00
|
|
|
(passed + failed) + ' tests, '
|
|
|
|
+ passed + ' passed, ' + failed + ' failed'
|
2011-08-12 21:00:42 +00:00
|
|
|
);
|
2011-08-15 12:18:14 +00:00
|
|
|
if (!test.passed) {
|
2011-08-12 21:00:42 +00:00
|
|
|
setBackground($tests, false);
|
|
|
|
setBackground($test.find('.OxBar'), false);
|
|
|
|
}
|
|
|
|
Ox.Element()
|
|
|
|
.css({
|
|
|
|
padding: '2px 0 2px 4px',
|
2011-08-15 12:18:14 +00:00
|
|
|
background: 'rgb(' + colors[+test.passed][2] + ')'
|
2011-08-12 21:00:42 +00:00
|
|
|
})
|
|
|
|
.html(
|
|
|
|
'<span style="font-family: Monaco">'
|
|
|
|
+ Ox.encodeHTML(test.statement) + ' '
|
2011-08-15 12:18:14 +00:00
|
|
|
+ (test.passed ? '=' : '!') + '=> '
|
2011-08-12 21:00:42 +00:00
|
|
|
+ Ox.encodeHTML(test.expected)
|
2011-08-15 12:18:14 +00:00
|
|
|
+ (test.passed ? '' : ' ==> ' + Ox.encodeHTML(test.actual))
|
2011-08-12 21:00:42 +00:00
|
|
|
+ '</tt>'
|
|
|
|
)
|
|
|
|
.appendTo($test.$content);
|
|
|
|
});
|
|
|
|
$test.$content.css({
|
|
|
|
marginTop: -$test.$content.height() + 'px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
2010-01-07 20:21:07 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-08-15 12:18:14 +00:00
|
|
|
function setBackground($element, passed) {
|
2011-08-12 21:00:42 +00:00
|
|
|
['-moz-linear-gradient', '-webkit-linear-gradient'].forEach(function(v) {
|
2010-01-07 20:21:07 +00:00
|
|
|
$element.css({
|
2011-08-12 21:00:42 +00:00
|
|
|
background: v + '(top, rgb(' +
|
2011-08-15 12:18:14 +00:00
|
|
|
colors[+passed][0] + '), rgb(' +
|
|
|
|
colors[+passed][1] + '))'
|
2010-01-07 20:21:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-04-25 12:14:03 +00:00
|
|
|
});
|