diff --git a/tests/src/tests/Option.spec.ts b/tests/src/tests/Option.spec.ts
index 1dfece3..6f6bcf8 100644
--- a/tests/src/tests/Option.spec.ts
+++ b/tests/src/tests/Option.spec.ts
@@ -1,6 +1,6 @@
///
-import { Option, Result, Vec } from "@rbxts/rust-classes";
+import { Option, Result, unit, Vec } from "@rbxts/rust-classes";
export = () => {
it("Option.__tostring", () => {
@@ -66,6 +66,19 @@ export = () => {
expect(Option.some(1).map((i) => ++i)).to.equal(Option.some(2));
expect(Option.none().map((i) => ++i)).to.equal(Option.none());
});
+ it("Option.inspect", () => {
+ let calledSome = 0;
+ let calledNone = 0;
+ Option.some(unit()).inspect((v) => {
+ expect(v).to.equal(unit());
+ calledSome++;
+ });
+ Option.none().inspect(() => {
+ calledNone++;
+ });
+ expect(calledSome).to.equal(1);
+ expect(calledNone).to.equal(0);
+ });
it("Option.mapOr", () => {
expect(Option.some(1).mapOr(0, (i) => ++i)).to.equal(2);
expect(Option.none().mapOr(0, (i) => ++i)).to.equal(0);
diff --git a/tests/src/tests/Result.spec.ts b/tests/src/tests/Result.spec.ts
index 48fc26b..450519a 100644
--- a/tests/src/tests/Result.spec.ts
+++ b/tests/src/tests/Result.spec.ts
@@ -118,6 +118,32 @@ export = () => {
expect(Result.err(1).mapErr((i) => ++i)).to.equal(Result.err(2));
expect(Result.ok(1).mapErr(() => error("Should not run"))).to.equal(Result.ok(1));
});
+ it("Result.inspect", () => {
+ let calledOk = 0;
+ let calledErr = 0;
+ Result.ok(unit()).inspect((v) => {
+ expect(v).to.equal(unit());
+ calledOk++;
+ });
+ Result.err(unit()).inspect(() => {
+ calledErr++;
+ });
+ expect(calledOk).to.equal(1);
+ expect(calledErr).to.equal(0);
+ });
+ it("Result.inspectErr", () => {
+ let calledOk = 0;
+ let calledErr = 0;
+ Result.ok(unit()).inspectErr(() => {
+ calledOk++;
+ });
+ Result.err(unit()).inspectErr((v) => {
+ expect(v).to.equal(unit());
+ calledErr++;
+ });
+ expect(calledOk).to.equal(0);
+ expect(calledErr).to.equal(1);
+ });
it("Result.and", () => {
expect(Result.ok(1).and(Result.ok(2))).to.equal(Result.ok(2));
expect(Result.err(1).and(Result.ok(2))).to.equal(Result.err(1));