update README.md in javascript
[liba.git] / javascript / test / trajbell.js
blobe49a2ad6673c9d7ac95fc69febf336059c680612
1 #!/usr/bin/env node
2 var liba = require("../liba");
3 function assert(expr) {
4 if (!eval(expr)) {
5 throw Error(expr);
8 function do_leak_check() {
9 for (const arg of arguments) {
10 arg.delete();
12 if (liba.do_leak_check) {
13 liba.do_leak_check();
16 var ctx = new liba.trajbell();
17 ctx.gen(3, 2, 3, 0, 10, 0, 0);
18 assert("ctx.t != undefined");
19 assert("ctx.tv != undefined");
20 assert("ctx.ta != undefined");
21 assert("ctx.td != undefined");
22 assert("ctx.taj != undefined");
23 assert("ctx.tdj != undefined");
24 assert("ctx.p0 != undefined");
25 assert("ctx.p1 != undefined");
26 assert("ctx.v0 != undefined");
27 assert("ctx.v1 != undefined");
28 assert("ctx.vm != undefined");
29 assert("ctx.jm != undefined");
30 assert("ctx.am != undefined");
31 assert("ctx.dm != undefined");
32 for (var i = 0; i < ctx.t; i += ctx.t / 10) {
33 console.log(i, ctx.pos(i), ctx.vel(i), ctx.acc(i), ctx.jer(i));
35 do_leak_check(ctx);