io-ts-fuzzer
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -10,5 +10,7 @@ import * as t from 'io-ts'; | ||
export declare function concrete<T, C extends t.Decoder<unknown, T> & BasicType>(func: basicLiteralConcreteFuzzer<T, C>, tag: C['_tag']): BasicFuzzer<T, C>; | ||
export declare function concreteNamed<T, C extends t.Decoder<unknown, T>>(func: ConcreteFuzzer<T>['func'], name: C['name']): Fuzzer<T, C>; | ||
export declare function gen<T, C extends t.Decoder<unknown, T> & BasicType>(func: basicFuzzGenerator<T, C>, tag: C['_tag']): BasicFuzzer<T, C>; | ||
export declare function fuzzBoolean(n: number): boolean; | ||
export declare function fuzzNumber(n: number): number; | ||
export declare function fuzzInt(n: number): t.TypeOf<typeof t.Int>; | ||
export declare function fuzzString(n: number): string; | ||
@@ -26,3 +28,3 @@ export declare function fuzzNull(): null; | ||
[key: string]: unknown; | ||
}>) | (t.Decoder<unknown, number> & t.RecursiveType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.InterfaceType<any, any, any, unknown>) | (t.Decoder<unknown, number> & t.PartialType<any, any, any, unknown>) | (t.Decoder<unknown, number> & t.DictionaryType<t.Any, t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.UnionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.IntersectionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.TupleType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.ReadonlyType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ReadonlyArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ExactType<t.Any, any, any, unknown>)> | Fuzzer<boolean, (t.Decoder<unknown, boolean> & t.NullType) | (t.Decoder<unknown, boolean> & t.UndefinedType) | (t.Decoder<unknown, boolean> & t.VoidType) | (t.Decoder<unknown, boolean> & t.UnknownType) | (t.Decoder<unknown, boolean> & t.StringType) | (t.Decoder<unknown, boolean> & t.NumberType) | (t.Decoder<unknown, boolean> & t.BooleanType) | (t.Decoder<unknown, boolean> & t.AnyArrayType) | (t.Decoder<unknown, boolean> & t.AnyDictionaryType) | (t.Decoder<unknown, boolean> & t.RefinementType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.LiteralType<string | number | boolean>) | (t.Decoder<unknown, boolean> & t.KeyofType<{ | ||
}>) | (t.Decoder<unknown, number> & t.RecursiveType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.InterfaceType<any, any, any, unknown>) | (t.Decoder<unknown, number> & t.PartialType<any, any, any, unknown>) | (t.Decoder<unknown, number> & t.DictionaryType<t.Any, t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.UnionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.IntersectionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.TupleType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, number> & t.ReadonlyType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ReadonlyArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.ExactType<t.Any, any, any, unknown>)> | Fuzzer<t.Branded<number, t.IntBrand>, t.Decoder<unknown, t.Branded<number, t.IntBrand>>> | Fuzzer<boolean, (t.Decoder<unknown, boolean> & t.NullType) | (t.Decoder<unknown, boolean> & t.UndefinedType) | (t.Decoder<unknown, boolean> & t.VoidType) | (t.Decoder<unknown, boolean> & t.UnknownType) | (t.Decoder<unknown, boolean> & t.StringType) | (t.Decoder<unknown, boolean> & t.NumberType) | (t.Decoder<unknown, boolean> & t.BooleanType) | (t.Decoder<unknown, boolean> & t.AnyArrayType) | (t.Decoder<unknown, boolean> & t.AnyDictionaryType) | (t.Decoder<unknown, boolean> & t.RefinementType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.LiteralType<string | number | boolean>) | (t.Decoder<unknown, boolean> & t.KeyofType<{ | ||
[key: string]: unknown; | ||
@@ -29,0 +31,0 @@ }>) | (t.Decoder<unknown, boolean> & t.RecursiveType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.ArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.InterfaceType<any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.PartialType<any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.DictionaryType<t.Any, t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.UnionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, boolean> & t.IntersectionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, boolean> & t.TupleType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, boolean> & t.ReadonlyType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.ReadonlyArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, boolean> & t.ExactType<t.Any, any, any, unknown>)> | Fuzzer<string, (t.Decoder<unknown, string> & t.NullType) | (t.Decoder<unknown, string> & t.UndefinedType) | (t.Decoder<unknown, string> & t.VoidType) | (t.Decoder<unknown, string> & t.UnknownType) | (t.Decoder<unknown, string> & t.StringType) | (t.Decoder<unknown, string> & t.NumberType) | (t.Decoder<unknown, string> & t.BooleanType) | (t.Decoder<unknown, string> & t.AnyArrayType) | (t.Decoder<unknown, string> & t.AnyDictionaryType) | (t.Decoder<unknown, string> & t.RefinementType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.LiteralType<string | number | boolean>) | (t.Decoder<unknown, string> & t.KeyofType<{ |
@@ -14,2 +14,13 @@ "use strict"; | ||
exports.concrete = concrete; | ||
function concreteNamed(func, name) { | ||
return { | ||
impl: { | ||
type: 'fuzzer', | ||
func, | ||
}, | ||
id: name, | ||
idType: 'name', | ||
}; | ||
} | ||
exports.concreteNamed = concreteNamed; | ||
function gen(func, tag) { | ||
@@ -34,2 +45,6 @@ return { | ||
exports.fuzzNumber = fuzzNumber; | ||
function fuzzInt(n) { | ||
return Math.floor(n); | ||
} | ||
exports.fuzzInt = fuzzInt; | ||
function fuzzString(n) { | ||
@@ -136,2 +151,3 @@ return `${n}`; | ||
concrete(fuzzNumber, 'NumberType'), | ||
concreteNamed(fuzzInt, 'Int'), | ||
concrete(fuzzBoolean, 'BooleanType'), | ||
@@ -138,0 +154,0 @@ concrete(fuzzString, 'StringType'), |
@@ -0,1 +1,8 @@ | ||
# [1.3.0](https://github.com/holvonix-open/io-ts-fuzzer/compare/v1.2.2...v1.3.0) (2019-08-03) | ||
### Features | ||
* support Ints ([54a29de](https://github.com/holvonix-open/io-ts-fuzzer/commit/54a29de)) | ||
## [1.2.2](https://github.com/holvonix-open/io-ts-fuzzer/compare/v1.2.1...v1.2.2) (2019-08-03) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "io-ts-fuzzer", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Fuzzing for io-ts codecs and types", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -10,4 +10,2 @@ # io-ts-fuzzer - Fuzzing for io-ts codecs and types | ||
````typescript | ||
@@ -27,3 +25,4 @@ import * as t from 'io-ts'; | ||
// Make examples. | ||
// Make examples. The input number fully determines | ||
// the output example. | ||
console.log(fuzzer.encode(0)); | ||
@@ -50,4 +49,14 @@ console.log(fuzzer.encode(1)); | ||
* `t.unknown` | ||
* `t.Int` | ||
## Use Cases | ||
### Verifying Decoder Behavior | ||
Given a `d = t.Decoder<I,A>` (aka a `t.Type`), `fuzz.exampleGenerator` will | ||
build a `t.Encoder<number,A>` that will give example instances of `A`. | ||
The example instances should all pass on `d.decode`, which should return | ||
an identical example. No exceptions should be thrown. | ||
## License | ||
@@ -54,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43011
382
89