forked from 0x2620/oxjs
new build system: build in /build, dev version in /dev; split up Ox.js; fix tests
This commit is contained in:
parent
bbef38f0a9
commit
d0fe279a0f
366 changed files with 8165 additions and 161926 deletions
|
|
@ -3,10 +3,9 @@
|
|||
<head>
|
||||
<title>Ox.js Tests</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="tests.css"/>
|
||||
<script type="text/javascript" src="../build/Ox.js"></script>
|
||||
<!--<script type="text/javascript" src="../build/js/ox.data.js"></script>-->
|
||||
<script type="text/javascript" src="tests.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="css/tests.css"/>
|
||||
<script type="text/javascript" src="../dev/Ox.js"></script>
|
||||
<script type="text/javascript" src="js/tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
div {
|
||||
font-family: Consolas;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.success {
|
||||
color: rgb(0, 128, 0);
|
||||
}
|
||||
|
||||
.failure {
|
||||
color: rgb(192, 0, 0);
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
Ox.load({UI: {}, Geo: {}}, function() {
|
||||
|
||||
//Ox.UI.ready(function() {
|
||||
|
||||
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);
|
||||
|
||||
tests(['../build/Ox.js', '../build/Ox.Geo/Ox.Geo.js']);
|
||||
|
||||
function tests() {
|
||||
var passed = 0, failed = 0,
|
||||
lines, spaces, command, expected, result, passed,
|
||||
replace = ['', ''], fns = [], $test
|
||||
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'})
|
||||
.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) {
|
||||
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">'
|
||||
+ Ox.encodeHTML(test.statement) + ' '
|
||||
+ (test.passed ? '=' : '!') + '=> '
|
||||
+ Ox.encodeHTML(test.expected)
|
||||
+ (test.passed ? '' : ' ==> ' + Ox.encodeHTML(test.actual))
|
||||
+ '</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] + '))'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue