Files
wupengyong a655816f89 Signed-off-by: wupengyong <wupengyong@huawei.com>
Change-Id: Icc8727a8fbc4a6c4935a79eb2f09dd071a236b35

Change-Id: I7608f6237968bea69d980ebbee6d3032aaf7378a
2021-08-18 17:29:31 +08:00

41 lines
718 B
JavaScript

/* example of JS module importing a C module */
import { Point } from "./point.so";
function assert(b, str)
{
if (b) {
return;
} else {
throw Error("assertion failed: " + str);
}
}
class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
get_color() {
return this.color;
}
};
function main()
{
var pt, pt2;
pt = new Point(2, 3);
assert(pt.x === 2);
assert(pt.y === 3);
pt.x = 4;
assert(pt.x === 4);
assert(pt.norm() == 5);
pt2 = new ColorPoint(2, 3, 0xffffff);
assert(pt2.x === 2);
assert(pt2.color === 0xffffff);
assert(pt2.get_color() === 0xffffff);
}
main();