From 50394c87b591f3ede0bb076581f8fbf93c3844e4 Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Wed, 22 May 2024 20:22:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20option=20to=20generate=20unic?= =?UTF-8?q?ode=20values=20in=20`object`=20(#5010)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** Recent bugs found in Vitest around badly formed snapshot names would have benefit from having a built-in way to switch on unicode generation on `object` and `anything`. The proposed PR adds a new flag onto them. It allows users to force generation of unicode strings as keys and values of the instances produced by these two helpers. The flag is called `withUnicodeString`. **Checklist** — _Don't delete this checklist and make sure you do the following before opening the PR_ - [x] The name of my PR follows [gitmoji](https://gitmoji.dev/) specification - [x] My PR references one of several related issues (if any) - [x] New features or breaking changes must come with an associated Issue or Discussion - [x] My PR does not add any new dependency without an associated Issue or Discussion - [x] My PR includes bumps details, please run `yarn bump` and flag the impacts properly - [x] My PR adds relevant tests and they would have failed without my PR (when applicable) **Advanced** - [x] Category: ✨ Introduce new features - [x] Impacts: N.A. --- .yarn/versions/62e8ed33.yml | 8 ++++++ .../helpers/QualifiedObjectConstraints.ts | 27 ++++++++++++++---- .../test/e2e/GenerateAllValues.spec.ts | 1 + .../builders/AnyArbitraryBuilder.spec.ts | 11 +++++++- .../test/unit/utils/stringify.spec.ts | 3 +- .../arbitraries/composites/object.md | 28 +++++++++++-------- 6 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 .yarn/versions/62e8ed33.yml diff --git a/.yarn/versions/62e8ed33.yml b/.yarn/versions/62e8ed33.yml new file mode 100644 index 00000000000..a9650bcd747 --- /dev/null +++ b/.yarn/versions/62e8ed33.yml @@ -0,0 +1,8 @@ +releases: + fast-check: minor + +declined: + - "@fast-check/ava" + - "@fast-check/jest" + - "@fast-check/vitest" + - "@fast-check/worker" diff --git a/packages/fast-check/src/arbitrary/_internals/helpers/QualifiedObjectConstraints.ts b/packages/fast-check/src/arbitrary/_internals/helpers/QualifiedObjectConstraints.ts index ac341faf9b3..7c877953d12 100644 --- a/packages/fast-check/src/arbitrary/_internals/helpers/QualifiedObjectConstraints.ts +++ b/packages/fast-check/src/arbitrary/_internals/helpers/QualifiedObjectConstraints.ts @@ -2,6 +2,7 @@ import type { Arbitrary } from '../../../check/arbitrary/definition/Arbitrary'; import { boolean } from '../../boolean'; import { constant } from '../../constant'; import { double } from '../../double'; +import { fullUnicodeString } from '../../fullUnicodeString'; import { maxSafeInteger } from '../../maxSafeInteger'; import { oneof } from '../../oneof'; import { string } from '../../string'; @@ -103,6 +104,13 @@ export interface ObjectConstraints { * @remarks Since 2.13.0 */ withSparseArray?: boolean; + /** + * Replace the arbitrary of strings defaulted for key and values by one able to generate unicode strings with non-ascii characters. + * If you override key and/or values constraint, this flag will not apply to your override. + * @defaultValue false + * @remarks Since 3.19.0 + */ + withUnicodeString?: boolean; } /** @internal */ @@ -113,18 +121,24 @@ type ObjectConstraintsOptionalValues = 'depthSize' | 'maxDepth' | 'maxKeys' | 's * @internal */ export type QualifiedObjectConstraints = Required< - Omit + Omit > & Pick; /** @internal */ -function defaultValues(constraints: { size: SizeForArbitrary }): Arbitrary[] { +type DefaultValuesConstraints = { size: SizeForArbitrary }; + +/** @internal */ +function defaultValues( + constraints: DefaultValuesConstraints, + stringArbitrary: (constraints: DefaultValuesConstraints) => Arbitrary, +): Arbitrary[] { return [ boolean(), maxSafeInteger(), double(), - string(constraints), - oneof(string(constraints), constant(null), constant(undefined)), + stringArbitrary(constraints), + oneof(stringArbitrary(constraints), constant(null), constant(undefined)), ]; } @@ -146,11 +160,12 @@ export function toQualifiedObjectConstraints(settings: ObjectConstraints = {}): function orDefault(optionalValue: T | undefined, defaultValue: T): T { return optionalValue !== undefined ? optionalValue : defaultValue; } + const stringArbitrary = settings.withUnicodeString ? fullUnicodeString : string; const valueConstraints = { size: settings.size }; return { - key: orDefault(settings.key, string(valueConstraints)), + key: orDefault(settings.key, stringArbitrary(valueConstraints)), values: boxArbitrariesIfNeeded( - orDefault(settings.values, defaultValues(valueConstraints)), + orDefault(settings.values, defaultValues(valueConstraints, stringArbitrary)), orDefault(settings.withBoxedValues, false), ), depthSize: settings.depthSize, diff --git a/packages/fast-check/test/e2e/GenerateAllValues.spec.ts b/packages/fast-check/test/e2e/GenerateAllValues.spec.ts index 1ae67d3790c..d16c5b61d85 100644 --- a/packages/fast-check/test/e2e/GenerateAllValues.spec.ts +++ b/packages/fast-check/test/e2e/GenerateAllValues.spec.ts @@ -75,6 +75,7 @@ describe(`Generate all values (seed: ${seed})`, () => { withDate: true, withTypedArray: true, withSparseArray: true, + withUnicodeString: true, ...(typeof BigInt !== 'undefined' ? { withBigInt: true } : {}), }); while (++numTries <= 10000) { diff --git a/packages/fast-check/test/unit/arbitrary/_internals/builders/AnyArbitraryBuilder.spec.ts b/packages/fast-check/test/unit/arbitrary/_internals/builders/AnyArbitraryBuilder.spec.ts index 0c1889c6ba5..ec103a7c28a 100644 --- a/packages/fast-check/test/unit/arbitrary/_internals/builders/AnyArbitraryBuilder.spec.ts +++ b/packages/fast-check/test/unit/arbitrary/_internals/builders/AnyArbitraryBuilder.spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import fc from 'fast-check'; +import fc, { stringify } from 'fast-check'; import { anyArbitraryBuilder } from '../../../../../src/arbitrary/_internals/builders/AnyArbitraryBuilder'; import type { ObjectConstraints } from '../../../../../src/arbitrary/_internals/helpers/QualifiedObjectConstraints'; @@ -102,6 +102,7 @@ describe('anyArbitraryBuilder (integration)', () => { withSet: fc.boolean(), withSparseArray: fc.boolean(), withTypedArray: fc.boolean(), + withUnicodeString: fc.boolean(), }, { requiredKeys: [] }, ) @@ -148,6 +149,9 @@ describe('anyArbitraryBuilder (integration)', () => { if (!extra.withTypedArray) { expect(isTypedArray(v)).toBe(false); } + if (!extra.withUnicodeString) { + expect(stringify(v)).toSatisfy(doesNotIncludeAnySurrogateCharacter); + } // No check for !extra.withObjectString as nothing prevent normal string builders to build such strings // In the coming major releases withObjectString might even disappear }; @@ -174,6 +178,11 @@ describe('anyArbitraryBuilder (integration)', () => { // Helpers +function doesNotIncludeAnySurrogateCharacter(s: string): boolean { + // No character is a part of a surrogate pair + return s.split('').every((c) => c < '\uD800' || c > '\uDFFF'); +} + function isBigInt(v: unknown): boolean { return typeof v === 'bigint'; } diff --git a/packages/fast-check/test/unit/utils/stringify.spec.ts b/packages/fast-check/test/unit/utils/stringify.spec.ts index 8de04ab9634..1577f1a6a81 100644 --- a/packages/fast-check/test/unit/utils/stringify.spec.ts +++ b/packages/fast-check/test/unit/utils/stringify.spec.ts @@ -37,7 +37,7 @@ class CustomTagThrowingToString { } } -const anythingEnableAll = { +const anythingEnableAll: fc.ObjectConstraints = { withBoxedValues: true, withMap: true, withSet: true, @@ -46,6 +46,7 @@ const anythingEnableAll = { withDate: true, withTypedArray: true, withSparseArray: true, + withUnicodeString: true, ...(typeof BigInt !== 'undefined' ? { withBigInt: true } : {}), }; diff --git a/website/docs/core-blocks/arbitraries/composites/object.md b/website/docs/core-blocks/arbitraries/composites/object.md index 4ecfadf2435..01c5cff4a45 100644 --- a/website/docs/core-blocks/arbitraries/composites/object.md +++ b/website/docs/core-blocks/arbitraries/composites/object.md @@ -165,7 +165,7 @@ Generate objects (key/values). **Signatures:** - `fc.object()` -- `fc.object({key?, depthSize?, maxDepth?, maxKeys?, size?, withBigInt?, withBoxedValues?, withDate?, withMap?, withNullPrototype?, withObjectString?, withSet?, withTypedArray?, values?})` +- `fc.object({key?, depthSize?, maxDepth?, maxKeys?, size?, withBigInt?, withBoxedValues?, withDate?, withMap?, withNullPrototype?, withObjectString?, withSet?, withTypedArray?, withSparseArray?, withUnicodeString?, values?})` **with:** @@ -182,6 +182,8 @@ Generate objects (key/values). - `withObjectString?` — default: `false` — _enable strings looking as string representations of JavaScript instances - eg.: `"{}"`, `"new Set([1])"`_ - `withSet?` — default: `false` — _enable `Set` - eg.: `new Set([1, 2, 3])`_ - `withTypedArray?` — default: `false` — _enable typed arrays for ints, uints and floats - eg.: `Int8Array.from([1, 2, 3])`_ +- `withSparseArray?` — default: `false` — _enable sparse arrays - eg.: `[1,,,3]`_ +- `withUnicodeString?` — default: `false` — _change the default for `key` and `values` so that they produce unicode strings with non-ascii characters_ - `values?` — default: _booleans, numbers, strings, null and undefined_ — _array of arbitraries producing the root* values - *non-object ones_ **Usages:** @@ -239,13 +241,15 @@ fc.object({ withObjectString: true, withSet: true, withTypedArray: true, + withSparseArray: true, + withUnicodeString: true, }); // Examples of generated values: // • {} -// • {"!}~":{"9&*>":9494705766050126970059458547134765572232472890999989593960442554603045184030n,"36196779627093044303215052719752706352981292536045008449906200395046789418178n":true,"__:^bAM'":new Boolean(true),"u k%":1596443377842537,"new Number(-7049375787334476)":new Number(7.470701818813003e+220),"<":"PW#NZ]>__$","?,f+":30002898913267044193974323334546082038810289464813171141565449175457493043927n,"vj`:X\\a":new Date("+046542-01-18T09:38:40.580Z")},"N$":Uint8Array.from([194,106,58,62,115,212,177,55,196]),"x":{".I&N":false,"as":32401686191943328701373790805636534760611537151552234790087877880448748089108n,"x":new Map([[false,-7406733250570661812141992739047378682862933477383691956802999676905441418611n],[undefined,new Set(["Jwf !j7F4f",new Number(-5372309718894610),"-6724167660149972",-1.9948743032786002e-277])],[new Boolean(false),Object.assign(Object.create(null),{"%1g`":true,")QsA":new Date("+255151-05-07T04:49:18.548Z"),"=KL":undefined,"68gc/{U":undefined,"~(>G@7G":new String("i*IT@x16")})],["X|-lm`","o_KVZ"]]),"k% D-$y":undefined}} -// • {"6":{"Y7MR0U]5q":new Set([new Boolean(false),5.140011582069296e-68,null,3.17393404674175e-299,new String("~b2+K,L"),34112792392140757735808259705664111791041643531782909535770237858684045298587n,3894376903563633,new Boolean(true),new Number(1.543040772123217e-149)])},"~OSo:":[{".+,":new Boolean(false),"'9uoS":"TzFF;2`o7y","is>Sh":"L4_5KAGVf","#}[(":null,"@+b4A{:":new Number(-9.605721374229465e-150),"6[C":6409654348829291,"UvM+6>Wp":new Number(6.944713497662369e-35),"9H`=yg+rA<":8711584371832775,"":false},[null,new String(":/:4=<&ty1"),new Boolean(true),undefined,new Number(6858384934457673),"\"H72Hg{WFqX\"",38]],"C":Object.assign(Object.create(null),{"NLm":"8023815702534817"}),"":Int8Array.from([-86,-28,74,-25,79,-86,51,78,13,-56]),"tkpIncs":"\"null\""," \"p;,\"":new Set([Object.assign(Object.create(null),{"g_uQ;":[new Number(2667295261136719),new Map([[-1.0669097125271472e+264,new Number(1.0618252726663204e+65)],[new Number(8654070824677589),null],[3159424422455611,new String(" ")],[new Number(1158494439593465),5700000001244861],[-29042696710262469346962418539718822780439690717113028500860986284724661139269n,new Boolean(false)],[new Number(-6848593877876571),new String("oTpL5~se,@")],[new Number(-5.919717713853319e+138),"N`#DfMj:m"],[new String("4.t.\\sy8."),new Boolean(true)]])],"=z":"new Boolean(false)","^N I?g:YW":null})])," %":new Map([[-2.6e-322,""],[-1.5e-323,new Boolean(false)],[8327751921859515,new Number(1.7976931348623135e+308)],[Uint8Array.from([251]),false],[new Boolean(true),new Boolean(true)],[4.802419269746338e+179,[1.7976931348623151e+308]],[new Number(-3192953574037226),-1.0406846166032024e-112]])} -// • {"m":Object.assign(Object.create(null),{"GdKtb5":undefined,"":new Boolean(true),"D0!MW%a,U?":4176690198074207,"\\":5.564651422369171e+236,"^\\Gf>s":-1.1954513864585612e+266,"m};\"h":"5->","\"\\\"[JOf^7c\\\\\\\\\\\"\"":new String("#\\h-S|6"),"+*q2E,zx|":"Ve2P@nw","QU81JO":new String("|x}.YY")}),"8#3AOzyS(>":new String("8!G"),"":-2.1615999946830344e+292,"OroZ]J":{"0VDF\"t":new Date("-182412-10-23T22:25:42.883Z"),"4*Y0{^":new Map([["RXjxH7*+m}",new Number(-7159956608542526)],["($",false],["B':\\",false],["(",new Boolean(false)],["^jy,f8:s":"\"\"","Oryb(&xIAc":new Number(-7241425187310123),"@jrh*F":[null,new String("1WA3-Q.dfh"),1.1499097510701588e+108,null,new Boolean(false),new Number(3.1953519717235633e+159),{"oAa)al":[new String("<;Y@89&")],"^":new Number(2.2068933757652113e-250),"":2505140018000971},-4987526382048941,new Boolean(true),new Boolean(false)],"wc":new Map([[new Set([undefined,-27145322609286573418141121110338331814276874986634281531336096736878349004657n]),new Number(5.594206087802421e+269)]])} -// • {"K]+.i1?8":Object.assign(Object.create(null),{"":new String("gn5>okAG"),"Z":new Number(-2.8857611508988743e+276),"6{;":new Number(8248181823478789),"o\"u":"$@ ","}":"aMbtvs7C=/","T":"","de9@I1lMI":-2.8706407111120148e-269,"*":false,"mC":new Number(7.989425170759711e+195),"?GwV~":new Number(-457340909318629)}),"Kvs&8B2v":[{"^N":new Boolean(true),".:!A(qP":20528038146198208162650887930259608015981242728679994658945084604661485478002n,"HcddA":-5713290637700537700172208589046419850544142694893963903333467061831764879366n,"\"mTz $A\"":new Date("-080532-11-25T17:27:38.927Z"),"s.-2{PG]44":new Number(-6992011241268997),",":Int32Array.from([58354526,-349223904,-1863496096,-600565121,-439317198,1388408886,831319902,1571202305])}],"[I_3xDKk":new Set([Uint8Array.from([176,242,118,161,221,129,76,90]),new String("u-U"),null,"{Gy5k",new Date("-047592-12-06T02:45:52.378Z")]),",U'O/B4":new Map([[{"\"2":-51120958619614452207272888046562414099114012250112258213669353230651915934280n,"!Xj&HZ&z]":6825529460871025,"":undefined,"X":new Boolean(false),"zNN:~/?y<":-4521242514669030657275831943389670117392295466914227726932809412670219147594n,"RFxS5":new String("n~r6"),"H":new Boolean(false),"FOJ.%u9D!":new String("_")},[new Number(-2.7383636506170423e+215),"S",-7.869980401122065e-149,new Boolean(true),new Boolean(false),new Date("8703-10-31T01:27:12.885Z")]],[new String(",Go \\\"rh~",-5878537952870667228898116266453647481605446718907285116441390047947761144481n],[")djk",new Number(-9.378305640451206e-219)],["dH2",new String("^gaOh2/jFn")],["`D",false],["jW7",new Boolean(true)]]),new Number(3546419723802637)],[-3939708498905839,-7829211939997425],[true,new Boolean(true)],[[new Date("+189728-11-11T04:13:57.162Z"),-2866832410423399],-4535254984610130]]),"BN5*[3U4'*":new Set([[[1.0577165562424638e+130,true,false],2623502132149017],{"SA+C.;S":Uint8ClampedArray.from([181]),"":Uint32Array.from([1055394060,3754698713]),"=":new String("a2`")},Float64Array.from([])])} +// • {"𐝥򾫽򄓎𥸕򽊶󱂝綖":{"򉘤𿴀􀡹񻞏􃆢󂼾󺉁𤻎󁑹󩨭":"new Number(5.458711183935786e+215)","\"\"":new Set([new Number(-168580940874959),false,new String("𱚏󗿥")]),"𿚔#":new Map([["󵒊󩇣󄠾󹓅",new String("􃷂󅧰􊧮򆬽尢纍񬏖򈢯")],["򂆶𮕉ɠ񩗢󜧡𞯧󥰆𪲳󲴥󏜠",new Number(-3.915309186966617e-201)],["񢬬𬘃񍦎𨴓򌥱򑲮󷋴򧡥𦹎񮮻",false],["󢎆򐵂􍨌𣏓⢋򄓢𰌂􃙼",9.778144932315068e-292],["󥓽򠕉",new Boolean(true)],["񳟟",new Number(7263738133547713)],["􈦶񈫡򒧯񮹡𬲒򈓠","񒂜򡌍􎅹󇤮𪶟򠿺󓸸񒴕"],["񤮇",""],["򰨞𧘻򪣵򄠏",new String("򿺔󴼃򷣧󓀒")]])},"򇔎󻢢򶞇񙿢񏡂󕌴񠪢𤾿򇣦􉫽":Uint8ClampedArray.from([2,167,221,250,25,5,253,3,39]),"񫍋󕪿󿫽񈬌񁷚":new Set([null,-7554992422397568,-17220778063163852213518299424149709632540904753173033601881880719429971665504n,new String(""),new Boolean(true),undefined,-10556040980590440407765974154662897970048173654375365677184296697937171159766n]),"toString":{},"񂱹":[],"𺴕󖼑򠊅𔡹򁵩":Uint8ClampedArray.from([118,211,17]),"n":"new Map([[\"\",-3.847406447449319e-89]])","'3򆡭#諸0,":Object.assign(Object.create(null),{"񕯄􏿻. +𪲿󓕲4􏿾":new Number(8e-323),"󟔭򑂬𖄋񉾻𭩼𗿎򹸶臦":"","":23060781171921571898756243128383982884697443490579335692025690551060929342872n,"u򰉠oStr":new String("򻝢󔔲𐬸򁭘񩃟򵶳񍏫𓹹򓠹򴻯"),"􏿼񺆁":null,"󅆲򚏵󪹫񌋬𮏄𚨛󉬐":new Number(-1.3004479422180178e+247)})} +// • Object.assign(Object.create(null),{"򄹝񀱭":Int32Array.from([]),"𹼵񴝊󁬄󔧿􋮓󛶿𐔕򑱌𗶅󤪰":{"\"\\\"[,,,new Number(-4.490174307177352e-198),,new Date(\\\\\\\"-106579-12-08T20:44:48.131Z\\\\\\\"),,,,undefined,undefined,,,,,new Boolean(true),1.9508140793094447e-78,,new Number(-5041235613012303)]\\\"\"":[undefined,30705958287062063809406821421480739232961490015468570116289856317966655176612n,new Number(7.67366369906868e+61),"񾃪񭳵󞹛",-14338777825638388738588125662519091098121465295520758561664196240746398148098n,"򽪟𶟝󻹐򤻰",undefined],"𜺼򵹶򾏬셎":[,,6140240271527813,,,,,,,,,,,false,,,-6137666721580411,,,new String("󴣠󼶓򚜞"),,,,,,,,null],"򑲴򻳡􋡔񊒜𙽍󦽴񵺆":Object.assign(Object.create(null),{"񳷠󁲚򆴘눡":2.152516341623135e-119,"񁫹𾙼":new Boolean(true),"򊿬󦚔򝮵񳲢򲌲􆦌􉫴쳟󪐂":-34792858776756117278644791631482107040200676854821362073707882618437886127898n,"󉴖𨻎򳯔񔻲":new Boolean(false),"𢙻򊣐󘗎񫸶𷸭󈤧򀽛򮮭򭎇":true,"򊖠󢰫񝳥򞚬󒣵𲙼":new Date("-126777-12-31T00:18:16.754Z"),"󱙹򒼡񢝥𹊐󜪾\"":-3.099084554742164e+111})},"񧼢⑄򯫓":Object.assign(Object.create(null),{"񈡳𘾂򧨁":true,"񤆑󧝂񊥺":new String("񵲍"),"񒏘򌃲򨣶":new Number(-472028172876604),"󁏧򭍚񷓈񅯈𓩹𓐑󰢯𚵂":new Date("+037493-02-01T23:18:48.960Z"),"򽎳򜮺򮯕󗤶":new Number(-2.3716909519897796e-150),"򙧂񣉩򘷅􆌢Ձ񶘪񿕝񒡈󇑄":3040157920756017,"񀷖𜖷𮁫򸆲򟡒᲼󄧦򿰥􎶚":new String("𬡟ﰖ򚍼򀴋񍔿𔕫􉯘𳷍򸼐"),"񚧴󢇨󈴵󮢽𦱂񕫓񜆂򯠻":new Number(2532454634579329),"new Number(7798002711790977)":new String("𿵁񙙣𫏡੩򗢇")}),"򕟴񦙜񀍀򇁢󦌩󐟬񴛬𨩟":"Int16Array.from([7658,22125,-26239])","":new Map([["𳟶󹾂򖴁򃐒󊎋򼊾",Uint8Array.from([])],["{\"󬁲󐀎𪫮𴥓󖀐󹌝򬯺񍳗󕥖󰁓\":34333408565281186912577278712210978660985153156897149000078193251081785567642n,\"󈚛󩩺󗭍񛍍≼򵖏󄋑򵒌󯁹\":-6668764753275173,\"new String(\\\"󕳓򺟝󤩹򼎒򢀆𿙍𸨊󀋭𙘯񮖣\\\")\":3.795018961460958e+53,\"󐅀񹄦⺠쌛򿯪𧡬\":-2839839446815476,\"񼙴\":true,\"󁑳򅟧򶝕򟖊򳢰\":-1671767290528202,\"\":{\"򘟍󎧗𮘒􊀾󠄵퟇򓘱𺾚󙶖\":new Date(\"-182354-05-21T10:29:26.023Z\"),\"򨔔򽗏𨌰󵫙񁾀\":true,\"󞕏𛜺𰯬򽡏𘽗󉗣𪮾򭺷𕑆广\":new Number(4536131695635927),\"new Number(5.117983040436394e+69)\":-7686272122101106,\"\":new Date(\"+256755-02-25T04:42:50.620Z\"),\"󽤀񬸬򡟲\":new Date(\"-128815-01-15T07:27:05.561Z\"),\"𳊸𾹜\":new Number(1918554798446691),\"򽛉򑗧񰵱񗛇󯍸󴮴悵򾛼\":-7170578019637745722012682538451894114914867188472658657746570163170180233272n,\"𒩶󠑋󴌖򏜧\":null,\"󉺌󢙯\":undefined},\"񶴅񺎪񏀮囖􈲊򮕑􆸠\":new Number(-1.5469047808995759e-83)}",new Number(-1.6148448506765371e+22)],["󽰾񹓍󥦙𓾬񫈘",false],["𛏒񿽁኿􎽶񧦬񪴐",new Number(-5.826528261511027e+274)]])}) +// • Object.assign(Object.create(null),{"󿤡񜰁󠸂":new Set([]),".󫴜𓍚":Int8Array.from([-46,-72,-12,-70,56,120,-31,124,52,-33]),"key":Object.assign(Object.create(null),{"new Map([[new Boolean(false),-1.441300349275421e+148]])":null,"󏩄񵥥󶀻𬇆񈼦򴙈𑌄􆿙򏰠򧵰":new Number(-9.77072430925001e+272),"񔼚𥝸𳘔񅡾򂆇𔚋򜟛򫡁":[,,,,,,,,,,,,,,,,,,,,,,,,,,,,Float64Array.from([2.4327003204327724e+59,-2.3055577399170182e+238,-1.220016394687611e+278,-1.748990183698356e+145,5.1394770441041245e+137,1.8234041126551352e-121,1.094040461150623e-206])],"񠂉𦪹𮯙񈘰􉒷":new Date("+193195-05-28T11:42:59.440Z"),"arguments":new Boolean(false)}),"󇟹򇁊򙿌񍯱򯹵񮤗𗬩񓬡":"[48]"}) +// • {"򱗫":new Map([]),"𷢑􉎦񯢉󅌓󤑵򙺿":Uint32Array.from([1826204194,2417112435,3273159995,841539727,2942351593,1381423026]),"𰂻󎂹򅳾򈼥򧇮򿌮":new Map([["",new Number(-6836057403391378)],["new Date(\"-258207-08-18T07:39:50.664Z\")",[,,,,new Number(-1735757222382761),,"",,,,,,,,6278459942747999807080033191647922344096494191174452342262690828457892656925n,,new Date("-214251-08-20T20:06:26.663Z"),"􂢕􅪴",,,,,-8.079750906287982e-78,,,,,,,-10369827297499097554212502537348689556523576568069581751719816193396600267713n]],["󼓊񅪿򣇶",new Number(-1.2812321053022621e+131)],["􁵚򛩫񠋢𥼄󸮬",new Boolean(false)]]),"񄌺󫢀񲏑򥺪򤥲":[,new Set([-2.788886288154636e-108,-23176574200426617453381026519592490931781297414960701128396696332593406842216n,new Number(2614490335475399)]),,new Number(1.3866106311527406e+165),,43453764951860924684879533858074278006216090104086631170894299857984787714606n,,,,,,"򟠉󧶴𦱓󚭏񾞙򣻶򟉡",,,,,,,,-40062093534296937501748016010257849709288299651944876442585854714003078112906n,,,,,,,new Date("+120633-04-04T13:13:22.144Z")],"񽁜綌𩕊򳭱":Uint8Array.from([187,25,149,37,145,210,143,27]),"񘮵フ𾡰񕾃񀙹𘚢񪵖":"\"new Date(\\\"-062403-09-14T13:14:48.775Z\\\")\"","򥊋󏳬𖱀󼪉򡭓񗓱􇲝󯒘":new Date("+252329-01-04T02:02:12.616Z")} // • … fc.object({ @@ -272,7 +276,7 @@ Generate any kind of entities. **Signatures:** - `fc.anything()` -- `fc.anything({key?, depthSize?, maxDepth?, maxKeys?, size?, withBigInt?, withBoxedValues?, withDate?, withMap?, withNullPrototype?, withObjectString?, withSet?, withTypedArray?, values?})` +- `fc.anything({key?, depthSize?, maxDepth?, maxKeys?, size?, withBigInt?, withBoxedValues?, withDate?, withMap?, withNullPrototype?, withObjectString?, withSet?, withTypedArray?, withSparseArray?, withUnicodeString?, values?})` **with:** @@ -290,6 +294,7 @@ Generate any kind of entities. - `withSet?` — default: `false` — _enable `Set` - eg.: `new Set([1, 2, 3])`_ - `withTypedArray?` — default: `false` — _enable typed arrays for ints, uints and floats - eg.: `Int8Array.from([1, 2, 3])`_ - `withSparseArray?` — default: `false` — _enable sparse arrays - eg.: `[1,,,3]`_ +- `withUnicodeString?` — default: `false` — _change the default for `key` and `values` so that they produce unicode strings with non-ascii characters_ - `values?` — default: _booleans, numbers, strings, null and undefined_ — _array of arbitraries producing the root* values - *non-object ones_ **Usages:** @@ -343,13 +348,14 @@ fc.anything({ withSet: true, withTypedArray: true, withSparseArray: true, + withUnicodeString: true, }); // Examples of generated values: -// • [,,Object.assign(Object.create(null),{"5":undefined,"(_?C7pt":"","^E7Gyxv:":null," HX-,!#Y!":-24433665101126154577412974031256147490766030447807202673488877375171078490361n,"null":null,"|eR":15583747497214338238720970206332670685084374564290428276551032661271014257363n,"e":undefined}),,,true,,,,,,5614966592543699,,,,,,,-1.5581783079152344e-75,,,,,,,,,,new Map([[new Number(9.566807827285406e-250),new String("<@TD")],[2491797154642901,-7904776594405027],[new String("xtPJh"),new Number(7780679868790257)],[-4171412755646164,new Number(8899365920362973)],[true,-4.882087257668938e+289],[-8663561749600801083696605312122003123296678442665780054937383503975435354810n,"T'm\"O"],["_MkX!",undefined],[null,new Number(1766504482939761)],[new Number(2.020531818014619e-245),new String(")")]])] -// • [Int8Array.from([-3,0,-122,-126,-1,121,50,5]),"new Map([[new Map([[[,,,\"|`z!Y)\",true,,,,,,,,,,,,,,,,,,,,,\"a>ZU,@5j\"],\"1-\"],[-2423755478426117729073867301605745182670178056886961917272887542626910784966n,new Boolean(true)],[new String(\"z\"),new Number(1.7976931348623127e+308)]]),2.7226918179210657]])",new Set([])] -// • Object.assign(Object.create(null),{"f_SrN@":[false,,,,new Number(-634812710160603),3.0663015536568686e+105,,,,,"hTp]s?odUE",new Number(5881062065201437),new Boolean(false),"N\\26@kd