Repository: karen-irc/option-t
Pull request #1009 (2021-05-15 18:52:55)

Cleanup more


Patch:
diff --git a/docs/public_api_list.md b/docs/public_api_list.md
index ed7e1e16..410f6c70 100644
--- a/docs/public_api_list.md
+++ b/docs/public_api_list.md
@@ -14,7 +14,6 @@
 - [option-t/Maybe](../src/Maybe/index.ts)
 - [option-t/Maybe/and](../src/Maybe/and.ts)
 - [option-t/Maybe/andThen](../src/Maybe/andThen.ts)
-- [option-t/Maybe/andThenAsync](../src/Maybe/andThenAsync.ts)
 - [option-t/Maybe/expect](../src/Maybe/expect.ts)
 - [option-t/Maybe/map](../src/Maybe/map.ts)
 - [option-t/Maybe/mapAsync](../src/Maybe/mapAsync.ts)
diff --git a/src/Maybe/andThenAsync.ts b/src/Maybe/andThenAsync.ts
deleted file mode 100644
index 7e87bb9c..00000000
--- a/src/Maybe/andThenAsync.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { assertIsPromise } from '../internal/assert';
-import { ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE } from '../internal/ErrorMessage';
-import type { AsyncTransformFn } from '../internal/Function';
-
-import { Maybe, isNullOrUndefined } from './Maybe';
-
-export type MaybeAsyncTryTransformFn<T, U> = AsyncTransformFn<T, Maybe<U>>;
-
-/**
- *  Returns `null` or `undefined` if the _input_ is `null` or `undefined`,
- *  otherwise calls _transformer_ with the value and returns the result.
- *
- *  XXX:
- *  Some languages call this operation flatmap.
- *  But we don't provide `flatMap()` as alias of this function.
- *  because it's too hard to undarstand that "flatMap" operation for `T | null | undefined`.
- */
-export function andThenAsyncForMaybe<T, U>(
-    input: Maybe<T>,
-    transformer: MaybeAsyncTryTransformFn<T, U>
-): Promise<Maybe<U>> {
-    if (isNullOrUndefined(input)) {
-        return Promise.resolve(input);
-    }
-
-    const result: Promise<Maybe<U>> = transformer(input);
-
-    // If this is async function, this always return Promise, but not.
-    // We should check to clarify the error case if user call this function from plain js
-    // and they mistake to use this.
-    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-
-    return result;
-}
diff --git a/src/Maybe/index.ts b/src/Maybe/index.ts
index 1947b20d..5d3209a3 100644
--- a/src/Maybe/index.ts
+++ b/src/Maybe/index.ts
@@ -2,7 +2,6 @@ export { NotNullAndUndefined, Maybe, isNotNullAndUndefined, isNullOrUndefined }
 // XXX: `and()` operation is equivalent of `a && b` so we don't ship it by default set.
 //export { andForMaybe as and } from './and';
 export { andThenForMaybe as andThen } from './andThen';
-export { andThenAsyncForMaybe as andThenAsync } from './andThenAsync';
 export { expectNotNullAndUndefined as expect } from './expect';
 export { mapForMaybe as map } from './map';
 export { mapAsyncForMaybe as mapAsync } from './mapAsync';
diff --git a/src/Nullable/andThenAsync.ts b/src/Nullable/andThenAsync.ts
index d14f27ea..a1287beb 100644
--- a/src/Nullable/andThenAsync.ts
+++ b/src/Nullable/andThenAsync.ts
@@ -27,10 +27,10 @@ export function andThenAsyncForNullable<T, U>(
         return Promise.resolve<Nullable<U>>(input);
     }
 
-    const transformed: Promise<Nullable<U>> = transformer(input);
+    const result: Promise<Nullable<U>> = transformer(input);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    return transformed;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    return result;
 }
diff --git a/src/PlainOption/andThen.ts b/src/PlainOption/andThen.ts
index 075cc617..b72deb0b 100644
--- a/src/PlainOption/andThen.ts
+++ b/src/PlainOption/andThen.ts
@@ -25,6 +25,6 @@ export function andThenForOption<T, U>(
         return input;
     }
 
-    const transformed = transformer(input.val);
-    return transformed;
+    const result = transformer(input.val);
+    return result;
 }
diff --git a/src/PlainOption/map.ts b/src/PlainOption/map.ts
index 7d4e1b68..b6cfc03c 100644
--- a/src/PlainOption/map.ts
+++ b/src/PlainOption/map.ts
@@ -12,6 +12,6 @@ export function mapForOption<T, U>(input: Option<T>, transformer: TransformFn<T,
         return input;
     }
 
-    const transformed: U = transformer(input.val);
-    return createSome(transformed);
+    const result: U = transformer(input.val);
+    return createSome(result);
 }
diff --git a/src/PlainResult/andThen.ts b/src/PlainResult/andThen.ts
index 0dd9764b..3456e2de 100644
--- a/src/PlainResult/andThen.ts
+++ b/src/PlainResult/andThen.ts
@@ -25,6 +25,6 @@ export function andThenForResult<T, U, E>(
         return input;
     }
 
-    const transformed = transformer(input.val);
-    return transformed;
+    const result = transformer(input.val);
+    return result;
 }
diff --git a/src/PlainResult/andThenAsync.ts b/src/PlainResult/andThenAsync.ts
index 1a5f01a1..76873ae6 100644
--- a/src/PlainResult/andThenAsync.ts
+++ b/src/PlainResult/andThenAsync.ts
@@ -29,10 +29,10 @@ export function andThenAsyncForResult<T, U, E>(
     }
 
     const source: T = unwrapFromResult(input);
-    const transformed: Promise<Result<U, E>> = transformer(source);
+    const result: Promise<Result<U, E>> = transformer(source);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    return transformed;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    return result;
 }
diff --git a/src/PlainResult/map.ts b/src/PlainResult/map.ts
index 06a15f73..430d9dcf 100644
--- a/src/PlainResult/map.ts
+++ b/src/PlainResult/map.ts
@@ -15,6 +15,6 @@ export function mapForResult<T, U, E>(
         return input;
     }
 
-    const transformed: U = transformer(input.val);
-    return createOk(transformed);
+    const result: U = transformer(input.val);
+    return createOk(result);
 }
diff --git a/src/PlainResult/mapAsync.ts b/src/PlainResult/mapAsync.ts
index 2b13e45e..e31d4fe0 100644
--- a/src/PlainResult/mapAsync.ts
+++ b/src/PlainResult/mapAsync.ts
@@ -20,11 +20,11 @@ export function mapAsyncForResult<T, U, E>(
     }
 
     const inner: T = unwrapFromResult(input);
-    const transformed: Promise<U> = transformer(inner);
+    const result: Promise<U> = transformer(inner);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    const result: Promise<Result<U, E>> = transformed.then(createOk);
-    return result;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    const passed: Promise<Result<U, E>> = result.then(createOk);
+    return passed;
 }
diff --git a/src/PlainResult/mapErr.ts b/src/PlainResult/mapErr.ts
index 67d720f9..3ccc65b3 100644
--- a/src/PlainResult/mapErr.ts
+++ b/src/PlainResult/mapErr.ts
@@ -15,6 +15,6 @@ export function mapErrForResult<T, E, F>(
         return input;
     }
 
-    const transformed: F = transformer(input.err);
-    return createErr<F>(transformed);
+    const result: F = transformer(input.err);
+    return createErr<F>(result);
 }
diff --git a/src/PlainResult/mapErrAsync.ts b/src/PlainResult/mapErrAsync.ts
index 905de899..34063ecc 100644
--- a/src/PlainResult/mapErrAsync.ts
+++ b/src/PlainResult/mapErrAsync.ts
@@ -18,11 +18,11 @@ export function mapErrAsyncForResult<T, E, F>(
         return Promise.resolve(s);
     }
 
-    const transformed: Promise<F> = transformer(input.err);
+    const result: Promise<F> = transformer(input.err);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    const result: Promise<Result<T, F>> = transformed.then(createErr);
-    return result;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    const passed: Promise<Result<T, F>> = result.then(createErr);
+    return passed;
 }
diff --git a/src/PlainResult/mapOr.ts b/src/PlainResult/mapOr.ts
index 15e41df5..74ce8ccd 100644
--- a/src/PlainResult/mapOr.ts
+++ b/src/PlainResult/mapOr.ts
@@ -13,8 +13,8 @@ export function mapOrForResult<T, E, U>(
     transformer: TransformFn<T, U>
 ): U {
     if (input.ok) {
-        const transformed: U = transformer(input.val);
-        return transformed;
+        const result: U = transformer(input.val);
+        return result;
     }
 
     return defaultValue;
diff --git a/src/PlainResult/mapOrAsync.ts b/src/PlainResult/mapOrAsync.ts
index da9bff70..905efa45 100644
--- a/src/PlainResult/mapOrAsync.ts
+++ b/src/PlainResult/mapOrAsync.ts
@@ -21,10 +21,10 @@ export function mapOrAsyncForResult<T, E, U>(
     }
 
     const source: T = unwrapFromResult(input);
-    const transformed: Promise<U> = transformer(source);
+    const result: Promise<U> = transformer(source);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    return transformed;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    return result;
 }
diff --git a/src/PlainResult/mapOrElseAsync.ts b/src/PlainResult/mapOrElseAsync.ts
index e48374ff..4704b716 100644
--- a/src/PlainResult/mapOrElseAsync.ts
+++ b/src/PlainResult/mapOrElseAsync.ts
@@ -19,19 +19,19 @@ export function mapOrElseAsyncForResult<T, E, U>(
 ): Promise<U> {
     if (isOk(input)) {
         const inner: T = unwrapFromResult(input);
-        const transformed: Promise<U> = transformer(inner);
+        const result: Promise<U> = transformer(inner);
         // If this is async function, this always return Promise, but not.
         // We should check to clarify the error case if user call this function from plain js
         // and they mistake to use this.
-        assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-        return transformed;
+        assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+        return result;
     }
 
     const err: E = unwrapErrFromResult(input);
-    const defaultValue: Promise<U> = recoverer(err);
+    const fallback: Promise<U> = recoverer(err);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(defaultValue, ERR_MSG_RECOVERER_MUST_RETURN_PROMISE);
-    return defaultValue;
+    assertIsPromise(fallback, ERR_MSG_RECOVERER_MUST_RETURN_PROMISE);
+    return fallback;
 }
diff --git a/src/Undefinable/andThenAsync.ts b/src/Undefinable/andThenAsync.ts
index 6270ae1f..f6589cd4 100644
--- a/src/Undefinable/andThenAsync.ts
+++ b/src/Undefinable/andThenAsync.ts
@@ -23,10 +23,10 @@ export function andThenAsyncForUndefinable<T, U>(
         return Promise.resolve<Undefinable<U>>(input);
     }
 
-    const transformed: Promise<Undefinable<U>> = transformer(input);
+    const result: Promise<Undefinable<U>> = transformer(input);
     // If this is async function, this always return Promise, but not.
     // We should check to clarify the error case if user call this function from plain js
     // and they mistake to use this.
-    assertIsPromise(transformed, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
-    return transformed;
+    assertIsPromise(result, ERR_MSG_TRANSFORMER_MUST_RETURN_PROMISE);
+    return result;
 }
diff --git a/tools/pkg_files.json b/tools/pkg_files.json
index 8b5ac56b..1f7c81fc 100644
--- a/tools/pkg_files.json
+++ b/tools/pkg_files.json
@@ -59,8 +59,6 @@
     "cjs/Maybe/and.js": null,
     "cjs/Maybe/andThen.d.ts": null,
     "cjs/Maybe/andThen.js": null,
-    "cjs/Maybe/andThenAsync.d.ts": null,
-    "cjs/Maybe/andThenAsync.js": null,
     "cjs/Maybe/expect.d.ts": null,
     "cjs/Maybe/expect.js": null,
     "cjs/Maybe/index.d.ts": null,
@@ -347,8 +345,6 @@
     "esm/Maybe/and.mjs": null,
     "esm/Maybe/andThen.d.ts": null,
     "esm/Maybe/andThen.mjs": null,
-    "esm/Maybe/andThenAsync.d.ts": null,
-    "esm/Maybe/andThenAsync.mjs": null,
     "esm/Maybe/expect.d.ts": null,
     "esm/Maybe/expect.mjs": null,
     "esm/Maybe/index.d.ts": null,
@@ -659,9 +655,6 @@
     "lib/Maybe/andThen.d.ts": null,
     "lib/Maybe/andThen.js": null,
     "lib/Maybe/andThen.mjs": null,
-    "lib/Maybe/andThenAsync.d.ts": null,
-    "lib/Maybe/andThenAsync.js": null,
-    "lib/Maybe/andThenAsync.mjs": null,
     "lib/Maybe/expect.d.ts": null,
     "lib/Maybe/expect.js": null,
     "lib/Maybe/expect.mjs": null,
diff --git a/tools/public_api.mjs b/tools/public_api.mjs
index 3c953b6e..21ce5dda 100644
--- a/tools/public_api.mjs
+++ b/tools/public_api.mjs
@@ -10,7 +10,6 @@ export default {
             'isNotNullAndUndefined',
             'isNullOrUndefined',
             'andThen',
-            'andThenAsync',
             'expect',
             'map',
             'mapAsync',
@@ -33,11 +32,6 @@ export default {
             'andThenForMaybe'
         ]
     },
-    'Maybe/andThenAsync': {
-        'exports': [
-            'andThenAsyncForMaybe'
-        ]
-    },
     'Maybe/expect': {
         'exports': [
             'expectNotNullAndUndefined'


Test patch:
diff --git a/__tests__/Maybe/and_then.test.mjs b/__tests__/Maybe/and_then.test.mjs
index a8acc6bc..9b7b36b4 100644
--- a/__tests__/Maybe/and_then.test.mjs
+++ b/__tests__/Maybe/and_then.test.mjs
@@ -17,26 +17,16 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
-
-    const DEFAULT_VAL = Symbol('');
-    const result = andThenForMaybe(null, (_v) => {
-        t.fail('should not call selector fn');
-        return DEFAULT_VAL;
-    });
-
-    t.is(result, null);
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(1);
+
+        const DEFAULT_VAL = Symbol('');
+        const result = andThenForMaybe(NULL_VALUE, (_v) => {
+            t.fail('should not call selector fn');
+            return DEFAULT_VAL;
+        });
 
-    const DEFAULT_VAL = Symbol('');
-    const result = andThenForMaybe(undefined, (_v) => {
-        t.fail('should not call selector fn');
-        return DEFAULT_VAL;
+        t.is(result, NULL_VALUE);
     });
-
-    t.is(result, undefined);
-});
+}
diff --git a/__tests__/Maybe/and_then_async.test.mjs b/__tests__/Maybe/and_then_async.test.mjs
deleted file mode 100644
index 8e0242a6..00000000
--- a/__tests__/Maybe/and_then_async.test.mjs
+++ /dev/null
@@ -1,65 +0,0 @@
-import test from 'ava';
-
-import { andThenAsyncForMaybe } from '../../__dist/esm/Maybe/andThenAsync.mjs';
-import { nonNullableValue } from '../utils.mjs';
-
-const nonNullableValueCaseList = nonNullableValue.map((input) => {
-    if (input instanceof Promise) {
-        // Promise will be unwrap recursively automatically.
-        // There is no ways to unwrap single level now.
-        // So we need to care that.
-        return [input, input, 'this is promise'];
-    }
-
-    return [input, input, input];
-});
-
-for (const [INPUT, PASSED_EXPECTED, FINAL_EXPECTED] of nonNullableValueCaseList) {
-    test('pass the value: ' + String(INPUT), async (t) => {
-        t.plan(4);
-
-        const result = andThenAsyncForMaybe(INPUT, async (v) => {
-            t.pass('should call selector fn');
-            t.is(v, PASSED_EXPECTED);
-            return v;
-        });
-
-        t.true(result instanceof Promise, 'result should be Promise');
-
-        const actual = await result;
-        t.is(actual, FINAL_EXPECTED);
-    });
-}
-
-for (const NULL_VALUE of [undefined, null]) {
-    test(`pass ${NULL_VALUE}`, async (t) => {
-        t.plan(2);
-
-        const result = andThenAsyncForMaybe(NULL_VALUE, async (_v) => {
-            t.fail('should not call selector fn');
-            return Math.random();
-        });
-
-        t.true(result instanceof Promise, 'result should be Promise');
-        const actual = await result;
-        t.is(actual, NULL_VALUE);
-    });
-
-    test(`input is ${NULL_VALUE}, callback should return Promise`, async (t) => {
-        t.plan(2);
-
-        await t.throwsAsync(
-            async () => {
-                const input = Math.random();
-                await andThenAsyncForMaybe(input, (_input) => {
-                    t.pass('should be called');
-                    return 1;
-                });
-            },
-            {
-                instanceOf: TypeError,
-                message: '`transformer` must return Promise',
-            }
-        );
-    });
-}
diff --git a/__tests__/Maybe/expect.test.mjs b/__tests__/Maybe/expect.test.mjs
index 2909634f..a7c9fcd5 100644
--- a/__tests__/Maybe/expect.test.mjs
+++ b/__tests__/Maybe/expect.test.mjs
@@ -15,32 +15,19 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(1);
 
-    const EXPECTED_MSG = 'expected test';
-    t.throws(
-        () => {
-            expectNotNullAndUndefined(null, EXPECTED_MSG);
-        },
-        {
-            instanceOf: TypeError,
-            message: EXPECTED_MSG,
-        }
-    );
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
-
-    const EXPECTED_MSG = 'expected test';
-    t.throws(
-        () => {
-            expectNotNullAndUndefined(undefined, EXPECTED_MSG);
-        },
-        {
-            instanceOf: TypeError,
-            message: EXPECTED_MSG,
-        }
-    );
-});
+        const EXPECTED_MSG = 'expected test';
+        t.throws(
+            () => {
+                expectNotNullAndUndefined(NULL_VALUE, EXPECTED_MSG);
+            },
+            {
+                instanceOf: TypeError,
+                message: EXPECTED_MSG,
+            }
+        );
+    });
+}
diff --git a/__tests__/Maybe/map.test.mjs b/__tests__/Maybe/map.test.mjs
index c41fd950..0ac2a27e 100644
--- a/__tests__/Maybe/map.test.mjs
+++ b/__tests__/Maybe/map.test.mjs
@@ -18,21 +18,15 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
-    const result = mapForMaybe(null, (_v) => {
-        t.fail('should not call selector fn');
-    });
-    t.is(result, null);
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
-    const result = mapForMaybe(undefined, (_v) => {
-        t.fail('should not call selector fn');
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(1);
+        const result = mapForMaybe(NULL_VALUE, (_v) => {
+            t.fail('should not call selector fn');
+        });
+        t.is(result, NULL_VALUE);
     });
-    t.is(result, undefined);
-});
+}
 
 {
     const testcases = [
diff --git a/__tests__/Maybe/map_async.test.mjs b/__tests__/Maybe/map_async.test.mjs
index a402e7e6..06f60328 100644
--- a/__tests__/Maybe/map_async.test.mjs
+++ b/__tests__/Maybe/map_async.test.mjs
@@ -30,29 +30,19 @@ for (const [INPUT, PASSED_EXPECTED, FINAL_EXPECTED] of nonNullableValueCaseList)
     });
 }
 
-test('pass null', async (t) => {
-    t.plan(2);
-
-    const result = mapAsyncForMaybe(null, async (_v) => {
-        t.fail('should not call selector fn');
-    });
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, async (t) => {
+        t.plan(2);
 
-    t.true(result instanceof Promise, 'result should be Promise');
-    const actual = await result;
-    t.is(actual, null);
-});
-
-test('pass undefined', async (t) => {
-    t.plan(2);
+        const result = mapAsyncForMaybe(NULL_VALUE, async (_v) => {
+            t.fail('should not call selector fn');
+        });
 
-    const result = mapAsyncForMaybe(undefined, async (_v) => {
-        t.fail('should not call selector fn');
+        t.true(result instanceof Promise, 'result should be Promise');
+        const actual = await result;
+        t.is(actual, NULL_VALUE);
     });
-
-    t.true(result instanceof Promise, 'result should be Promise');
-    const actual = await result;
-    t.is(actual, undefined);
-});
+}
 
 {
     const testcases = [
diff --git a/__tests__/Maybe/map_or.test.mjs b/__tests__/Maybe/map_or.test.mjs
index 04babd51..803b78df 100644
--- a/__tests__/Maybe/map_or.test.mjs
+++ b/__tests__/Maybe/map_or.test.mjs
@@ -18,25 +18,17 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
-    const DEFAULE_VAL = Symbol('');
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(1);
+        const DEFAULE_VAL = Math.random();
 
-    const result = mapOrForMaybe(null, DEFAULE_VAL, (_v) => {
-        t.fail('should not call selector fn');
-    });
-    t.is(result, DEFAULE_VAL);
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
-    const DEFAULE_VAL = Symbol('');
-
-    const result = mapOrForMaybe(undefined, DEFAULE_VAL, (_v) => {
-        t.fail('should not call selector fn');
+        const result = mapOrForMaybe(NULL_VALUE, DEFAULE_VAL, (_v) => {
+            t.fail('should not call selector fn');
+        });
+        t.is(result, DEFAULE_VAL);
     });
-    t.is(result, DEFAULE_VAL);
-});
+}
 
 {
     const testcases = [
diff --git a/__tests__/Maybe/map_or_else.test.mjs b/__tests__/Maybe/map_or_else.test.mjs
index 34776631..cc3ba0e9 100644
--- a/__tests__/Maybe/map_or_else.test.mjs
+++ b/__tests__/Maybe/map_or_else.test.mjs
@@ -24,39 +24,27 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(2);
 
-    const DEFAULE_VAL = Symbol('');
-    const COMPUTED_VAL = Symbol('');
+        const DEFAULE_VAL = Symbol('default');
+        const COMPUTED_VAL = Symbol('computed');
 
-    const result = mapOrElseForMaybe(
-        null,
-        () => DEFAULE_VAL,
-        (_v) => {
-            t.fail('should not call selector fn');
-            return COMPUTED_VAL;
-        }
-    );
-    t.is(result, DEFAULE_VAL);
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
-
-    const DEFAULE_VAL = Symbol('');
-    const COMPUTED_VAL = Symbol('');
-
-    const result = mapOrElseForMaybe(
-        undefined,
-        () => DEFAULE_VAL,
-        (_v) => {
-            t.fail('should not call selector fn');
-            return COMPUTED_VAL;
-        }
-    );
-    t.is(result, DEFAULE_VAL);
-});
+        const result = mapOrElseForMaybe(
+            NULL_VALUE,
+            () => {
+                t.pass('should be called');
+                return DEFAULE_VAL;
+            },
+            (_v) => {
+                t.fail('should not call selector fn');
+                return COMPUTED_VAL;
+            }
+        );
+        t.is(result, DEFAULE_VAL);
+    });
+}
 
 {
     const testcases = [
diff --git a/__tests__/Maybe/or_else.test.mjs b/__tests__/Maybe/or_else.test.mjs
index 4cb55adb..7ee6029a 100644
--- a/__tests__/Maybe/or_else.test.mjs
+++ b/__tests__/Maybe/or_else.test.mjs
@@ -18,26 +18,16 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(2);
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(2);
 
-    const DEFAULT_VAL = Math.random();
-    const result = orElseForMaybe(null, () => {
-        t.pass('should call recover fn');
-        return DEFAULT_VAL;
-    });
-
-    t.is(result, DEFAULT_VAL);
-});
-
-test('pass undefined', (t) => {
-    t.plan(2);
+        const DEFAULT_VAL = Math.random();
+        const result = orElseForMaybe(NULL_VALUE, () => {
+            t.pass('should call recover fn');
+            return DEFAULT_VAL;
+        });
 
-    const DEFAULT_VAL = Math.random();
-    const result = orElseForMaybe(undefined, () => {
-        t.pass('should call recover fn');
-        return DEFAULT_VAL;
+        t.is(result, DEFAULT_VAL);
     });
-
-    t.is(result, DEFAULT_VAL);
-});
+}
diff --git a/__tests__/Maybe/tap.test.mjs b/__tests__/Maybe/tap.test.mjs
index be4d51ff..c45b1279 100644
--- a/__tests__/Maybe/tap.test.mjs
+++ b/__tests__/Maybe/tap.test.mjs
@@ -16,18 +16,12 @@ for (const input of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    const result = tapMaybe(null, (_v) => {
-        t.fail('should not call selector fn');
-    });
-
-    t.is(result, null);
-});
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        const result = tapMaybe(NULL_VALUE, (_v) => {
+            t.fail('should not call selector fn');
+        });
 
-test('pass undefined', (t) => {
-    const result = tapMaybe(undefined, (_v) => {
-        t.fail('should not call selector fn');
+        t.is(result, NULL_VALUE);
     });
-
-    t.is(result, undefined);
-});
+}
diff --git a/__tests__/Maybe/unwrap.test.mjs b/__tests__/Maybe/unwrap.test.mjs
index 4e41fe0a..64f22abc 100644
--- a/__tests__/Maybe/unwrap.test.mjs
+++ b/__tests__/Maybe/unwrap.test.mjs
@@ -18,24 +18,15 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(1);
-
-    t.throws(
-        () => {
-            unwrapMaybe(null);
-        },
-        { instanceOf: TypeError, message: 'called with `null` or `undefined`' }
-    );
-});
-
-test('pass undefined', (t) => {
-    t.plan(1);
-
-    t.throws(
-        () => {
-            unwrapMaybe(undefined);
-        },
-        { instanceOf: TypeError, message: 'called with `null` or `undefined`' }
-    );
-});
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(1);
+
+        t.throws(
+            () => {
+                unwrapMaybe(NULL_VALUE);
+            },
+            { instanceOf: TypeError, message: 'called with `null` or `undefined`' }
+        );
+    });
+}
diff --git a/__tests__/Maybe/unwrap_or.test.mjs b/__tests__/Maybe/unwrap_or.test.mjs
index 0af81646..5f266bd4 100644
--- a/__tests__/Maybe/unwrap_or.test.mjs
+++ b/__tests__/Maybe/unwrap_or.test.mjs
@@ -18,18 +18,14 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    const DEFAULT_VAL = Math.random();
-    const result = unwrapOrFromMaybe(null, DEFAULT_VAL);
-
-    t.is(result, DEFAULT_VAL);
-});
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        const DEFAULT_VAL = Math.random();
+        const result = unwrapOrFromMaybe(NULL_VALUE, DEFAULT_VAL);
 
-test('pass undefined', (t) => {
-    const DEFAULT_VAL = Math.random();
-    const result = unwrapOrFromMaybe(undefined, DEFAULT_VAL);
-    t.is(result, DEFAULT_VAL);
-});
+        t.is(result, DEFAULT_VAL);
+    });
+}
 
 {
     const testcases = [
diff --git a/__tests__/Maybe/unwrap_or_else.test.mjs b/__tests__/Maybe/unwrap_or_else.test.mjs
index 94963986..1083e976 100644
--- a/__tests__/Maybe/unwrap_or_else.test.mjs
+++ b/__tests__/Maybe/unwrap_or_else.test.mjs
@@ -22,29 +22,19 @@ for (const value of nonNullableValue) {
     });
 }
 
-test('pass null', (t) => {
-    t.plan(2);
-
-    const DEFAULT_VAL = Math.random();
-    const result = unwrapOrElseFromMaybe(null, () => {
-        t.pass('should call recover fn');
-        return DEFAULT_VAL;
-    });
-
-    t.is(result, DEFAULT_VAL);
-});
+for (const NULL_VALUE of [undefined, null]) {
+    test(`pass ${NULL_VALUE}`, (t) => {
+        t.plan(2);
 
-test('pass undefined', (t) => {
-    t.plan(2);
+        const DEFAULT_VAL = Math.random();
+        const result = unwrapOrElseFromMaybe(NULL_VALUE, () => {
+            t.pass('should call recover fn');
+            return DEFAULT_VAL;
+        });
 
-    const DEFAULT_VAL = Math.random();
-    const result = unwrapOrElseFromMaybe(null, () => {
-        t.pass('should call recover fn');
-        return DEFAULT_VAL;
+        t.is(result, DEFAULT_VAL);
     });
-
-    t.is(result, DEFAULT_VAL);
-});
+}
 
 {
     const testcases = [