Skip to content

Instantly share code, notes, and snippets.

Folder: assembly/__tests__/
File: assembly/__tests__/as-pect.d.ts
File: assembly/__tests__/example.spec.ts
File: as-pect.config.js
@jtenner
jtenner / CanvasButton.js
Last active December 28, 2021 17:13
Canvas Button
var priorEvt;
function getMousePos(evt) {
priorEvt = evt = evt || priorEvt;
var rect = canvas.getBoundingClientRect();
if (evt)
return {
x: evt.clientX - rect.left,
y: evt.clientY - rect.top
};
// The entry file of your WebAssembly module.
class OnlyHasUnchecked {
length: i32 = 3;
@operator("{}")
protected __get(index: i32): i32 {
return index;
}
}

Keybase proof

I hereby claim:

  • I am jtenner on github.

  • I am devilmint (https://keybase.io/devilmint) on keybase.

  • I have a public key ASAd8zM4Uwfwh1TpXx0o5g-db62_yJOXSjstwI5i_Cw6Ywo

@jtenner
jtenner / init.sh
Last active November 20, 2019 15:40
npm install --save-dev assemblyscript @as-pect/cli
npx asinit .
npx asp --init
# To run your test suite
npx asp
(module
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$vdii (func (param f64 i32 i32)))
import { SetTransformOperation } from "../internal/operations/SetTransformOperation";
import { CanvasContext2DInstructionType } from "../../src/shared/CanvasContext2DInstructionType";
describe("SetTransformOperation", () => {
it("should write to a buffer", () => {
// Create an array buffer with the size of a SetTransformOperation
let buffer = new ArrayBuffer(offsetof<SetTransformOperation>());
// write to the buffer at index 0
let nextIndex = SetTransformOperation.write(buffer, 0, 1, 2, 3, 4, 5, 6);
class Vec3 {
x: f64;
y: f64;
z: f64;
}
const refPointer: usize = __alloc(5000);
const a = new Vec3();
const b = changetype<Vec3>(refPointer);
describe("A failing test", (): void => {
it("should fail", (): void => {
expect<bool>(false).toBeTruthy("Show this message, because we expect a falsy value to be truthy!");
});
});
class Vec3 {
constructor(
public x: f64,
public y: f64,
public z: f64,
) {}
}
let a = new Vec3(1.0, 2.0, 3.0);