Skip to content

Instantly share code, notes, and snippets.

jtenner

Block or report user

Report or block jtenner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View output.wat
(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)))
View SetTransformOperation.spec.ts
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);
View changetype.ts
class Vec3 {
x: f64;
y: f64;
z: f64;
}
const refPointer: usize = __alloc(5000);
const a = new Vec3();
const b = changetype<Vec3>(refPointer);
View gist:6c7f7f2fef758f697f363990dc6cb5bc
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!");
});
});
View toStrictEqual.spec.ts
class Vec3 {
constructor(
public x: f64,
public y: f64,
public z: f64,
) {}
}
let a = new Vec3(1.0, 2.0, 3.0);
View not.spec.ts
describe("not", (): void => {
it("should not be -1", (): void => {
expect<i32>(42).not.toBe(-1, "42 is not -1");
});
});
View toBe.spec.ts
class Vec3 {
x: f64 = 0;
y: f64 = 0;
z: f64 = 0;
}
describe("Vec3", (): void => {
it("should add up", (): void => {
expect<i32>(19 + 23).toBe(42);
});
View log.spec.ts
class Bar {}
describe("Foo", (): void => {
log<string>("Some string value");
log<i32>(42); // all number types are supported
log<Bar>(new Bar()); // displays the raw bytes in the console
log<Bar>(null); // null reference
});
View todo.spec.ts
describe("Foo", (): void => {
todo("Test #bar");
});
View Foo.divide.spec.ts
let myFoo = new Foo();
describe("Foo.divide()", (): void => {
it("should throw when dividing by zero", (): void => {
expectFn((): void => { myFoo.divide(42, 0); })
.toThrow("Dividing by zero should throw an error.");
});
});
You can’t perform that action at this time.