-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.js
More file actions
73 lines (52 loc) · 1.9 KB
/
tests.js
File metadata and controls
73 lines (52 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var fs = require('fs');
var _ = require('underscore')
var Backbone = require('backbone')
var expression = fs.readFileSync('./lib/backbone_extensions.js','utf8');
eval(expression)
var expression = fs.readFileSync('./vector.js','utf8');
eval(expression)
var expression = fs.readFileSync('./graph.js','utf8');
eval(expression)
var expression = fs.readFileSync('./quad.js','utf8');
eval(expression)
var expression = fs.readFileSync('./classicalmechanics.js','utf8');
eval(expression)
var expression = fs.readFileSync('./lib/decorators.js','utf8');
eval(expression)
var expression = fs.readFileSync('./thing.js','utf8');
eval(expression)
// converts retarded magical arguments object to an Array object
function toArray(arg) { return Array.prototype.slice.call(arg) }
exports.Vector_Arithmetics = function(test) {
test.equal(makeV(1,1).isub(makeV(2,-3)).show().join(),'-1,4')
test.done()
};
exports.Vector_Constructor = function(test) {
var x = new Thing()
x.set({test0: makeV(1,2)})
x.set({test1: [3,4]})
x.set(_.extend({},
vectorize(x,'test0',[5,6]),
vectorize(x,'test1',[7,8]),
vectorize(x,'test2',[9,10])
))
test.equal(JSON.stringify([x.get('test0').show(), x.get('test1').show(),x.get('test2').show()]),"[[1,2],[3,4],[9,10]]")
test.done()
}
exports.ClassicalMechanics_Simulation = function(test) {
var p = new ClassicalMechanics({ velocity: [0,0], acceleration: makeV(1,2)})
test.equal(p.velocity().show().join() + p.acceleration().show().join(), '0,01,2')
p.simulate(0.1)
test.equal(p.velocity().show().join() + p.acceleration().show().join(), '0.1,0.21,2')
test.done()
}
exports.Body_CenterOfWeight = function(test) {
var o = new Thing()
var a1 = new Thing()
var a2 = new Thing()
var a3 = new Thing()
a3.set({density: 0})
o.addchild(a1)
o.addchild(a2)
test.done()
}