Repository: dubzzz/fast-check
Pull request #1779 (2021-04-21 18:16:35)

🚚 Move mixedCase arbitrary into /arbitrary
<!-- Why is this PR for? -->
<!-- Describe the reason why you opened this PR or give a link towards the associated issue. -->

## In a nutshell

❌ New feature
❌ Fix an issue
❌ Documentation improvement
✔️ Other: *moving code*

(✔️: yes, ❌: no)

## Potential impacts

Not expected


codesandbox[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/dubzzz/fast-check/pr/1779/builds/122140) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a1217fab9d71f9e8b0fc0189d404ed8789ea00a7:

|Sandbox| Source |
|--|--|
|[Vanilla](https://codesandbox.io/s/vanilla-gloqi)| Configuration |
|[fast-check-examples](https://codesandbox.io/s/fast-check-examples-jx0e7)| Configuration |

codecov[bot]: # [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) Report
> Merging [#1779](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (a1217fa) into [main](https://codecov.io/gh/dubzzz/fast-check/commit/4af2be53472ba2200af17a2fa17ef082b10585d9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (4af2be5) will **increase** coverage by `0.00%`.
> The diff coverage is `94.11%`.

[![Impacted file tree graph](https://codecov.io/gh/dubzzz/fast-check/pull/1779/graphs/tree.svg?width=650&height=150&src=pr&token=fRi2fJN730&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)

```diff
@@           Coverage Diff           @@
##             main    #1779   +/-   ##
=======================================
  Coverage   96.62%   96.63%           
=======================================
  Files         117      118    +1     
  Lines        3647     3650    +3     
  Branches      716      716           
=======================================
+ Hits         3524     3527    +3     
  Misses        119      119           
  Partials        4        4           
```

| Flag | Coverage Δ | |
|---|---|---|
| unit-tests | `96.63% <94.11%> (+<0.01%)` | :arrow_up: |
| unit-tests-10.x-Linux | `96.63% <94.11%> (+<0.01%)` | :arrow_up: |
| unit-tests-12.x-Linux | `?` | |
| unit-tests-14.x-Linux | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | Coverage Δ | |
|---|---|---|
| [src/arbitrary/mixedCase.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1779/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9taXhlZENhc2UudHM=) | `90.90% <90.90%> (ø)` | |
| [src/arbitrary/\_internals/MixedCaseArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1779/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9faW50ZXJuYWxzL01peGVkQ2FzZUFyYml0cmFyeS50cw==) | `89.70% <100.00%> (ø)` | |
| [src/fast-check-default.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1779/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2Zhc3QtY2hlY2stZGVmYXVsdC50cw==) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Last update [4af2be5...a1217fa](https://codecov.io/gh/dubzzz/fast-check/pull/1779?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).


Patch:
diff --git a/src/check/arbitrary/MixedCaseArbitrary.ts b/src/arbitrary/_internals/MixedCaseArbitrary.ts
similarity index 75%
rename from src/check/arbitrary/MixedCaseArbitrary.ts
rename to src/arbitrary/_internals/MixedCaseArbitrary.ts
index 60f5a5f5..b81a7777 100644
--- a/src/check/arbitrary/MixedCaseArbitrary.ts
+++ b/src/arbitrary/_internals/MixedCaseArbitrary.ts
@@ -1,25 +1,11 @@
 import { Random } from '../../random/generator/Random';
 import { Stream } from '../../stream/Stream';
-import { bigUintN } from '../../arbitrary/bigUintN';
-import { Arbitrary } from './definition/Arbitrary';
-import { NextArbitrary } from './definition/NextArbitrary';
-import { convertFromNext, convertToNext } from './definition/Converters';
-import { NextValue } from './definition/NextValue';
+import { bigUintN } from '../bigUintN';
+import { NextArbitrary } from '../../check/arbitrary/definition/NextArbitrary';
+import { convertToNext } from '../../check/arbitrary/definition/Converters';
+import { NextValue } from '../../check/arbitrary/definition/NextValue';
 import { makeLazy } from '../../stream/LazyIterableIterator';
 
-/**
- * Constraints to be applied on {@link mixedCase}
- * @remarks Since 1.17.0
- * @public
- */
-export interface MixedCaseConstraints {
-  /**
-   * Transform a character to its upper and/or lower case version
-   * @remarks Since 1.17.0
-   */
-  toggleCase?: (rawChar: string) => string;
-}
-
 /** @internal */
 export function countToggledBits(n: bigint): number {
   let count = 0;
@@ -57,7 +43,7 @@ type MixedCaseArbitraryContext = {
 };
 
 /** @internal */
-class MixedCaseArbitrary extends NextArbitrary<string> {
+export class MixedCaseArbitrary extends NextArbitrary<string> {
   constructor(
     private readonly stringArb: NextArbitrary<string>,
     private readonly toggleCase: (rawChar: string) => string
@@ -156,31 +142,3 @@ class MixedCaseArbitrary extends NextArbitrary<string> {
       );
   }
 }
-
-/** @internal */
-function defaultToggleCase(rawChar: string) {
-  const upper = rawChar.toUpperCase();
-  if (upper !== rawChar) return upper;
-  return rawChar.toLowerCase();
-}
-
-/**
- * Randomly switch the case of characters generated by `stringArb` (upper/lower)
- *
- * WARNING:
- * Require bigint support.
- * Under-the-hood the arbitrary relies on bigint to compute the flags that should be toggled or not.
- *
- * @param stringArb - Arbitrary able to build string values
- * @param constraints - Constraints to be applied when computing upper/lower case version
- *
- * @remarks Since 1.17.0
- * @public
- */
-export function mixedCase(stringArb: Arbitrary<string>, constraints?: MixedCaseConstraints): Arbitrary<string> {
-  if (typeof BigInt === 'undefined') {
-    throw new Error(`mixedCase requires BigInt support`);
-  }
-  const toggleCase = (constraints && constraints.toggleCase) || defaultToggleCase;
-  return convertFromNext(new MixedCaseArbitrary(convertToNext(stringArb), toggleCase));
-}
diff --git a/src/arbitrary/mixedCase.ts b/src/arbitrary/mixedCase.ts
new file mode 100644
index 00000000..295919e5
--- /dev/null
+++ b/src/arbitrary/mixedCase.ts
@@ -0,0 +1,44 @@
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { convertFromNext, convertToNext } from '../check/arbitrary/definition/Converters';
+import { MixedCaseArbitrary } from './_internals/MixedCaseArbitrary';
+
+/**
+ * Constraints to be applied on {@link mixedCase}
+ * @remarks Since 1.17.0
+ * @public
+ */
+export interface MixedCaseConstraints {
+  /**
+   * Transform a character to its upper and/or lower case version
+   * @remarks Since 1.17.0
+   */
+  toggleCase?: (rawChar: string) => string;
+}
+
+/** @internal */
+function defaultToggleCase(rawChar: string) {
+  const upper = rawChar.toUpperCase();
+  if (upper !== rawChar) return upper;
+  return rawChar.toLowerCase();
+}
+
+/**
+ * Randomly switch the case of characters generated by `stringArb` (upper/lower)
+ *
+ * WARNING:
+ * Require bigint support.
+ * Under-the-hood the arbitrary relies on bigint to compute the flags that should be toggled or not.
+ *
+ * @param stringArb - Arbitrary able to build string values
+ * @param constraints - Constraints to be applied when computing upper/lower case version
+ *
+ * @remarks Since 1.17.0
+ * @public
+ */
+export function mixedCase(stringArb: Arbitrary<string>, constraints?: MixedCaseConstraints): Arbitrary<string> {
+  if (typeof BigInt === 'undefined') {
+    throw new Error(`mixedCase requires BigInt support`);
+  }
+  const toggleCase = (constraints && constraints.toggleCase) || defaultToggleCase;
+  return convertFromNext(new MixedCaseArbitrary(convertToNext(stringArb), toggleCase));
+}
diff --git a/src/fast-check-default.ts b/src/fast-check-default.ts
index dfefbfaf..7ed613f4 100644
--- a/src/fast-check-default.ts
+++ b/src/fast-check-default.ts
@@ -51,7 +51,7 @@ import { letrec } from './arbitrary/letrec';
 import { lorem, LoremConstraints } from './check/arbitrary/LoremArbitrary';
 import { mapToConstant } from './check/arbitrary/MapToConstantArbitrary';
 import { memo, Memo } from './arbitrary/memo';
-import { mixedCase, MixedCaseConstraints } from './check/arbitrary/MixedCaseArbitrary';
+import { mixedCase, MixedCaseConstraints } from './arbitrary/mixedCase';
 import {
   anything,
   json,


Test patch:
diff --git a/test/unit/check/arbitrary/MixedCaseArbitrary.itest.spec.ts b/test/unit/arbitrary/MixedCaseArbitrary.itest.spec.ts
similarity index 70%
rename from test/unit/check/arbitrary/MixedCaseArbitrary.itest.spec.ts
rename to test/unit/arbitrary/MixedCaseArbitrary.itest.spec.ts
index ce2a093c..596a5ab0 100644
--- a/test/unit/check/arbitrary/MixedCaseArbitrary.itest.spec.ts
+++ b/test/unit/arbitrary/MixedCaseArbitrary.itest.spec.ts
@@ -1,8 +1,8 @@
-import { nat } from '../../../../src/arbitrary/nat';
-import { stringOf } from '../../../../src/check/arbitrary/StringArbitrary';
-import { mixedCase } from '../../../../src/check/arbitrary/MixedCaseArbitrary';
+import { nat } from '../../../src/arbitrary/nat';
+import { stringOf } from '../../../src/check/arbitrary/StringArbitrary';
+import { mixedCase } from '../../../src/arbitrary/mixedCase';
 
-import * as genericHelper from './generic/GenericArbitraryHelper';
+import * as genericHelper from '../check/arbitrary/generic/GenericArbitraryHelper';
 
 declare function BigInt(n: number | bigint | string): bigint;
 
diff --git a/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts b/test/unit/arbitrary/MixedCaseArbitrary.utest.spec.ts
similarity index 92%
rename from test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts
rename to test/unit/arbitrary/MixedCaseArbitrary.utest.spec.ts
index ddce5a9e..93f244b3 100644
--- a/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts
+++ b/test/unit/arbitrary/MixedCaseArbitrary.utest.spec.ts
@@ -1,12 +1,13 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { mixedCase, countToggledBits, computeNextFlags } from '../../../../src/check/arbitrary/MixedCaseArbitrary';
+import { mixedCase } from '../../../src/arbitrary/mixedCase';
+import { countToggledBits, computeNextFlags } from '../../../src/arbitrary/_internals/MixedCaseArbitrary';
 
-jest.mock('../../../../src/arbitrary/bigUintN');
-import * as BigUintNMock from '../../../../src/arbitrary/bigUintN';
-import * as stubRng from '../../stubs/generators';
+jest.mock('../../../src/arbitrary/bigUintN');
+import * as BigUintNMock from '../../../src/arbitrary/bigUintN';
+import * as stubRng from '../stubs/generators';
 import { mocked } from 'ts-jest/utils';
-import { arbitraryFor } from './generic/ArbitraryBuilder';
+import { arbitraryFor } from '../check/arbitrary/generic/ArbitraryBuilder';
 
 const mrng = () => stubRng.mutable.nocall();