diff --git a/.gitignore b/.gitignore index 3dadcc66..68b6917b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,5 @@ _esy /ocamldoc-json-generator/dune _opam/ -fsharp/src/obj -fsharp/src/bin -.paket/ paket-files/ +/json-files \ No newline at end of file diff --git a/bsconfig.json b/bsconfig.json new file mode 100644 index 00000000..1ba6e3f3 --- /dev/null +++ b/bsconfig.json @@ -0,0 +1,18 @@ +{ + "name": "tablecloth", + "version": "0.0.1", + "sources": { + "dir" : "src", + "subdirs" : true + }, + "package-specs": { + "module": "commonjs", + "in-source": true + }, + "suffix": ".bs.js", + "bs-dependencies": [ + ], + "warnings": { + "error" : "+101" + } +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..d5c62b89 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "tablecloth", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "tablecloth", + "version": "0.0.1", + "license": "MIT", + "dependencies": { + "rescript": "*" + }, + "devDependencies": { + "@types/node": "^18.11.3" + } + }, + "node_modules/@types/node": { + "version": "18.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", + "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", + "dev": true + }, + "node_modules/rescript": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-10.0.1.tgz", + "integrity": "sha512-XwO1GPDtoEU4H03xQE5bp0/qtSVR6YLaJRPxWKrfFgKc+LI36ODOCie7o9UJfgzQdoMYkkZyiTGZ4N9OQEaiUw==", + "hasInstallScript": true, + "bin": { + "bsc": "bsc", + "bsrefmt": "bsrefmt", + "bstracing": "lib/bstracing", + "rescript": "rescript" + } + } + }, + "dependencies": { + "@types/node": { + "version": "18.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", + "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", + "dev": true + }, + "rescript": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-10.0.1.tgz", + "integrity": "sha512-XwO1GPDtoEU4H03xQE5bp0/qtSVR6YLaJRPxWKrfFgKc+LI36ODOCie7o9UJfgzQdoMYkkZyiTGZ4N9OQEaiUw==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..8a1dceaa --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "tablecloth", + "version": "0.0.1", + "scripts": { + "build": "rescript", + "clean": "rescript clean -with-deps", + "start": "rescript build -w" + }, + "keywords": [ + "rescript" + ], + "author": "", + "license": "MIT", + "dependencies": { + "rescript": "*" + }, + "devDependencies": { + "@types/node": "^18.11.3" + } +} diff --git a/src/generateTest.res b/src/generateTest.res new file mode 100644 index 00000000..250fcc47 --- /dev/null +++ b/src/generateTest.res @@ -0,0 +1,248 @@ +@module("fs") +external readFileSync: (~name: string, [#utf8]) => string = "readFileSync" + +type tests = { + inputs: array, + output: int, +} + +type parameter = { + name: string, + \"type": string, + label: bool +} + +type data = { + \"module": string, + name: string, + parameters: array, + tests: array, + returnType: string, +} + +@scope("JSON") @val +external parseIntoMyData: string => data = "parse" +let \"module" = ref("") +let testCasesR = [] +let testCasesF = [] +let testCasesO = [] +let labeltest = ref([]) +let labeltestO = ref([]) + +// let files = [ +// "Float.absolute.json", +// "Float.add.json", +// "Float.clamp.json", +// "Float.atan.json", +// "Float.atan2.json", +// "Float.ceiling.json", +// "Float.cos.json", +// "Float.degrees.json", +// "Float.divide.json", +// "Float.floor.json", +// "Float.fromInt.json", +// "Float.fromString.json", +// "Float.hypotenuse.json", +// "Float.inRange.json", +// "Float.isFinite.json", +// "Float.isInfinite.json", +// "Float.isInteger.json", +// "Float.isNaN.json", +// "Float.log.json", +// "Float.maximum.json", +// "Float.minimum.json", +// "Float.multiply.json", +// "Float.negate.json", +// "Float.power.json", +// "Float.round.json", +// "Float.radians.json", +// "Float.sin.json", +// "Float.squareRoot.json", +// "Float.subtract.json", +// "Float.tan.json", +// "Float.toInt.json", +// "Float.truncate.json", +// "Float.turns.json", +// ] +// let files = [ +// "Bool.compare.json", +// "Bool.equal.json", +// "Bool.fromInt.json", +// "Bool.fromString.json", +// "Bool.toInt.json", +// "Bool.toString.json", +// "Bool.xor.json", +// ] +// let files = [ +// "Char.fromCode.json", +// "Char.fromString.json", +// "Char.isAlphanumeric.json", +// "Char.isDigit.json", +// "Char.isLetter.json", +// "Char.isLowercase.json", +// "Char.isPrintable.json", +// "Char.isUppercase.json", +// "Char.isWhitespace.json", +// "Char.toCode.json", +// "Char.toDigit.json", +// "Char.toLowercase.json", +// "Char.toString.json", +// "Char.toUppercase.json", +// ] +let files = [ + "Int.absolute.json", + "Int.add.json", + "Int.clamp.json", + "Int.divide.json", + "Int.divideFloat.json", + "Int.fromString.json", + "Int.inRange.json", + "Int.isEven.json", + "Int.isOdd.json", + "Int.maximum.json", + "Int.minimum.json", + "Int.modulo.json", + "Int.multiply.json", + "Int.negate.json", + "Int.power.json", + "Int.remainder.json", + "Int.subtract.json", + "Int.toFloat.json", + "Int.toString.json", +] + +let generateAllTests = Belt.Array.map(files, file => { + let file = readFileSync(~name="../json-files/" ++ file, #utf8) + let myData = parseIntoMyData(file) + let name = myData.name + let returnType = myData.returnType + \"module" := myData.\"module" + let resultsR = [] + let resultsF = [] + let resultsO = [] + let newInput = ref("") + let newInputR = ref("") + let newInputOF = ref("") + let output = ref("") + let length = Belt.Array.length(myData.parameters) + + let generate = Belt.Array.map(myData.tests, test => { + output := Belt.Int.toString(test.output) + if myData.returnType == "string" { + output := `"${Belt.Int.toString(test.output)}"` + } else if Js.String.includes("array", myData.returnType) { + output := `[${Belt.Int.toString(test.output)}]` + //TODO: add a different output for ocaml and f# ([||]) + } + + if length == 1 { + //param length == 1 type string + if myData.parameters[0].\"type" == "string" { + newInput := `"${Js.Array.toString(test.inputs)}"` + newInputR := Js.Array.toString(test.inputs) + newInputOF := `"${Js.Array.toString(test.inputs)}"` + } //param length == 1 type array + else if Js.Array.isArray(test.inputs) { + newInput := `[${Js.Array.toString(test.inputs)}]` + newInputOF := `[|${Js.Array.toString(test.inputs)}|]` + } else { + //param length == 1 + + newInput := Js.Array.toString(test.inputs) + newInputR := Js.Array.toString(test.inputs) + newInputOF := Js.Array.toString(test.inputs) + } + } else { + //param length > 1 type + for i in 0 to length - 1{ + let label = myData.parameters[i].label + if label{ + let testOcaml = `~${myData.parameters[i].name}:${Belt.Int.toString(test.inputs[i])}` + let test = `~${myData.parameters[i].name}=${Belt.Int.toString(test.inputs[i])}` + Belt.Array.push(labeltest.contents,test) + Belt.Array.push(labeltestO.contents,testOcaml) + }else{ + Belt.Array.push(labeltest.contents,Belt.Int.toString(test.inputs[i])) + Belt.Array.push(labeltestO.contents,Belt.Int.toString(test.inputs[i])) + } + newInput := Js_array.joinWith(",", labeltest.contents) + newInputOF := Js_array.joinWith(" ", labeltestO.contents) + newInputR := Js_array.joinWith(",", labeltest.contents) + } + labeltest.contents=[] + labeltestO.contents=[] + } + + let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents != "exception" + ? `${\"module".contents}.${name}(${newInput.contents})) |> toEqual(${Js.String.includes( + "Some", + output.contents, + ) || + Js.String.includes("None", output.contents) + ? `{open Eq\n${Js.String.slice( + ~from=0, + ~to_=6, + returnType, + )}(${Js.String.replace( + ">", + "", + Js.String.sliceToEnd(~from=7, returnType), + )})}` + : `Eq.${returnType}`}, ${output.contents}))` + : `() => ${\"module".contents}.${name}(${newInput.contents})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + + let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents != "exception" + ? `${\"module".contents}.${name} ${newInputOF.contents}) |> toEqual ${Js.String.includes( + "Some", + output.contents, + ) || + Js.String.includes("None", output.contents) + ? `(let open Eq in ${Js.String.slice( + ~from=0, + ~to_=6, + returnType, + )} ${Js.String.replace( + ">", + "", + Js.String.sliceToEnd(~from=7, returnType), + )})` + : `Eq.${returnType}`} ${output.contents == "exception" + ? "|> toThrow" + : output.contents}) ; ` + : `fun () -> ${name} ${newInputOF.contents}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + + let resultFSharp = `testCase "${name}(${newInput.contents})" \n<| fun _ -> \n ${output.contents != "exception" + ? `let expected = ${output.contents}\n Expect.equal expected (${\"module".contents}.${name} ${newInputOF.contents}) "error"` + : `Expect.equal (${\"module".contents}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` + resultsF->Belt.Array.push(resultFSharp) + }) + + testCasesR->Belt.Array.push(Js.Array.joinWith("", resultsR)) + testCasesF->Belt.Array.push(Js.Array.joinWith("", resultsF)) + testCasesO->Belt.Array.push(Js.Array.joinWith("", resultsO)) +}) + + +let testHeaderR = `open Tablecloth\nopen AlcoJest\n\nlet suite= suite("${\"module".contents}", () => {\n open ${\"module".contents}\n` +let combineTestsR = `${testHeaderR}${Js.Array.joinWith("", testCasesR)}})` +let testHeaderO = `open Tablecloth\nopen AlcoJest\n\nlet suite =\n suite "${\"module".contents}" (fun () ->\n let open ${\"module".contents} in\n` +let combineTestsO = `${testHeaderO}${Js.Array.joinWith("", testCasesO)})` +let testHeaderF = `open Tablecloth\nopen Expecto\n\n[]\nlet tests =\n testList\n "${\"module".contents}"\n[` +let combineTestsF = `${testHeaderF}${Js.Array.joinWith("", testCasesF)}]` +Node.Fs.writeFileSync( + `../test/rescriptTests/${\"module".contents}Test.res`, + combineTestsR, + #utf8, +) +Node.Fs.writeFileSync( + `../test/ocamlTests/${\"module".contents}Test.ml`, + combineTestsO, + #utf8, +) +Node.Fs.writeFileSync( + `../test/fsharpTests/${\"module".contents}Test.fs`, + combineTestsF, + #utf8, +) diff --git a/test/fsharpTests/BoolTest.fs b/test/fsharpTests/BoolTest.fs new file mode 100644 index 00000000..5316e203 --- /dev/null +++ b/test/fsharpTests/BoolTest.fs @@ -0,0 +1,112 @@ +open Tablecloth +open Expecto + +[] +let tests = + testList + "Bool" +[testCase "compare(true,true)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Bool.compare true true) "error" +testCase "compare(true,false)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Bool.compare true false) "error" +testCase "compare(false,true)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Bool.compare false true) "error" +testCase "compare(false,false)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Bool.compare false false) "error" +testCase "equal(true,true)" +<| fun _ -> + let expected = true + Expect.equal expected (Bool.equal true true) "error" +testCase "equal(false,false)" +<| fun _ -> + let expected = true + Expect.equal expected (Bool.equal false false) "error" +testCase "equal(true,false)" +<| fun _ -> + let expected = false + Expect.equal expected (Bool.equal true false) "error" +testCase "fromInt(0)" +<| fun _ -> + let expected = Some(false) + Expect.equal expected (Bool.fromInt 0) "error" +testCase "fromInt(1)" +<| fun _ -> + let expected = Some(true) + Expect.equal expected (Bool.fromInt 1) "error" +testCase "fromInt(Int.minimumValue)" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromInt Int.minimumValue) "error" +testCase "fromInt(-2)" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromInt -2) "error" +testCase "fromInt(-1)" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromInt -1) "error" +testCase "fromInt(2)" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromInt 2) "error" +testCase "fromInt(Int.maximumValue)" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromInt Int.maximumValue) "error" +testCase "fromString("true")" +<| fun _ -> + let expected = Some(true) + Expect.equal expected (Bool.fromString "true") "error" +testCase "fromString("false")" +<| fun _ -> + let expected = Some(false) + Expect.equal expected (Bool.fromString "false") "error" +testCase "fromString("True")" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromString "True") "error" +testCase "fromString("1")" +<| fun _ -> + let expected = None + Expect.equal expected (Bool.fromString "1") "error" +testCase "toInt(true)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Bool.toInt true) "error" +testCase "toInt(false)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Bool.toInt false) "error" +testCase "toString(true)" +<| fun _ -> + let expected = "true" + Expect.equal expected (Bool.toString true) "error" +testCase "toString(false)" +<| fun _ -> + let expected = "false" + Expect.equal expected (Bool.toString false) "error" +testCase "xor(true,true)" +<| fun _ -> + let expected = false + Expect.equal expected (Bool.xor true true) "error" +testCase "xor(true,false)" +<| fun _ -> + let expected = true + Expect.equal expected (Bool.xor true false) "error" +testCase "xor(false,true)" +<| fun _ -> + let expected = true + Expect.equal expected (Bool.xor false true) "error" +testCase "xor(false,false)" +<| fun _ -> + let expected = false + Expect.equal expected (Bool.xor false false) "error" +] \ No newline at end of file diff --git a/test/fsharpTests/CharTest.fs b/test/fsharpTests/CharTest.fs new file mode 100644 index 00000000..610913fb --- /dev/null +++ b/test/fsharpTests/CharTest.fs @@ -0,0 +1,196 @@ +open Tablecloth +open Expecto + +[] +let tests = + testList + "Char" +[testCase "fromCode(97)" +<| fun _ -> + let expected = Some('a') + Expect.equal expected (Char.fromCode 97) "error" +testCase "fromCode(-1)" +<| fun _ -> + let expected = None + Expect.equal expected (Char.fromCode -1) "error" +testCase "fromCode(256)" +<| fun _ -> + let expected = None + Expect.equal expected (Char.fromCode 256) "error" +testCase "fromString("a")" +<| fun _ -> + let expected = Some('a') + Expect.equal expected (Char.fromString "a") "error" +testCase "fromString("abc")" +<| fun _ -> + let expected = None + Expect.equal expected (Char.fromString "abc") "error" +testCase "fromString("")" +<| fun _ -> + let expected = None + Expect.equal expected (Char.fromString "") "error" +testCase "isAlphanumeric('A')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isAlphanumeric 'A') "error" +testCase "isAlphanumeric('?')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isAlphanumeric '?') "error" +testCase "isDigit('0')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '0') "error" +testCase "isDigit('1')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '1') "error" +testCase "isDigit('2')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '2') "error" +testCase "isDigit('3')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '3') "error" +testCase "isDigit('4')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '4') "error" +testCase "isDigit('5')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '5') "error" +testCase "isDigit('6')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '6') "error" +testCase "isDigit('7')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '7') "error" +testCase "isDigit('8')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '8') "error" +testCase "isDigit('9')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isDigit '9') "error" +testCase "isDigit('a')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isDigit 'a') "error" +testCase "isLetter('A')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isLetter 'A') "error" +testCase "isLetter('7')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLetter '7') "error" +testCase "isLetter(' ')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLetter ' ') "error" +testCase "isLetter('\n')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLetter '\n') "error" +testCase "isLetter('\001')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLetter '\001') "error" +testCase "isLetter('\236')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLetter '\236') "error" +testCase "isLowercase('a')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isLowercase 'a') "error" +testCase "isLowercase('7')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLowercase '7') "error" +testCase "isLowercase('\236')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isLowercase '\236') "error" +testCase "isPrintable('~')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isPrintable '~') "error" +testCase "isUppercase('A')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isUppercase 'A') "error" +testCase "isUppercase('7')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isUppercase '7') "error" +testCase "isUppercase('\237')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isUppercase '\237') "error" +testCase "isWhitespace(' ')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isWhitespace ' ') "error" +testCase "isWhitespace('a')" +<| fun _ -> + let expected = false + Expect.equal expected (Char.isWhitespace 'a') "error" +testCase "toCode('a')" +<| fun _ -> + let expected = 97 + Expect.equal expected (Char.toCode 'a') "error" +testCase "toDigit('0')" +<| fun _ -> + let expected = Some(0) + Expect.equal expected (Char.toDigit '0') "error" +testCase "toDigit('8')" +<| fun _ -> + let expected = Some(8) + Expect.equal expected (Char.toDigit '8') "error" +testCase "toDigit('a')" +<| fun _ -> + let expected = None + Expect.equal expected (Char.toDigit 'a') "error" +testCase "toLowercase('A')" +<| fun _ -> + let expected = 'a' + Expect.equal expected (Char.toLowercase 'A') "error" +testCase "toLowercase('a')" +<| fun _ -> + let expected = 'a' + Expect.equal expected (Char.toLowercase 'a') "error" +testCase "toLowercase('7')" +<| fun _ -> + let expected = '7' + Expect.equal expected (Char.toLowercase '7') "error" +testCase "toLowercase('\233')" +<| fun _ -> + let expected = '\233' + Expect.equal expected (Char.toLowercase '\233') "error" +testCase "toString('a')" +<| fun _ -> + let expected = "a" + Expect.equal expected (Char.toString 'a') "error" +testCase "toUppercase('a')" +<| fun _ -> + let expected = 'A' + Expect.equal expected (Char.toUppercase 'a') "error" +testCase "toUppercase('A')" +<| fun _ -> + let expected = 'A' + Expect.equal expected (Char.toUppercase 'A') "error" +testCase "toUppercase('7')" +<| fun _ -> + let expected = '7' + Expect.equal expected (Char.toUppercase '7') "error" +testCase "toUppercase('\233')" +<| fun _ -> + let expected = '\233' + Expect.equal expected (Char.toUppercase '\233') "error" +] \ No newline at end of file diff --git a/test/fsharpTests/FloatTest.fs b/test/fsharpTests/FloatTest.fs new file mode 100644 index 00000000..534408dc --- /dev/null +++ b/test/fsharpTests/FloatTest.fs @@ -0,0 +1,738 @@ +open Tablecloth +open Expecto + +[] +let tests = + testList + "Float" +[testCase "absolute(8.)" +<| fun _ -> + let expected = 8. + Expect.equal expected (Float.absolute 8.) "error" +testCase "absolute(-7.)" +<| fun _ -> + let expected = 7. + Expect.equal expected (Float.absolute -7.) "error" +testCase "absolute(0.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.absolute 0.) "error" +testCase "add(3.14,3.14)" +<| fun _ -> + let expected = 6.28 + Expect.equal expected (Float.add 3.14 3.14) "error" +testCase "clamp(5.,~lower=0.,~upper=8.)" +<| fun _ -> + let expected = 5. + Expect.equal expected (Float.clamp 5. ~lower:0. ~upper:8.) "error" +testCase "clamp(9.,~lower=0.,~upper=8.)" +<| fun _ -> + let expected = 8. + Expect.equal expected (Float.clamp 9. ~lower:0. ~upper:8.) "error" +testCase "clamp(1.,~lower=2.,~upper=8.)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.clamp 1. ~lower:2. ~upper:8.) "error" +testCase "clamp(5.,~lower=-10.,~upper=-5.)" +<| fun _ -> + let expected = -5. + Expect.equal expected (Float.clamp 5. ~lower:-10. ~upper:-5.) "error" +testCase "clamp(-15.,~lower=-10.,~upper=-5.)" +<| fun _ -> + let expected = -10. + Expect.equal expected (Float.clamp -15. ~lower:-10. ~upper:-5.) "error" +testCase "clamp(-6.6,~lower=-7.9,~upper=nan)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp -6.6 ~lower:-7.9 ~upper:nan) "error" +testCase "clamp(-6.6,~lower=nan,~upper=0.)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp -6.6 ~lower:nan ~upper:0.) "error" +testCase "clamp(nan,~lower=2.,~upper=8.)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp nan ~lower:2. ~upper:8.) "error" +testCase "clamp(3.,~lower=7.,~upper= 1.)" +<| fun _ -> + Expect.equal (Float.clamp 3. ~lower:7. ~upper: 1.) |> failwith "error" +testCase "atan(0.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.atan 0.) "error" +testCase "atan(1. /. 1.)" +<| fun _ -> + let expected = 0.7853981633974483 + Expect.equal expected (Float.atan 1. /. 1.) "error" +testCase "atan(1. /. -1.)" +<| fun _ -> + let expected = -0.7853981633974483 + Expect.equal expected (Float.atan 1. /. -1.) "error" +testCase "atan(-1. /. -1.)" +<| fun _ -> + let expected = 0.7853981633974483 + Expect.equal expected (Float.atan -1. /. -1.) "error" +testCase "atan(-1. /. 1.)" +<| fun _ -> + let expected = -0.7853981633974483 + Expect.equal expected (Float.atan -1. /. 1.) "error" +testCase "atan2(~y=0.,~x=0.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.atan2 ~y:0. ~x:0.) "error" +testCase "atan2(~y=1.,~x=1.)" +<| fun _ -> + let expected = 0.7853981633974483 + Expect.equal expected (Float.atan2 ~y:1. ~x:1.) "error" +testCase "atan2(~y=1.,~x=-1.)" +<| fun _ -> + let expected = 2.356194490192345 + Expect.equal expected (Float.atan2 ~y:1. ~x:-1.) "error" +testCase "atan2(~y=-1.,~x=-1.)" +<| fun _ -> + let expected = -2.356194490192345 + Expect.equal expected (Float.atan2 ~y:-1. ~x:-1.) "error" +testCase "atan2(~y=-1.,~x=1.)" +<| fun _ -> + let expected = -0.7853981633974483 + Expect.equal expected (Float.atan2 ~y:-1. ~x:1.) "error" +testCase "ceiling(1.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.ceiling 1.2) "error" +testCase "ceiling(1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.ceiling 1.5) "error" +testCase "ceiling(1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.ceiling 1.8) "error" +testCase "ceiling(-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.ceiling -1.2) "error" +testCase "ceiling(-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.ceiling -1.5) "error" +testCase "ceiling(-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.ceiling -1.8) "error" +testCase "cos(degrees(60.))" +<| fun _ -> + let expected = 0.5 + Expect.equal expected (Float.cos degrees(60.)) "error" +testCase "cos(radians(pi /. 3.))" +<| fun _ -> + let expected = 0.5 + Expect.equal expected (Float.cos radians(pi /. 3.)) "error" +testCase "degrees(180.)" +<| fun _ -> + let expected = pi + Expect.equal expected (Float.degrees 180.) "error" +testCase "divide(3.14,~by=2.)" +<| fun _ -> + let expected = 1.57 + Expect.equal expected (Float.divide 3.14 ~by:2.) "error" +testCase "divide(3.14,~by=0.)" +<| fun _ -> + let expected = infinity + Expect.equal expected (Float.divide 3.14 ~by:0.) "error" +testCase "divide(3.14,~by=-0.)" +<| fun _ -> + let expected = negativeInfinity + Expect.equal expected (Float.divide 3.14 ~by:-0.) "error" +testCase "floor(1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.floor 1.2) "error" +testCase "floor(1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.floor 1.5) "error" +testCase "floor(1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.floor 1.8) "error" +testCase "floor(-1.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.floor -1.2) "error" +testCase "floor(-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.floor -1.5) "error" +testCase "floor(-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.floor -1.8) "error" +testCase "fromInt(5)" +<| fun _ -> + let expected = 5.0 + Expect.equal expected (Float.fromInt 5) "error" +testCase "fromInt(0)" +<| fun _ -> + let expected = 0.0 + Expect.equal expected (Float.fromInt 0) "error" +testCase "fromInt(-7)" +<| fun _ -> + let expected = -7.0 + Expect.equal expected (Float.fromInt -7) "error" +testCase "fromString("NaN")" +<| fun _ -> + let expected = Some(Js.Float._NaN), + Expect.equal expected (Float.fromString "NaN") "error" +testCase "fromString("nan")" +<| fun _ -> + let expected = Some(Js.Float._NaN) + Expect.equal expected (Float.fromString "nan") "error" +testCase "fromString("Infinity")" +<| fun _ -> + let expected = Some(infinity) + Expect.equal expected (Float.fromString "Infinity") "error" +testCase "fromString("infinity")" +<| fun _ -> + let expected = None + Expect.equal expected (Float.fromString "infinity") "error" +testCase "fromString("55")" +<| fun _ -> + let expected = Some(55.) + Expect.equal expected (Float.fromString "55") "error" +testCase "fromString("-100")" +<| fun _ -> + let expected = Some(-100.) + Expect.equal expected (Float.fromString "-100") "error" +testCase "fromString("not number")" +<| fun _ -> + let expected = None + Expect.equal expected (Float.fromString "not number") "error" +testCase "hypotenuse(3.,4.)" +<| fun _ -> + let expected = 5. + Expect.equal expected (Float.hypotenuse 3. 4.) "error" +testCase "inRange(3.,~lower=2.,~upper=4.)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.inRange 3. ~lower:2. ~upper:4.) "error" +testCase "inRange(8.,~lower=2.,~upper=4.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 8. ~lower:2. ~upper:4.) "error" +testCase "inRange(1.,~lower= 2.,~upper=4.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 1. ~lower: 2. ~upper:4.) "error" +testCase "inRange(2.,~lower=1.,~upper=2.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 2. ~lower:1. ~upper:2.) "error" +testCase "inRange(-6.6,~lower=-7.9,~upper=-5.2)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.inRange -6.6 ~lower:-7.9 ~upper:-5.2) "error" +testCase "inRange(-6.6,~lower=-7.9,~upper=nan)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange -6.6 ~lower:-7.9 ~upper:nan) "error" +testCase "inRange(-6.6,~lower=nan,~upper=0.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange -6.6 ~lower:nan ~upper:0.) "error" +testCase "inRange(nan,~lower=2.,~upper=8.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange nan ~lower:2. ~upper:8.) "error" +testCase "inRange(3.,~lower=7.,~upper=1.)" +<| fun _ -> + Expect.equal (Float.inRange 3. ~lower:7. ~upper:1.) |> failwith "error" +testCase "isFinite(infinity)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isFinite infinity) "error" +testCase "isFinite(negativeInfinity)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isFinite negativeInfinity) "error" +testCase "isFinite(nan)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isFinite nan) "error" +testCase "isFinite(-5.)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isFinite -5.) "error" +testCase "isFinite(-0.314)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isFinite -0.314) "error" +testCase "isFinite(0.)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isFinite 0.) "error" +testCase "isFinite(3.14)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isFinite 3.14) "error" +testCase "isInfinite(infinity)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isInfinite infinity) "error" +testCase "isInfinite(negativeInfinity)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isInfinite negativeInfinity) "error" +testCase "isInfinite(nan)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInfinite nan) "error" +testCase "isInfinite(-5.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInfinite -5.) "error" +testCase "isInfinite(-0.314)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInfinite -0.314) "error" +testCase "isInfinite(0.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInfinite 0.) "error" +testCase "isInfinite(3.14)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInfinite 3.14) "error" +testCase "isInteger(5.0)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isInteger 5.0) "error" +testCase "isInteger(pi)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isInteger pi) "error" +testCase "isNaN(nan)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.isNaN nan) "error" +testCase "isNaN(91.4)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.isNaN 91.4) "error" +testCase "log(100.,~base=10.)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.log 100. ~base:10.) "error" +testCase "log(256.,~base=2.)" +<| fun _ -> + let expected = 8. + Expect.equal expected (Float.log 256. ~base:2.) "error" +testCase "log(0.,~base=10.)" +<| fun _ -> + let expected = negativeInfinity + Expect.equal expected (Float.log 0. ~base:10.) "error" +testCase "maximum(7.,9.)" +<| fun _ -> + let expected = 9. + Expect.equal expected (Float.maximum 7. 9.) "error" +testCase "maximum(-4.,-1.)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.maximum -4. -1.) "error" +testCase "maximum(7.,nan)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.maximum 7. nan) "error" +testCase "maximum(7.,infinity)" +<| fun _ -> + let expected = infinity + Expect.equal expected (Float.maximum 7. infinity) "error" +testCase "maximum(7.,negativeInfinity)" +<| fun _ -> + let expected = 7. + Expect.equal expected (Float.maximum 7. negativeInfinity) "error" +testCase "minimum(7.,9.)" +<| fun _ -> + let expected = 7. + Expect.equal expected (Float.minimum 7. 9.) "error" +testCase "minimum(-4.,-1.)" +<| fun _ -> + let expected = -4. + Expect.equal expected (Float.minimum -4. -1.) "error" +testCase "minimum(7.,nan)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.minimum 7. nan) "error" +testCase "minimum(7.,infinity)" +<| fun _ -> + let expected = 7. + Expect.equal expected (Float.minimum 7. infinity) "error" +testCase "minimum(7.,negativeInfinity)" +<| fun _ -> + let expected = negativeInfinity + Expect.equal expected (Float.minimum 7. negativeInfinity) "error" +testCase "multiply(2.,7.)" +<| fun _ -> + let expected = 14. + Expect.equal expected (Float.multiply 2. 7.) "error" +testCase "negate(8.)" +<| fun _ -> + let expected = -8. + Expect.equal expected (Float.negate 8.) "error" +testCase "negate(-7.)" +<| fun _ -> + let expected = 7. + Expect.equal expected (Float.negate -7.) "error" +testCase "negate(0.)" +<| fun _ -> + let expected = -0. + Expect.equal expected (Float.negate 0.) "error" +testCase "power(~base=7.,~exponent=3.)" +<| fun _ -> + let expected = 343. + Expect.equal expected (Float.power ~base:7. ~exponent:3.) "error" +testCase "power(~base=0.,~exponent=3.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.power ~base:0. ~exponent:3.) "error" +testCase "power(~base=7.,~exponent=0.)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.power ~base:7. ~exponent:0.) "error" +testCase "round(~direction=#Zero,1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Zero 1.2) "error" +testCase "round(~direction=#Zero,1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Zero 1.5) "error" +testCase "round(~direction=#Zero,1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Zero 1.8) "error" +testCase "round(~direction=#Zero,-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Zero -1.2) "error" +testCase "round(~direction=#Zero,-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Zero -1.5) "error" +testCase "round(~direction=#Zero,-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Zero -1.8) "error" +testCase "round(~direction=#AwayFromZero,1.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#AwayFromZero 1.2) "error" +testCase "round(~direction=#AwayFromZero,1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#AwayFromZero 1.5) "error" +testCase "round(~direction=#AwayFromZero,1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#AwayFromZero 1.8) "error" +testCase "round(~direction=#AwayFromZero,-1.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#AwayFromZero -1.2) "error" +testCase "round(~direction=#AwayFromZero,-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#AwayFromZero -1.5) "error" +testCase "round(~direction=#AwayFromZero,-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#AwayFromZero -1.8) "error" +testCase "round(~direction=#Up,1.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Up 1.2) "error" +testCase "round(~direction=#Up,1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Up 1.5) "error" +testCase "round(~direction=#Up,1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Up 1.8) "error" +testCase "round(~direction=#Up,-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Up -1.2) "error" +testCase "round(~direction=#Up,-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Up -1.5) "error" +testCase "round(~direction=#Up,-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Up -1.8) "error" +testCase "round(~direction=#Down,1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Down 1.2) "error" +testCase "round(~direction=#Down,1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Down 1.5) "error" +testCase "round(~direction=#Down,1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Down 1.8) "error" +testCase "round(~direction=#Down,-1.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Down -1.2) "error" +testCase "round(~direction=#Down,-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Down -1.5) "error" +testCase "round(~direction=#Down,-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Down -1.8) "error" +testCase "round(~direction=#Closest(#Zero),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) 1.2) "error" +testCase "round(~direction=#Closest(#Zero),1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) 1.5) "error" +testCase "round(~direction=#Closest(#Zero),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) 1.8) "error" +testCase "round(~direction=#Closest(#Zero),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) -1.2) "error" +testCase "round(~direction=#Closest(#Zero),-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) -1.5) "error" +testCase "round(~direction=#Closest(#Zero),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#Zero) -1.8) "error" +testCase "round(~direction=#Closest(#AwayFromZero),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) 1.2) "error" +testCase "round(~direction=#Closest(#AwayFromZero),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) 1.5) "error" +testCase "round(~direction=#Closest(#AwayFromZero),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) 1.8) "error" +testCase "round(~direction=#Closest(#AwayFromZero),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) -1.2) "error" +testCase "round(~direction=#Closest(#AwayFromZero),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) -1.5) "error" +testCase "round(~direction=#Closest(#AwayFromZero),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#AwayFromZero) -1.8) "error" +testCase "round(~direction=#Closest(#Up),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#Up) 1.2) "error" +testCase "round(~direction=#Closest(#Up),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#Up) 1.5) "error" +testCase "round(~direction=#Closest(#Up),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#Up) 1.8) "error" +testCase "round(~direction=#Closest(#Up),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#Up) -1.2) "error" +testCase "round(~direction=#Closest(#Up),-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#Up) -1.5) "error" +testCase "round(~direction=#Closest(#Up),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#Up) -1.8) "error" +testCase "round(~direction=#Closest(#Down),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#Down) 1.2) "error" +testCase "round(~direction=#Closest(#Down),1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#Down) 1.5) "error" +testCase "round(~direction=#Closest(#Down),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#Down) 1.8) "error" +testCase "round(~direction=#Closest(#Down),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#Down) -1.2) "error" +testCase "round(~direction=#Closest(#Down),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#Down) -1.5) "error" +testCase "round(~direction=#Closest(#Down),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#Down) -1.8) "error" +testCase "round(~direction=#Closest(#ToEven),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 1.2) "error" +testCase "round(~direction=#Closest(#ToEven),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 1.5) "error" +testCase "round(~direction=#Closest(#ToEven),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 1.8) "error" +testCase "round(~direction=#Closest(#ToEven),2.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 2.2) "error" +testCase "round(~direction=#Closest(#ToEven),2.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 2.5) "error" +testCase "round(~direction=#Closest(#ToEven),2.8)" +<| fun _ -> + let expected = 3. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) 2.8) "error" +testCase "round(~direction=#Closest(#ToEven),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -1.2) "error" +testCase "round(~direction=#Closest(#ToEven),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -1.5) "error" +testCase "round(~direction=#Closest(#ToEven),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -1.8) "error" +testCase "round(~direction=#Closest(#ToEven),-2.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -2.2) "error" +testCase "round(~direction=#Closest(#ToEven),-2.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -2.5) "error" +testCase "round(~direction=#Closest(#ToEven),-2.8)" +<| fun _ -> + let expected = -3. + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -2.8) "error" +testCase "radians(pi)" +<| fun _ -> + let expected = pi + Expect.equal expected (Float.radians pi) "error" +testCase "sin(degrees(30.))" +<| fun _ -> + let expected = 0.5 + Expect.equal expected (Float.sin degrees(30.)) "error" +testCase "sin(radians(pi /. 6.))" +<| fun _ -> + let expected = 0.5 + Expect.equal expected (Float.sin radians(pi /. 6.)) "error" +testCase "squareRoot(4.)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.squareRoot 4.) "error" +testCase "squareRoot(20.25)" +<| fun _ -> + let expected = 4.5 + Expect.equal expected (Float.squareRoot 20.25) "error" +testCase "squareRoot(-1.)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.squareRoot -1.) "error" +testCase "subtract(4.,3.)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.subtract 4. 3.) "error" +testCase "tan(degrees(45.))" +<| fun _ -> + let expected = 0.9999999999999999 + Expect.equal expected (Float.tan degrees(45.)) "error" +testCase "tan(radians(pi /. 4.))" +<| fun _ -> + let expected = 0.9999999999999999 + Expect.equal expected (Float.tan radians(pi /. 4.)) "error" +testCase "tan(0.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.tan 0.) "error" +testCase "toInt(5.)" +<| fun _ -> + let expected = Some(5) + Expect.equal expected (Float.toInt 5.) "error" +testCase "toInt(5.3)" +<| fun _ -> + let expected = Some(5) + Expect.equal expected (Float.toInt 5.3) "error" +testCase "toInt(0.)" +<| fun _ -> + let expected = Some(0) + Expect.equal expected (Float.toInt 0.) "error" +testCase "toInt(-7.)" +<| fun _ -> + let expected = Some(-7) + Expect.equal expected (Float.toInt -7.) "error" +testCase "toInt(nan)" +<| fun _ -> + let expected = None + Expect.equal expected (Float.toInt nan) "error" +testCase "toInt(infinity)" +<| fun _ -> + let expected = None + Expect.equal expected (Float.toInt infinity) "error" +testCase "toInt(negativeInfinity)" +<| fun _ -> + let expected = None + Expect.equal expected (Float.toInt negativeInfinity) "error" +testCase "truncate(1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.truncate 1.2) "error" +testCase "truncate(1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.truncate 1.5) "error" +testCase "truncate(1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.truncate 1.8) "error" +testCase "truncate(-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.truncate -1.2) "error" +testCase "truncate(-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.truncate -1.5) "error" +testCase "truncate(-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.truncate -1.8) "error" +testCase "turns(1.)" +<| fun _ -> + let expected = 2. *. pi + Expect.equal expected (Float.turns 1.) "error" +] \ No newline at end of file diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs new file mode 100644 index 00000000..d7614bd5 --- /dev/null +++ b/test/fsharpTests/IntTest.fs @@ -0,0 +1,325 @@ +open Tablecloth +open Expecto + +[] +let tests = + testList + "Int" +[testCase "absolute(8)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.absolute 8) "error" +testCase "absolute(-7)" +<| fun _ -> + let expected = 7 + Expect.equal expected (Int.absolute -7) "error" +testCase "absolute(0)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.absolute 0) "error" +testCase "add(1,2)" +<| fun _ -> + let expected = 3 + Expect.equal expected (Int.add 1 2) "error" +testCase "add(1,1)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.add 1 1) "error" +testCase "clamp(5,~lower=0,~upper=8)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.clamp 5 ~lower:0 ~upper:8) "error" +testCase "clamp(9,~lower=0,~upper=8)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.clamp 9 ~lower:0 ~upper:8) "error" +testCase "clamp(1,~lower=2,~upper=8)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.clamp 1 ~lower:2 ~upper:8) "error" +testCase "clamp(5,~lower=-10,~upper=-5)" +<| fun _ -> + let expected = -5 + Expect.equal expected (Int.clamp 5 ~lower:-10 ~upper:-5) "error" +testCase "clamp(-15,~lower=-10,~upper=-5)" +<| fun _ -> + let expected = -10 + Expect.equal expected (Int.clamp -15 ~lower:-10 ~upper:-5) "error" +testCase "clamp(3,~lower=7,~upper=1)" +<| fun _ -> + Expect.equal (Int.clamp 3 ~lower:7 ~upper:1) |> failwith "error" +testCase "divide(3,~by=2)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.divide 3 ~by:2) "error" +testCase "divide(3,~by=0)" +<| fun _ -> + Expect.equal (Int.divide 3 ~by:0) |> failwith "error" +testCase "divide(27,~by=5)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.divide 27 ~by:5) "error" +testCase "divideFloat(3,~by=2)" +<| fun _ -> + let expected = 1.5 + Expect.equal expected (Int.divideFloat 3 ~by:2) "error" +testCase "divideFloat(27,~by=5)" +<| fun _ -> + let expected = 5.4 + Expect.equal expected (Int.divideFloat 27 ~by:5) "error" +testCase "divideFloat(8,~by=4)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.divideFloat 8 ~by:4) "error" +testCase "divideFloat(8,~by=0)" +<| fun _ -> + let expected = Float.infinity + Expect.equal expected (Int.divideFloat 8 ~by:0) "error" +testCase "divideFloat(-8,~by=0)" +<| fun _ -> + let expected = Float.negativeInfinity + Expect.equal expected (Int.divideFloat -8 ~by:0) "error" +testCase "fromString("0")" +<| fun _ -> + let expected = Some(0) + Expect.equal expected (Int.fromString "0") "error" +testCase "fromString("-0")" +<| fun _ -> + let expected = Some(-0) + Expect.equal expected (Int.fromString "-0") "error" +testCase "fromString("42")" +<| fun _ -> + let expected = Some(42) + Expect.equal expected (Int.fromString "42") "error" +testCase "fromString("123_456")" +<| fun _ -> + let expected = Some(123_456) + Expect.equal expected (Int.fromString "123_456") "error" +testCase "fromString("-42")" +<| fun _ -> + let expected = Some(-42) + Expect.equal expected (Int.fromString "-42") "error" +testCase "fromString("0XFF")" +<| fun _ -> + let expected = Some(255) + Expect.equal expected (Int.fromString "0XFF") "error" +testCase "fromString("0X000A")" +<| fun _ -> + let expected = Some(10) + Expect.equal expected (Int.fromString "0X000A") "error" +testCase "fromString("Infinity")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString "Infinity") "error" +testCase "fromString("-Infinity")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString "-Infinity") "error" +testCase "fromString("NaN")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString "NaN") "error" +testCase "fromString("abc")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString "abc") "error" +testCase "fromString("--4")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString "--4") "error" +testCase "fromString(" ")" +<| fun _ -> + let expected = None + Expect.equal expected (Int.fromString " ") "error" +testCase "inRange(3,~lower=2,~upper=4)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange 3 ~lower:2 ~upper:4) "error" +testCase "inRange(8,~lower=2,~upper=4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 8 ~lower:2 ~upper:4) "error" +testCase "inRange(1,~lower=2,~upper=4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 1 ~lower:2 ~upper:4) "error" +testCase "inRange(2,~lower=1,~upper=2)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 2 ~lower:1 ~upper:2) "error" +testCase "inRange(-6,~lower=-7,~upper=-5)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange -6 ~lower:-7 ~upper:-5) "error" +testCase "inRange(3,~lower=7,~upper=1)" +<| fun _ -> + Expect.equal (Int.inRange 3 ~lower:7 ~upper:1) |> failwith "error" +testCase "isEven(8)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.isEven 8) "error" +testCase "isEven(9)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.isEven 9) "error" +testCase "isEven(0)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.isEven 0) "error" +testCase "isOdd(8)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.isOdd 8) "error" +testCase "isOdd(9)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.isOdd 9) "error" +testCase "isOdd(0)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.isOdd 0) "error" +testCase "maximum(8,18)" +<| fun _ -> + let expected = 18 + Expect.equal expected (Int.maximum 8 18) "error" +testCase "maximum(5,0)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.maximum 5 0) "error" +testCase "maximum(-4,-1)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.maximum -4 -1) "error" +testCase "minimum(8,18)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.minimum 8 18) "error" +testCase "minimum(5,0)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.minimum 5 0) "error" +testCase "minimum(-4,-1)" +<| fun _ -> + let expected = -4 + Expect.equal expected (Int.minimum -4 -1) "error" +testCase "modulo(-4,~by=3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -4 ~by:3) "error" +testCase "modulo(-3,~by=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo -3 ~by:3) "error" +testCase "modulo(-2,~by=3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo -2 ~by:3) "error" +testCase "modulo(-1,~by=3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -1 ~by:3) "error" +testCase "modulo(0,~by=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 0 ~by:3) "error" +testCase "modulo(1,~by=3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 1 ~by:3) "error" +testCase "modulo(2,~by=3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo 2 ~by:3) "error" +testCase "modulo(3,~by=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 3 ~by:3) "error" +testCase "modulo(4,~by=3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 4 ~by:3) "error" +testCase "multiply(2,7)" +<| fun _ -> + let expected = 14 + Expect.equal expected (Int.multiply 2 7) "error" +testCase "negate(8)" +<| fun _ -> + let expected = -8 + Expect.equal expected (Int.negate 8) "error" +testCase "negate(-7)" +<| fun _ -> + let expected = 7 + Expect.equal expected (Int.negate -7) "error" +testCase "negate(0)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.negate 0) "error" +testCase "power(~base=7,~exponent=3)" +<| fun _ -> + let expected = 343 + Expect.equal expected (Int.power ~base:7 ~exponent:3) "error" +testCase "power(~base=0,~exponent=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.power ~base:0 ~exponent:3) "error" +testCase "power(~base=7,~exponent=0)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.power ~base:7 ~exponent:0) "error" +testCase "remainder(-4,~by=3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -4 ~by:3) "error" +testCase "remainder(-2,~by=3)" +<| fun _ -> + let expected = -2 + Expect.equal expected (Int.remainder -2 ~by:3) "error" +testCase "remainder(-1,~by=3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -1 ~by:3) "error" +testCase "remainder(0,~by=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 0 ~by:3) "error" +testCase "remainder(1,~by=3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 1 ~by:3) "error" +testCase "remainder(2,~by=3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.remainder 2 ~by:3) "error" +testCase "remainder(3,~by=3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 3 ~by:3) "error" +testCase "remainder(4,~by=3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 4 ~by:3) "error" +testCase "subtract(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.subtract 4 3) "error" +testCase "toFloat(5)" +<| fun _ -> + let expected = 5. + Expect.equal expected (Int.toFloat 5) "error" +testCase "toFloat(0)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Int.toFloat 0) "error" +testCase "toFloat(-7)" +<| fun _ -> + let expected = -7. + Expect.equal expected (Int.toFloat -7) "error" +testCase "toString(1)" +<| fun _ -> + let expected = "1" + Expect.equal expected (Int.toString 1) "error" +testCase "toString(-1)" +<| fun _ -> + let expected = "-1" + Expect.equal expected (Int.toString -1) "error" +] \ No newline at end of file diff --git a/test/ocamlTests/BoolTest.ml b/test/ocamlTests/BoolTest.ml new file mode 100644 index 00000000..660d92af --- /dev/null +++ b/test/ocamlTests/BoolTest.ml @@ -0,0 +1,33 @@ +open Tablecloth +open AlcoJest + +let suite = + suite "Bool" (fun () -> + let open Bool in +test "compare(true,true)" (fun () -> expect (Bool.compare true true) |> toEqual Eq.int 0) ; +test "compare(true,false)" (fun () -> expect (Bool.compare true false) |> toEqual Eq.int 1) ; +test "compare(false,true)" (fun () -> expect (Bool.compare false true) |> toEqual Eq.int -1) ; +test "compare(false,false)" (fun () -> expect (Bool.compare false false) |> toEqual Eq.int 0) ; +test "equal(true,true)" (fun () -> expect (Bool.equal true true) |> toEqual Eq.bool true) ; +test "equal(false,false)" (fun () -> expect (Bool.equal false false) |> toEqual Eq.bool true) ; +test "equal(true,false)" (fun () -> expect (Bool.equal true false) |> toEqual Eq.bool false) ; +test "fromInt(0)" (fun () -> expect (Bool.fromInt 0) |> toEqual (let open Eq in option bool) Some(false)) ; +test "fromInt(1)" (fun () -> expect (Bool.fromInt 1) |> toEqual (let open Eq in option bool) Some(true)) ; +test "fromInt(Int.minimumValue)" (fun () -> expect (Bool.fromInt Int.minimumValue) |> toEqual (let open Eq in option bool) None) ; +test "fromInt(-2)" (fun () -> expect (Bool.fromInt -2) |> toEqual (let open Eq in option bool) None) ; +test "fromInt(-1)" (fun () -> expect (Bool.fromInt -1) |> toEqual (let open Eq in option bool) None) ; +test "fromInt(2)" (fun () -> expect (Bool.fromInt 2) |> toEqual (let open Eq in option bool) None) ; +test "fromInt(Int.maximumValue)" (fun () -> expect (Bool.fromInt Int.maximumValue) |> toEqual (let open Eq in option bool) None) ; +test "fromString("true")" (fun () -> expect (Bool.fromString "true") |> toEqual (let open Eq in option bool) Some(true)) ; +test "fromString("false")" (fun () -> expect (Bool.fromString "false") |> toEqual (let open Eq in option bool) Some(false)) ; +test "fromString("True")" (fun () -> expect (Bool.fromString "True") |> toEqual (let open Eq in option bool) None) ; +test "fromString("1")" (fun () -> expect (Bool.fromString "1") |> toEqual (let open Eq in option bool) None) ; +test "toInt(true)" (fun () -> expect (Bool.toInt true) |> toEqual Eq.int 1) ; +test "toInt(false)" (fun () -> expect (Bool.toInt false) |> toEqual Eq.int 0) ; +test "toString(true)" (fun () -> expect (Bool.toString true) |> toEqual Eq.string "true") ; +test "toString(false)" (fun () -> expect (Bool.toString false) |> toEqual Eq.string "false") ; +test "xor(true,true)" (fun () -> expect (Bool.xor true true) |> toEqual Eq.bool false) ; +test "xor(true,false)" (fun () -> expect (Bool.xor true false) |> toEqual Eq.bool true) ; +test "xor(false,true)" (fun () -> expect (Bool.xor false true) |> toEqual Eq.bool true) ; +test "xor(false,false)" (fun () -> expect (Bool.xor false false) |> toEqual Eq.bool false) ; +) \ No newline at end of file diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml new file mode 100644 index 00000000..5adcca2f --- /dev/null +++ b/test/ocamlTests/CharTest.ml @@ -0,0 +1,54 @@ +open Tablecloth +open AlcoJest + +let suite = + suite "Char" (fun () -> + let open Char in +test "fromCode(97)" (fun () -> expect (Char.fromCode 97) |> toEqual (let open Eq in option char) Some('a')) ; +test "fromCode(-1)" (fun () -> expect (Char.fromCode -1) |> toEqual (let open Eq in option char) None) ; +test "fromCode(256)" (fun () -> expect (Char.fromCode 256) |> toEqual (let open Eq in option char) None) ; +test "fromString("a")" (fun () -> expect (Char.fromString "a") |> toEqual (let open Eq in option char) Some('a')) ; +test "fromString("abc")" (fun () -> expect (Char.fromString "abc") |> toEqual (let open Eq in option char) None) ; +test "fromString("")" (fun () -> expect (Char.fromString "") |> toEqual (let open Eq in option char) None) ; +test "isAlphanumeric('A')" (fun () -> expect (Char.isAlphanumeric 'A') |> toEqual Eq.bool true) ; +test "isAlphanumeric('?')" (fun () -> expect (Char.isAlphanumeric '?') |> toEqual Eq.bool false) ; +test "isDigit('0')" (fun () -> expect (Char.isDigit '0') |> toEqual Eq.bool true) ; +test "isDigit('1')" (fun () -> expect (Char.isDigit '1') |> toEqual Eq.bool true) ; +test "isDigit('2')" (fun () -> expect (Char.isDigit '2') |> toEqual Eq.bool true) ; +test "isDigit('3')" (fun () -> expect (Char.isDigit '3') |> toEqual Eq.bool true) ; +test "isDigit('4')" (fun () -> expect (Char.isDigit '4') |> toEqual Eq.bool true) ; +test "isDigit('5')" (fun () -> expect (Char.isDigit '5') |> toEqual Eq.bool true) ; +test "isDigit('6')" (fun () -> expect (Char.isDigit '6') |> toEqual Eq.bool true) ; +test "isDigit('7')" (fun () -> expect (Char.isDigit '7') |> toEqual Eq.bool true) ; +test "isDigit('8')" (fun () -> expect (Char.isDigit '8') |> toEqual Eq.bool true) ; +test "isDigit('9')" (fun () -> expect (Char.isDigit '9') |> toEqual Eq.bool true) ; +test "isDigit('a')" (fun () -> expect (Char.isDigit 'a') |> toEqual Eq.bool false) ; +test "isLetter('A')" (fun () -> expect (Char.isLetter 'A') |> toEqual Eq.bool true) ; +test "isLetter('7')" (fun () -> expect (Char.isLetter '7') |> toEqual Eq.bool false) ; +test "isLetter(' ')" (fun () -> expect (Char.isLetter ' ') |> toEqual Eq.bool false) ; +test "isLetter('\n')" (fun () -> expect (Char.isLetter '\n') |> toEqual Eq.bool false) ; +test "isLetter('\001')" (fun () -> expect (Char.isLetter '\001') |> toEqual Eq.bool false) ; +test "isLetter('\236')" (fun () -> expect (Char.isLetter '\236') |> toEqual Eq.bool false) ; +test "isLowercase('a')" (fun () -> expect (Char.isLowercase 'a') |> toEqual Eq.bool true) ; +test "isLowercase('7')" (fun () -> expect (Char.isLowercase '7') |> toEqual Eq.bool false) ; +test "isLowercase('\236')" (fun () -> expect (Char.isLowercase '\236') |> toEqual Eq.bool false) ; +test "isPrintable('~')" (fun () -> expect (Char.isPrintable '~') |> toEqual Eq.bool true) ; +test "isUppercase('A')" (fun () -> expect (Char.isUppercase 'A') |> toEqual Eq.bool true) ; +test "isUppercase('7')" (fun () -> expect (Char.isUppercase '7') |> toEqual Eq.bool false) ; +test "isUppercase('\237')" (fun () -> expect (Char.isUppercase '\237') |> toEqual Eq.bool false) ; +test "isWhitespace(' ')" (fun () -> expect (Char.isWhitespace ' ') |> toEqual Eq.bool true) ; +test "isWhitespace('a')" (fun () -> expect (Char.isWhitespace 'a') |> toEqual Eq.bool false) ; +test "toCode('a')" (fun () -> expect (Char.toCode 'a') |> toEqual Eq.int 97) ; +test "toDigit('0')" (fun () -> expect (Char.toDigit '0') |> toEqual (let open Eq in option int) Some(0)) ; +test "toDigit('8')" (fun () -> expect (Char.toDigit '8') |> toEqual (let open Eq in option int) Some(8)) ; +test "toDigit('a')" (fun () -> expect (Char.toDigit 'a') |> toEqual (let open Eq in option int) None) ; +test "toLowercase('A')" (fun () -> expect (Char.toLowercase 'A') |> toEqual Eq.char 'a') ; +test "toLowercase('a')" (fun () -> expect (Char.toLowercase 'a') |> toEqual Eq.char 'a') ; +test "toLowercase('7')" (fun () -> expect (Char.toLowercase '7') |> toEqual Eq.char '7') ; +test "toLowercase('\233')" (fun () -> expect (Char.toLowercase '\233') |> toEqual Eq.char '\233') ; +test "toString('a')" (fun () -> expect (Char.toString 'a') |> toEqual Eq.string "a") ; +test "toUppercase('a')" (fun () -> expect (Char.toUppercase 'a') |> toEqual Eq.char 'A') ; +test "toUppercase('A')" (fun () -> expect (Char.toUppercase 'A') |> toEqual Eq.char 'A') ; +test "toUppercase('7')" (fun () -> expect (Char.toUppercase '7') |> toEqual Eq.char '7') ; +test "toUppercase('\233')" (fun () -> expect (Char.toUppercase '\233') |> toEqual Eq.char '\233') ; +) \ No newline at end of file diff --git a/test/ocamlTests/FloatTest.ml b/test/ocamlTests/FloatTest.ml new file mode 100644 index 00000000..e3ce7307 --- /dev/null +++ b/test/ocamlTests/FloatTest.ml @@ -0,0 +1,190 @@ +open Tablecloth +open AlcoJest + +let suite = + suite "Float" (fun () -> + let open Float in +test "absolute(8.)" (fun () -> expect (Float.absolute 8.) |> toEqual Eq.float 8.) ; +test "absolute(-7.)" (fun () -> expect (Float.absolute -7.) |> toEqual Eq.float 7.) ; +test "absolute(0.)" (fun () -> expect (Float.absolute 0.) |> toEqual Eq.float 0.) ; +test "add(3.14,3.14)" (fun () -> expect (Float.add 3.14 3.14) |> toEqual Eq.float 6.28) ; +test "clamp(5.,~lower=0.,~upper=8.)" (fun () -> expect (Float.clamp 5. ~lower:0. ~upper:8.) |> toEqual Eq.float 5.) ; +test "clamp(9.,~lower=0.,~upper=8.)" (fun () -> expect (Float.clamp 9. ~lower:0. ~upper:8.) |> toEqual Eq.float 8.) ; +test "clamp(1.,~lower=2.,~upper=8.)" (fun () -> expect (Float.clamp 1. ~lower:2. ~upper:8.) |> toEqual Eq.float 2.) ; +test "clamp(5.,~lower=-10.,~upper=-5.)" (fun () -> expect (Float.clamp 5. ~lower:-10. ~upper:-5.) |> toEqual Eq.float -5.) ; +test "clamp(-15.,~lower=-10.,~upper=-5.)" (fun () -> expect (Float.clamp -15. ~lower:-10. ~upper:-5.) |> toEqual Eq.float -10.) ; +test "clamp(-6.6,~lower=-7.9,~upper=nan)" (fun () -> expect (Float.clamp -6.6 ~lower:-7.9 ~upper:nan) |> toEqual Eq.float NaN) ; +test "clamp(-6.6,~lower=nan,~upper=0.)" (fun () -> expect (Float.clamp -6.6 ~lower:nan ~upper:0.) |> toEqual Eq.float NaN) ; +test "clamp(nan,~lower=2.,~upper=8.)" (fun () -> expect (Float.clamp nan ~lower:2. ~upper:8.) |> toEqual Eq.float NaN) ; +test "clamp(3.,~lower=7.,~upper= 1.)" (fun () -> expect (fun () -> clamp 3. ~lower:7. ~upper: 1.) |> toThrow); +test "atan(0.)" (fun () -> expect (Float.atan 0.) |> toEqual Eq.radians 0.) ; +test "atan(1. /. 1.)" (fun () -> expect (Float.atan 1. /. 1.) |> toEqual Eq.radians 0.7853981633974483) ; +test "atan(1. /. -1.)" (fun () -> expect (Float.atan 1. /. -1.) |> toEqual Eq.radians -0.7853981633974483) ; +test "atan(-1. /. -1.)" (fun () -> expect (Float.atan -1. /. -1.) |> toEqual Eq.radians 0.7853981633974483) ; +test "atan(-1. /. 1.)" (fun () -> expect (Float.atan -1. /. 1.) |> toEqual Eq.radians -0.7853981633974483) ; +test "atan2(~y=0.,~x=0.)" (fun () -> expect (Float.atan2 ~y:0. ~x:0.) |> toEqual Eq.radians 0.) ; +test "atan2(~y=1.,~x=1.)" (fun () -> expect (Float.atan2 ~y:1. ~x:1.) |> toEqual Eq.radians 0.7853981633974483) ; +test "atan2(~y=1.,~x=-1.)" (fun () -> expect (Float.atan2 ~y:1. ~x:-1.) |> toEqual Eq.radians 2.356194490192345) ; +test "atan2(~y=-1.,~x=-1.)" (fun () -> expect (Float.atan2 ~y:-1. ~x:-1.) |> toEqual Eq.radians -2.356194490192345) ; +test "atan2(~y=-1.,~x=1.)" (fun () -> expect (Float.atan2 ~y:-1. ~x:1.) |> toEqual Eq.radians -0.7853981633974483) ; +test "ceiling(1.2)" (fun () -> expect (Float.ceiling 1.2) |> toEqual Eq.float 2.) ; +test "ceiling(1.5)" (fun () -> expect (Float.ceiling 1.5) |> toEqual Eq.float 2.) ; +test "ceiling(1.8)" (fun () -> expect (Float.ceiling 1.8) |> toEqual Eq.float 2.) ; +test "ceiling(-1.2)" (fun () -> expect (Float.ceiling -1.2) |> toEqual Eq.float -1.) ; +test "ceiling(-1.5)" (fun () -> expect (Float.ceiling -1.5) |> toEqual Eq.float -1.) ; +test "ceiling(-1.8)" (fun () -> expect (Float.ceiling -1.8) |> toEqual Eq.float -1.) ; +test "cos(degrees(60.))" (fun () -> expect (Float.cos degrees(60.)) |> toEqual Eq.float 0.5) ; +test "cos(radians(pi /. 3.))" (fun () -> expect (Float.cos radians(pi /. 3.)) |> toEqual Eq.float 0.5) ; +test "degrees(180.)" (fun () -> expect (Float.degrees 180.) |> toEqual Eq.radians pi) ; +test "divide(3.14,~by=2.)" (fun () -> expect (Float.divide 3.14 ~by:2.) |> toEqual Eq.float 1.57) ; +test "divide(3.14,~by=0.)" (fun () -> expect (Float.divide 3.14 ~by:0.) |> toEqual Eq.float infinity) ; +test "divide(3.14,~by=-0.)" (fun () -> expect (Float.divide 3.14 ~by:-0.) |> toEqual Eq.float negativeInfinity) ; +test "floor(1.2)" (fun () -> expect (Float.floor 1.2) |> toEqual Eq.float 1.) ; +test "floor(1.5)" (fun () -> expect (Float.floor 1.5) |> toEqual Eq.float 1.) ; +test "floor(1.8)" (fun () -> expect (Float.floor 1.8) |> toEqual Eq.float 1.) ; +test "floor(-1.2)" (fun () -> expect (Float.floor -1.2) |> toEqual Eq.float -2.) ; +test "floor(-1.5)" (fun () -> expect (Float.floor -1.5) |> toEqual Eq.float -2.) ; +test "floor(-1.8)" (fun () -> expect (Float.floor -1.8) |> toEqual Eq.float -2.) ; +test "fromInt(5)" (fun () -> expect (Float.fromInt 5) |> toEqual Eq.float 5.0) ; +test "fromInt(0)" (fun () -> expect (Float.fromInt 0) |> toEqual Eq.float 0.0) ; +test "fromInt(-7)" (fun () -> expect (Float.fromInt -7) |> toEqual Eq.float -7.0) ; +test "fromString("NaN")" (fun () -> expect (Float.fromString "NaN") |> toEqual (let open Eq in option float) Some(Js.Float._NaN),) ; +test "fromString("nan")" (fun () -> expect (Float.fromString "nan") |> toEqual (let open Eq in option float) Some(Js.Float._NaN)) ; +test "fromString("Infinity")" (fun () -> expect (Float.fromString "Infinity") |> toEqual (let open Eq in option float) Some(infinity)) ; +test "fromString("infinity")" (fun () -> expect (Float.fromString "infinity") |> toEqual (let open Eq in option float) None) ; +test "fromString("55")" (fun () -> expect (Float.fromString "55") |> toEqual (let open Eq in option float) Some(55.)) ; +test "fromString("-100")" (fun () -> expect (Float.fromString "-100") |> toEqual (let open Eq in option float) Some(-100.)) ; +test "fromString("not number")" (fun () -> expect (Float.fromString "not number") |> toEqual (let open Eq in option float) None) ; +test "hypotenuse(3.,4.)" (fun () -> expect (Float.hypotenuse 3. 4.) |> toEqual Eq.float 5.) ; +test "inRange(3.,~lower=2.,~upper=4.)" (fun () -> expect (Float.inRange 3. ~lower:2. ~upper:4.) |> toEqual Eq.bool true) ; +test "inRange(8.,~lower=2.,~upper=4.)" (fun () -> expect (Float.inRange 8. ~lower:2. ~upper:4.) |> toEqual Eq.bool false) ; +test "inRange(1.,~lower= 2.,~upper=4.)" (fun () -> expect (Float.inRange 1. ~lower: 2. ~upper:4.) |> toEqual Eq.bool false) ; +test "inRange(2.,~lower=1.,~upper=2.)" (fun () -> expect (Float.inRange 2. ~lower:1. ~upper:2.) |> toEqual Eq.bool false) ; +test "inRange(-6.6,~lower=-7.9,~upper=-5.2)" (fun () -> expect (Float.inRange -6.6 ~lower:-7.9 ~upper:-5.2) |> toEqual Eq.bool true) ; +test "inRange(-6.6,~lower=-7.9,~upper=nan)" (fun () -> expect (Float.inRange -6.6 ~lower:-7.9 ~upper:nan) |> toEqual Eq.bool false) ; +test "inRange(-6.6,~lower=nan,~upper=0.)" (fun () -> expect (Float.inRange -6.6 ~lower:nan ~upper:0.) |> toEqual Eq.bool false) ; +test "inRange(nan,~lower=2.,~upper=8.)" (fun () -> expect (Float.inRange nan ~lower:2. ~upper:8.) |> toEqual Eq.bool false) ; +test "inRange(3.,~lower=7.,~upper=1.)" (fun () -> expect (fun () -> inRange 3. ~lower:7. ~upper:1.) |> toThrow); +test "isFinite(infinity)" (fun () -> expect (Float.isFinite infinity) |> toEqual Eq.bool false) ; +test "isFinite(negativeInfinity)" (fun () -> expect (Float.isFinite negativeInfinity) |> toEqual Eq.bool false) ; +test "isFinite(nan)" (fun () -> expect (Float.isFinite nan) |> toEqual Eq.bool false) ; +test "isFinite(-5.)" (fun () -> expect (Float.isFinite -5.) |> toEqual Eq.bool true) ; +test "isFinite(-0.314)" (fun () -> expect (Float.isFinite -0.314) |> toEqual Eq.bool true) ; +test "isFinite(0.)" (fun () -> expect (Float.isFinite 0.) |> toEqual Eq.bool true) ; +test "isFinite(3.14)" (fun () -> expect (Float.isFinite 3.14) |> toEqual Eq.bool true) ; +test "isInfinite(infinity)" (fun () -> expect (Float.isInfinite infinity) |> toEqual Eq.bool true) ; +test "isInfinite(negativeInfinity)" (fun () -> expect (Float.isInfinite negativeInfinity) |> toEqual Eq.bool true) ; +test "isInfinite(nan)" (fun () -> expect (Float.isInfinite nan) |> toEqual Eq.bool false) ; +test "isInfinite(-5.)" (fun () -> expect (Float.isInfinite -5.) |> toEqual Eq.bool false) ; +test "isInfinite(-0.314)" (fun () -> expect (Float.isInfinite -0.314) |> toEqual Eq.bool false) ; +test "isInfinite(0.)" (fun () -> expect (Float.isInfinite 0.) |> toEqual Eq.bool false) ; +test "isInfinite(3.14)" (fun () -> expect (Float.isInfinite 3.14) |> toEqual Eq.bool false) ; +test "isInteger(5.0)" (fun () -> expect (Float.isInteger 5.0) |> toEqual Eq.bool true) ; +test "isInteger(pi)" (fun () -> expect (Float.isInteger pi) |> toEqual Eq.bool false) ; +test "isNaN(nan)" (fun () -> expect (Float.isNaN nan) |> toEqual Eq.bool true) ; +test "isNaN(91.4)" (fun () -> expect (Float.isNaN 91.4) |> toEqual Eq.bool false) ; +test "log(100.,~base=10.)" (fun () -> expect (Float.log 100. ~base:10.) |> toEqual Eq.float 2.) ; +test "log(256.,~base=2.)" (fun () -> expect (Float.log 256. ~base:2.) |> toEqual Eq.float 8.) ; +test "log(0.,~base=10.)" (fun () -> expect (Float.log 0. ~base:10.) |> toEqual Eq.float negativeInfinity) ; +test "maximum(7.,9.)" (fun () -> expect (Float.maximum 7. 9.) |> toEqual Eq.float 9.) ; +test "maximum(-4.,-1.)" (fun () -> expect (Float.maximum -4. -1.) |> toEqual Eq.float -1.) ; +test "maximum(7.,nan)" (fun () -> expect (Float.maximum 7. nan) |> toEqual Eq.float NaN) ; +test "maximum(7.,infinity)" (fun () -> expect (Float.maximum 7. infinity) |> toEqual Eq.float infinity) ; +test "maximum(7.,negativeInfinity)" (fun () -> expect (Float.maximum 7. negativeInfinity) |> toEqual Eq.float 7.) ; +test "minimum(7.,9.)" (fun () -> expect (Float.minimum 7. 9.) |> toEqual Eq.float 7.) ; +test "minimum(-4.,-1.)" (fun () -> expect (Float.minimum -4. -1.) |> toEqual Eq.float -4.) ; +test "minimum(7.,nan)" (fun () -> expect (Float.minimum 7. nan) |> toEqual Eq.float NaN) ; +test "minimum(7.,infinity)" (fun () -> expect (Float.minimum 7. infinity) |> toEqual Eq.float 7.) ; +test "minimum(7.,negativeInfinity)" (fun () -> expect (Float.minimum 7. negativeInfinity) |> toEqual Eq.float negativeInfinity) ; +test "multiply(2.,7.)" (fun () -> expect (Float.multiply 2. 7.) |> toEqual Eq.float 14.) ; +test "negate(8.)" (fun () -> expect (Float.negate 8.) |> toEqual Eq.float -8.) ; +test "negate(-7.)" (fun () -> expect (Float.negate -7.) |> toEqual Eq.float 7.) ; +test "negate(0.)" (fun () -> expect (Float.negate 0.) |> toEqual Eq.float -0.) ; +test "power(~base=7.,~exponent=3.)" (fun () -> expect (Float.power ~base:7. ~exponent:3.) |> toEqual Eq.float 343.) ; +test "power(~base=0.,~exponent=3.)" (fun () -> expect (Float.power ~base:0. ~exponent:3.) |> toEqual Eq.float 0.) ; +test "power(~base=7.,~exponent=0.)" (fun () -> expect (Float.power ~base:7. ~exponent:0.) |> toEqual Eq.float 1.) ; +test "round(~direction=#Zero,1.2)" (fun () -> expect (Float.round ~direction:#Zero 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Zero,1.5)" (fun () -> expect (Float.round ~direction:#Zero 1.5) |> toEqual Eq.float 1.) ; +test "round(~direction=#Zero,1.8)" (fun () -> expect (Float.round ~direction:#Zero 1.8) |> toEqual Eq.float 1.) ; +test "round(~direction=#Zero,-1.2)" (fun () -> expect (Float.round ~direction:#Zero -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Zero,-1.5)" (fun () -> expect (Float.round ~direction:#Zero -1.5) |> toEqual Eq.float -1.) ; +test "round(~direction=#Zero,-1.8)" (fun () -> expect (Float.round ~direction:#Zero -1.8) |> toEqual Eq.float -1.) ; +test "round(~direction=#AwayFromZero,1.2)" (fun () -> expect (Float.round ~direction:#AwayFromZero 1.2) |> toEqual Eq.float 2.) ; +test "round(~direction=#AwayFromZero,1.5)" (fun () -> expect (Float.round ~direction:#AwayFromZero 1.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#AwayFromZero,1.8)" (fun () -> expect (Float.round ~direction:#AwayFromZero 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#AwayFromZero,-1.2)" (fun () -> expect (Float.round ~direction:#AwayFromZero -1.2) |> toEqual Eq.float -2.) ; +test "round(~direction=#AwayFromZero,-1.5)" (fun () -> expect (Float.round ~direction:#AwayFromZero -1.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#AwayFromZero,-1.8)" (fun () -> expect (Float.round ~direction:#AwayFromZero -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Up,1.2)" (fun () -> expect (Float.round ~direction:#Up 1.2) |> toEqual Eq.float 2.) ; +test "round(~direction=#Up,1.5)" (fun () -> expect (Float.round ~direction:#Up 1.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#Up,1.8)" (fun () -> expect (Float.round ~direction:#Up 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Up,-1.2)" (fun () -> expect (Float.round ~direction:#Up -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Up,-1.5)" (fun () -> expect (Float.round ~direction:#Up -1.5) |> toEqual Eq.float -1.) ; +test "round(~direction=#Up,-1.8)" (fun () -> expect (Float.round ~direction:#Up -1.8) |> toEqual Eq.float -1.) ; +test "round(~direction=#Down,1.2)" (fun () -> expect (Float.round ~direction:#Down 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Down,1.5)" (fun () -> expect (Float.round ~direction:#Down 1.5) |> toEqual Eq.float 1.) ; +test "round(~direction=#Down,1.8)" (fun () -> expect (Float.round ~direction:#Down 1.8) |> toEqual Eq.float 1.) ; +test "round(~direction=#Down,-1.2)" (fun () -> expect (Float.round ~direction:#Down -1.2) |> toEqual Eq.float -2.) ; +test "round(~direction=#Down,-1.5)" (fun () -> expect (Float.round ~direction:#Down -1.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#Down,-1.8)" (fun () -> expect (Float.round ~direction:#Down -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#Zero),1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#Zero),1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) 1.5) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#Zero),1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#Zero),-1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#Zero),-1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) -1.5) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#Zero),-1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Zero) -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#AwayFromZero),1.2)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#AwayFromZero),1.5)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) 1.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#AwayFromZero),1.8)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#AwayFromZero),-1.2)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#AwayFromZero),-1.5)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) -1.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#AwayFromZero),-1.8)" (fun () -> expect (Float.round ~direction:#Closest(#AwayFromZero) -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#Up),1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Up) 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#Up),1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Up) 1.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#Up),1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Up) 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#Up),-1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Up) -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#Up),-1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Up) -1.5) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#Up),-1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Up) -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#Down),1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Down) 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#Down),1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Down) 1.5) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#Down),1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Down) 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#Down),-1.2)" (fun () -> expect (Float.round ~direction:#Closest(#Down) -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#Down),-1.5)" (fun () -> expect (Float.round ~direction:#Closest(#Down) -1.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#Down),-1.8)" (fun () -> expect (Float.round ~direction:#Closest(#Down) -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#ToEven),1.2)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 1.2) |> toEqual Eq.float 1.) ; +test "round(~direction=#Closest(#ToEven),1.5)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 1.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#ToEven),1.8)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 1.8) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#ToEven),2.2)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 2.2) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#ToEven),2.5)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 2.5) |> toEqual Eq.float 2.) ; +test "round(~direction=#Closest(#ToEven),2.8)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) 2.8) |> toEqual Eq.float 3.) ; +test "round(~direction=#Closest(#ToEven),-1.2)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -1.2) |> toEqual Eq.float -1.) ; +test "round(~direction=#Closest(#ToEven),-1.5)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -1.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#ToEven),-1.8)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -1.8) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#ToEven),-2.2)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -2.2) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#ToEven),-2.5)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -2.5) |> toEqual Eq.float -2.) ; +test "round(~direction=#Closest(#ToEven),-2.8)" (fun () -> expect (Float.round ~direction:#Closest(#ToEven) -2.8) |> toEqual Eq.float -3.) ; +test "radians(pi)" (fun () -> expect (Float.radians pi) |> toEqual Eq.radians pi) ; +test "sin(degrees(30.))" (fun () -> expect (Float.sin degrees(30.)) |> toEqual Eq.float 0.5) ; +test "sin(radians(pi /. 6.))" (fun () -> expect (Float.sin radians(pi /. 6.)) |> toEqual Eq.float 0.5) ; +test "squareRoot(4.)" (fun () -> expect (Float.squareRoot 4.) |> toEqual Eq.float 2.) ; +test "squareRoot(20.25)" (fun () -> expect (Float.squareRoot 20.25) |> toEqual Eq.float 4.5) ; +test "squareRoot(-1.)" (fun () -> expect (Float.squareRoot -1.) |> toEqual Eq.float NaN) ; +test "subtract(4.,3.)" (fun () -> expect (Float.subtract 4. 3.) |> toEqual Eq.float 1.) ; +test "tan(degrees(45.))" (fun () -> expect (Float.tan degrees(45.)) |> toEqual Eq.float 0.9999999999999999) ; +test "tan(radians(pi /. 4.))" (fun () -> expect (Float.tan radians(pi /. 4.)) |> toEqual Eq.float 0.9999999999999999) ; +test "tan(0.)" (fun () -> expect (Float.tan 0.) |> toEqual Eq.float 0.) ; +test "toInt(5.)" (fun () -> expect (Float.toInt 5.) |> toEqual (let open Eq in option int) Some(5)) ; +test "toInt(5.3)" (fun () -> expect (Float.toInt 5.3) |> toEqual (let open Eq in option int) Some(5)) ; +test "toInt(0.)" (fun () -> expect (Float.toInt 0.) |> toEqual (let open Eq in option int) Some(0)) ; +test "toInt(-7.)" (fun () -> expect (Float.toInt -7.) |> toEqual (let open Eq in option int) Some(-7)) ; +test "toInt(nan)" (fun () -> expect (Float.toInt nan) |> toEqual (let open Eq in option int) None) ; +test "toInt(infinity)" (fun () -> expect (Float.toInt infinity) |> toEqual (let open Eq in option int) None) ; +test "toInt(negativeInfinity)" (fun () -> expect (Float.toInt negativeInfinity) |> toEqual (let open Eq in option int) None) ; +test "truncate(1.2)" (fun () -> expect (Float.truncate 1.2) |> toEqual Eq.float 1.) ; +test "truncate(1.5)" (fun () -> expect (Float.truncate 1.5) |> toEqual Eq.float 1.) ; +test "truncate(1.8)" (fun () -> expect (Float.truncate 1.8) |> toEqual Eq.float 1.) ; +test "truncate(-1.2)" (fun () -> expect (Float.truncate -1.2) |> toEqual Eq.float -1.) ; +test "truncate(-1.5)" (fun () -> expect (Float.truncate -1.5) |> toEqual Eq.float -1.) ; +test "truncate(-1.8)" (fun () -> expect (Float.truncate -1.8) |> toEqual Eq.float -1.) ; +test "turns(1.)" (fun () -> expect (Float.turns 1.) |> toEqual Eq.radians 2. *. pi) ; +) \ No newline at end of file diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml new file mode 100644 index 00000000..77214297 --- /dev/null +++ b/test/ocamlTests/IntTest.ml @@ -0,0 +1,87 @@ +open Tablecloth +open AlcoJest + +let suite = + suite "Int" (fun () -> + let open Int in +test "absolute(8)" (fun () -> expect (Int.absolute 8) |> toEqual Eq.int 8) ; +test "absolute(-7)" (fun () -> expect (Int.absolute -7) |> toEqual Eq.int 7) ; +test "absolute(0)" (fun () -> expect (Int.absolute 0) |> toEqual Eq.int 0) ; +test "add(1,2)" (fun () -> expect (Int.add 1 2) |> toEqual Eq.int 3) ; +test "add(1,1)" (fun () -> expect (Int.add 1 1) |> toEqual Eq.int 2) ; +test "clamp(5,~lower=0,~upper=8)" (fun () -> expect (Int.clamp 5 ~lower:0 ~upper:8) |> toEqual Eq.int 5) ; +test "clamp(9,~lower=0,~upper=8)" (fun () -> expect (Int.clamp 9 ~lower:0 ~upper:8) |> toEqual Eq.int 8) ; +test "clamp(1,~lower=2,~upper=8)" (fun () -> expect (Int.clamp 1 ~lower:2 ~upper:8) |> toEqual Eq.int 2) ; +test "clamp(5,~lower=-10,~upper=-5)" (fun () -> expect (Int.clamp 5 ~lower:-10 ~upper:-5) |> toEqual Eq.int -5) ; +test "clamp(-15,~lower=-10,~upper=-5)" (fun () -> expect (Int.clamp -15 ~lower:-10 ~upper:-5) |> toEqual Eq.int -10) ; +test "clamp(3,~lower=7,~upper=1)" (fun () -> expect (fun () -> clamp 3 ~lower:7 ~upper:1) |> toThrow); +test "divide(3,~by=2)" (fun () -> expect (Int.divide 3 ~by:2) |> toEqual Eq.int 1) ; +test "divide(3,~by=0)" (fun () -> expect (fun () -> divide 3 ~by:0) |> toThrow); +test "divide(27,~by=5)" (fun () -> expect (Int.divide 27 ~by:5) |> toEqual Eq.int 5) ; +test "divideFloat(3,~by=2)" (fun () -> expect (Int.divideFloat 3 ~by:2) |> toEqual Eq.float 1.5) ; +test "divideFloat(27,~by=5)" (fun () -> expect (Int.divideFloat 27 ~by:5) |> toEqual Eq.float 5.4) ; +test "divideFloat(8,~by=4)" (fun () -> expect (Int.divideFloat 8 ~by:4) |> toEqual Eq.float 2) ; +test "divideFloat(8,~by=0)" (fun () -> expect (Int.divideFloat 8 ~by:0) |> toEqual Eq.float Float.infinity) ; +test "divideFloat(-8,~by=0)" (fun () -> expect (Int.divideFloat -8 ~by:0) |> toEqual Eq.float Float.negativeInfinity) ; +test "fromString("0")" (fun () -> expect (Int.fromString "0") |> toEqual (let open Eq in option int) Some(0)) ; +test "fromString("-0")" (fun () -> expect (Int.fromString "-0") |> toEqual (let open Eq in option int) Some(-0)) ; +test "fromString("42")" (fun () -> expect (Int.fromString "42") |> toEqual (let open Eq in option int) Some(42)) ; +test "fromString("123_456")" (fun () -> expect (Int.fromString "123_456") |> toEqual (let open Eq in option int) Some(123_456)) ; +test "fromString("-42")" (fun () -> expect (Int.fromString "-42") |> toEqual (let open Eq in option int) Some(-42)) ; +test "fromString("0XFF")" (fun () -> expect (Int.fromString "0XFF") |> toEqual (let open Eq in option int) Some(255)) ; +test "fromString("0X000A")" (fun () -> expect (Int.fromString "0X000A") |> toEqual (let open Eq in option int) Some(10)) ; +test "fromString("Infinity")" (fun () -> expect (Int.fromString "Infinity") |> toEqual (let open Eq in option int) None) ; +test "fromString("-Infinity")" (fun () -> expect (Int.fromString "-Infinity") |> toEqual (let open Eq in option int) None) ; +test "fromString("NaN")" (fun () -> expect (Int.fromString "NaN") |> toEqual (let open Eq in option int) None) ; +test "fromString("abc")" (fun () -> expect (Int.fromString "abc") |> toEqual (let open Eq in option int) None) ; +test "fromString("--4")" (fun () -> expect (Int.fromString "--4") |> toEqual (let open Eq in option int) None) ; +test "fromString(" ")" (fun () -> expect (Int.fromString " ") |> toEqual (let open Eq in option int) None) ; +test "inRange(3,~lower=2,~upper=4)" (fun () -> expect (Int.inRange 3 ~lower:2 ~upper:4) |> toEqual Eq.bool true) ; +test "inRange(8,~lower=2,~upper=4)" (fun () -> expect (Int.inRange 8 ~lower:2 ~upper:4) |> toEqual Eq.bool false) ; +test "inRange(1,~lower=2,~upper=4)" (fun () -> expect (Int.inRange 1 ~lower:2 ~upper:4) |> toEqual Eq.bool false) ; +test "inRange(2,~lower=1,~upper=2)" (fun () -> expect (Int.inRange 2 ~lower:1 ~upper:2) |> toEqual Eq.bool false) ; +test "inRange(-6,~lower=-7,~upper=-5)" (fun () -> expect (Int.inRange -6 ~lower:-7 ~upper:-5) |> toEqual Eq.bool true) ; +test "inRange(3,~lower=7,~upper=1)" (fun () -> expect (fun () -> inRange 3 ~lower:7 ~upper:1) |> toThrow); +test "isEven(8)" (fun () -> expect (Int.isEven 8) |> toEqual Eq.bool true) ; +test "isEven(9)" (fun () -> expect (Int.isEven 9) |> toEqual Eq.bool false) ; +test "isEven(0)" (fun () -> expect (Int.isEven 0) |> toEqual Eq.bool true) ; +test "isOdd(8)" (fun () -> expect (Int.isOdd 8) |> toEqual Eq.bool false) ; +test "isOdd(9)" (fun () -> expect (Int.isOdd 9) |> toEqual Eq.bool true) ; +test "isOdd(0)" (fun () -> expect (Int.isOdd 0) |> toEqual Eq.bool false) ; +test "maximum(8,18)" (fun () -> expect (Int.maximum 8 18) |> toEqual Eq.int 18) ; +test "maximum(5,0)" (fun () -> expect (Int.maximum 5 0) |> toEqual Eq.int 5) ; +test "maximum(-4,-1)" (fun () -> expect (Int.maximum -4 -1) |> toEqual Eq.int -1) ; +test "minimum(8,18)" (fun () -> expect (Int.minimum 8 18) |> toEqual Eq.int 8) ; +test "minimum(5,0)" (fun () -> expect (Int.minimum 5 0) |> toEqual Eq.int 0) ; +test "minimum(-4,-1)" (fun () -> expect (Int.minimum -4 -1) |> toEqual Eq.int -4) ; +test "modulo(-4,~by=3)" (fun () -> expect (Int.modulo -4 ~by:3) |> toEqual Eq.int 2) ; +test "modulo(-3,~by=3)" (fun () -> expect (Int.modulo -3 ~by:3) |> toEqual Eq.int 0) ; +test "modulo(-2,~by=3)" (fun () -> expect (Int.modulo -2 ~by:3) |> toEqual Eq.int 1) ; +test "modulo(-1,~by=3)" (fun () -> expect (Int.modulo -1 ~by:3) |> toEqual Eq.int 2) ; +test "modulo(0,~by=3)" (fun () -> expect (Int.modulo 0 ~by:3) |> toEqual Eq.int 0) ; +test "modulo(1,~by=3)" (fun () -> expect (Int.modulo 1 ~by:3) |> toEqual Eq.int 1) ; +test "modulo(2,~by=3)" (fun () -> expect (Int.modulo 2 ~by:3) |> toEqual Eq.int 2) ; +test "modulo(3,~by=3)" (fun () -> expect (Int.modulo 3 ~by:3) |> toEqual Eq.int 0) ; +test "modulo(4,~by=3)" (fun () -> expect (Int.modulo 4 ~by:3) |> toEqual Eq.int 1) ; +test "multiply(2,7)" (fun () -> expect (Int.multiply 2 7) |> toEqual Eq.int 14) ; +test "negate(8)" (fun () -> expect (Int.negate 8) |> toEqual Eq.int -8) ; +test "negate(-7)" (fun () -> expect (Int.negate -7) |> toEqual Eq.int 7) ; +test "negate(0)" (fun () -> expect (Int.negate 0) |> toEqual Eq.int 0) ; +test "power(~base=7,~exponent=3)" (fun () -> expect (Int.power ~base:7 ~exponent:3) |> toEqual Eq.int 343) ; +test "power(~base=0,~exponent=3)" (fun () -> expect (Int.power ~base:0 ~exponent:3) |> toEqual Eq.int 0) ; +test "power(~base=7,~exponent=0)" (fun () -> expect (Int.power ~base:7 ~exponent:0) |> toEqual Eq.int 1) ; +test "remainder(-4,~by=3)" (fun () -> expect (Int.remainder -4 ~by:3) |> toEqual Eq.int -1) ; +test "remainder(-2,~by=3)" (fun () -> expect (Int.remainder -2 ~by:3) |> toEqual Eq.int -2) ; +test "remainder(-1,~by=3)" (fun () -> expect (Int.remainder -1 ~by:3) |> toEqual Eq.int -1) ; +test "remainder(0,~by=3)" (fun () -> expect (Int.remainder 0 ~by:3) |> toEqual Eq.int 0) ; +test "remainder(1,~by=3)" (fun () -> expect (Int.remainder 1 ~by:3) |> toEqual Eq.int 1) ; +test "remainder(2,~by=3)" (fun () -> expect (Int.remainder 2 ~by:3) |> toEqual Eq.int 2) ; +test "remainder(3,~by=3)" (fun () -> expect (Int.remainder 3 ~by:3) |> toEqual Eq.int 0) ; +test "remainder(4,~by=3)" (fun () -> expect (Int.remainder 4 ~by:3) |> toEqual Eq.int 1) ; +test "subtract(4,3)" (fun () -> expect (Int.subtract 4 3) |> toEqual Eq.int 1) ; +test "toFloat(5)" (fun () -> expect (Int.toFloat 5) |> toEqual Eq.float 5.) ; +test "toFloat(0)" (fun () -> expect (Int.toFloat 0) |> toEqual Eq.float 0.) ; +test "toFloat(-7)" (fun () -> expect (Int.toFloat -7) |> toEqual Eq.float -7.) ; +test "toString(1)" (fun () -> expect (Int.toString 1) |> toEqual Eq.string "1") ; +test "toString(-1)" (fun () -> expect (Int.toString -1) |> toEqual Eq.string "-1") ; +) \ No newline at end of file diff --git a/test/rescriptTests/BoolTest.res b/test/rescriptTests/BoolTest.res new file mode 100644 index 00000000..ffcdcf4a --- /dev/null +++ b/test/rescriptTests/BoolTest.res @@ -0,0 +1,43 @@ +open Tablecloth +open AlcoJest + +let suite= suite("Bool", () => { + open Bool +test ("compare(true,true)", () => expect(Bool.compare(true,true)) |> toEqual(Eq.int, 0)) +test ("compare(true,false)", () => expect(Bool.compare(true,false)) |> toEqual(Eq.int, 1)) +test ("compare(false,true)", () => expect(Bool.compare(false,true)) |> toEqual(Eq.int, -1)) +test ("compare(false,false)", () => expect(Bool.compare(false,false)) |> toEqual(Eq.int, 0)) +test ("equal(true,true)", () => expect(Bool.equal(true,true)) |> toEqual(Eq.bool, true)) +test ("equal(false,false)", () => expect(Bool.equal(false,false)) |> toEqual(Eq.bool, true)) +test ("equal(true,false)", () => expect(Bool.equal(true,false)) |> toEqual(Eq.bool, false)) +test ("fromInt(0)", () => expect(Bool.fromInt(0)) |> toEqual({open Eq +option(bool)}, Some(false))) +test ("fromInt(1)", () => expect(Bool.fromInt(1)) |> toEqual({open Eq +option(bool)}, Some(true))) +test ("fromInt(Int.minimumValue)", () => expect(Bool.fromInt(Int.minimumValue)) |> toEqual({open Eq +option(bool)}, None)) +test ("fromInt(-2)", () => expect(Bool.fromInt(-2)) |> toEqual({open Eq +option(bool)}, None)) +test ("fromInt(-1)", () => expect(Bool.fromInt(-1)) |> toEqual({open Eq +option(bool)}, None)) +test ("fromInt(2)", () => expect(Bool.fromInt(2)) |> toEqual({open Eq +option(bool)}, None)) +test ("fromInt(Int.maximumValue)", () => expect(Bool.fromInt(Int.maximumValue)) |> toEqual({open Eq +option(bool)}, None)) +test ("fromString(true)", () => expect(Bool.fromString("true")) |> toEqual({open Eq +option(bool)}, Some(true))) +test ("fromString(false)", () => expect(Bool.fromString("false")) |> toEqual({open Eq +option(bool)}, Some(false))) +test ("fromString(True)", () => expect(Bool.fromString("True")) |> toEqual({open Eq +option(bool)}, None)) +test ("fromString(1)", () => expect(Bool.fromString("1")) |> toEqual({open Eq +option(bool)}, None)) +test ("toInt(true)", () => expect(Bool.toInt(true)) |> toEqual(Eq.int, 1)) +test ("toInt(false)", () => expect(Bool.toInt(false)) |> toEqual(Eq.int, 0)) +test ("toString(true)", () => expect(Bool.toString(true)) |> toEqual(Eq.string, "true")) +test ("toString(false)", () => expect(Bool.toString(false)) |> toEqual(Eq.string, "false")) +test ("xor(true,true)", () => expect(Bool.xor(true,true)) |> toEqual(Eq.bool, false)) +test ("xor(true,false)", () => expect(Bool.xor(true,false)) |> toEqual(Eq.bool, true)) +test ("xor(false,true)", () => expect(Bool.xor(false,true)) |> toEqual(Eq.bool, true)) +test ("xor(false,false)", () => expect(Bool.xor(false,false)) |> toEqual(Eq.bool, false)) +}) \ No newline at end of file diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res new file mode 100644 index 00000000..0c6f6c23 --- /dev/null +++ b/test/rescriptTests/CharTest.res @@ -0,0 +1,62 @@ +open Tablecloth +open AlcoJest + +let suite= suite("Char", () => { + open Char +test ("fromCode(97)", () => expect(Char.fromCode(97)) |> toEqual({open Eq +option(char)}, Some('a'))) +test ("fromCode(-1)", () => expect(Char.fromCode(-1)) |> toEqual({open Eq +option(char)}, None)) +test ("fromCode(256)", () => expect(Char.fromCode(256)) |> toEqual({open Eq +option(char)}, None)) +test ("fromString(a)", () => expect(Char.fromString("a")) |> toEqual({open Eq +option(char)}, Some('a'))) +test ("fromString(abc)", () => expect(Char.fromString("abc")) |> toEqual({open Eq +option(char)}, None)) +test ("fromString()", () => expect(Char.fromString("")) |> toEqual({open Eq +option(char)}, None)) +test ("isAlphanumeric('A')", () => expect(Char.isAlphanumeric('A')) |> toEqual(Eq.bool, true)) +test ("isAlphanumeric('?')", () => expect(Char.isAlphanumeric('?')) |> toEqual(Eq.bool, false)) +test ("isDigit('0')", () => expect(Char.isDigit('0')) |> toEqual(Eq.bool, true)) +test ("isDigit('1')", () => expect(Char.isDigit('1')) |> toEqual(Eq.bool, true)) +test ("isDigit('2')", () => expect(Char.isDigit('2')) |> toEqual(Eq.bool, true)) +test ("isDigit('3')", () => expect(Char.isDigit('3')) |> toEqual(Eq.bool, true)) +test ("isDigit('4')", () => expect(Char.isDigit('4')) |> toEqual(Eq.bool, true)) +test ("isDigit('5')", () => expect(Char.isDigit('5')) |> toEqual(Eq.bool, true)) +test ("isDigit('6')", () => expect(Char.isDigit('6')) |> toEqual(Eq.bool, true)) +test ("isDigit('7')", () => expect(Char.isDigit('7')) |> toEqual(Eq.bool, true)) +test ("isDigit('8')", () => expect(Char.isDigit('8')) |> toEqual(Eq.bool, true)) +test ("isDigit('9')", () => expect(Char.isDigit('9')) |> toEqual(Eq.bool, true)) +test ("isDigit('a')", () => expect(Char.isDigit('a')) |> toEqual(Eq.bool, false)) +test ("isLetter('A')", () => expect(Char.isLetter('A')) |> toEqual(Eq.bool, true)) +test ("isLetter('7')", () => expect(Char.isLetter('7')) |> toEqual(Eq.bool, false)) +test ("isLetter(' ')", () => expect(Char.isLetter(' ')) |> toEqual(Eq.bool, false)) +test ("isLetter('\n')", () => expect(Char.isLetter('\n')) |> toEqual(Eq.bool, false)) +test ("isLetter('\001')", () => expect(Char.isLetter('\001')) |> toEqual(Eq.bool, false)) +test ("isLetter('\236')", () => expect(Char.isLetter('\236')) |> toEqual(Eq.bool, false)) +test ("isLowercase('a')", () => expect(Char.isLowercase('a')) |> toEqual(Eq.bool, true)) +test ("isLowercase('7')", () => expect(Char.isLowercase('7')) |> toEqual(Eq.bool, false)) +test ("isLowercase('\236')", () => expect(Char.isLowercase('\236')) |> toEqual(Eq.bool, false)) +test ("isPrintable('~')", () => expect(Char.isPrintable('~')) |> toEqual(Eq.bool, true)) +test ("isUppercase('A')", () => expect(Char.isUppercase('A')) |> toEqual(Eq.bool, true)) +test ("isUppercase('7')", () => expect(Char.isUppercase('7')) |> toEqual(Eq.bool, false)) +test ("isUppercase('\237')", () => expect(Char.isUppercase('\237')) |> toEqual(Eq.bool, false)) +test ("isWhitespace(' ')", () => expect(Char.isWhitespace(' ')) |> toEqual(Eq.bool, true)) +test ("isWhitespace('a')", () => expect(Char.isWhitespace('a')) |> toEqual(Eq.bool, false)) +test ("toCode('a')", () => expect(Char.toCode('a')) |> toEqual(Eq.int, 97)) +test ("toDigit('0')", () => expect(Char.toDigit('0')) |> toEqual({open Eq +option(int)}, Some(0))) +test ("toDigit('8')", () => expect(Char.toDigit('8')) |> toEqual({open Eq +option(int)}, Some(8))) +test ("toDigit('a')", () => expect(Char.toDigit('a')) |> toEqual({open Eq +option(int)}, None)) +test ("toLowercase('A')", () => expect(Char.toLowercase('A')) |> toEqual(Eq.char, 'a')) +test ("toLowercase('a')", () => expect(Char.toLowercase('a')) |> toEqual(Eq.char, 'a')) +test ("toLowercase('7')", () => expect(Char.toLowercase('7')) |> toEqual(Eq.char, '7')) +test ("toLowercase('\233')", () => expect(Char.toLowercase('\233')) |> toEqual(Eq.char, '\233')) +test ("toString('a')", () => expect(Char.toString('a')) |> toEqual(Eq.string, "a")) +test ("toUppercase('a')", () => expect(Char.toUppercase('a')) |> toEqual(Eq.char, 'A')) +test ("toUppercase('A')", () => expect(Char.toUppercase('A')) |> toEqual(Eq.char, 'A')) +test ("toUppercase('7')", () => expect(Char.toUppercase('7')) |> toEqual(Eq.char, '7')) +test ("toUppercase('\233')", () => expect(Char.toUppercase('\233')) |> toEqual(Eq.char, '\233')) +}) \ No newline at end of file diff --git a/test/rescriptTests/FloatTest.res b/test/rescriptTests/FloatTest.res new file mode 100644 index 00000000..39326ce3 --- /dev/null +++ b/test/rescriptTests/FloatTest.res @@ -0,0 +1,203 @@ +open Tablecloth +open AlcoJest + +let suite= suite("Float", () => { + open Float +test ("absolute(8.)", () => expect(Float.absolute(8.)) |> toEqual(Eq.float, 8.)) +test ("absolute(-7.)", () => expect(Float.absolute(-7.)) |> toEqual(Eq.float, 7.)) +test ("absolute(0.)", () => expect(Float.absolute(0.)) |> toEqual(Eq.float, 0.)) +test ("add(3.14,3.14)", () => expect(Float.add(3.14,3.14)) |> toEqual(Eq.float, 6.28)) +test ("clamp(5.,~lower=0.,~upper=8.)", () => expect(Float.clamp(5.,~lower=0.,~upper=8.)) |> toEqual(Eq.float, 5.)) +test ("clamp(9.,~lower=0.,~upper=8.)", () => expect(Float.clamp(9.,~lower=0.,~upper=8.)) |> toEqual(Eq.float, 8.)) +test ("clamp(1.,~lower=2.,~upper=8.)", () => expect(Float.clamp(1.,~lower=2.,~upper=8.)) |> toEqual(Eq.float, 2.)) +test ("clamp(5.,~lower=-10.,~upper=-5.)", () => expect(Float.clamp(5.,~lower=-10.,~upper=-5.)) |> toEqual(Eq.float, -5.)) +test ("clamp(-15.,~lower=-10.,~upper=-5.)", () => expect(Float.clamp(-15.,~lower=-10.,~upper=-5.)) |> toEqual(Eq.float, -10.)) +test ("clamp(-6.6,~lower=-7.9,~upper=nan)", () => expect(Float.clamp(-6.6,~lower=-7.9,~upper=nan)) |> toEqual(Eq.float, NaN)) +test ("clamp(-6.6,~lower=nan,~upper=0.)", () => expect(Float.clamp(-6.6,~lower=nan,~upper=0.)) |> toEqual(Eq.float, NaN)) +test ("clamp(nan,~lower=2.,~upper=8.)", () => expect(Float.clamp(nan,~lower=2.,~upper=8.)) |> toEqual(Eq.float, NaN)) +test ("clamp(3.,~lower=7.,~upper= 1.)", () => expect(() => Float.clamp(3.,~lower=7.,~upper= 1.)) |> toThrow) +test ("atan(0.)", () => expect(Float.atan(0.)) |> toEqual(Eq.radians, 0.)) +test ("atan(1. /. 1.)", () => expect(Float.atan(1. /. 1.)) |> toEqual(Eq.radians, 0.7853981633974483)) +test ("atan(1. /. -1.)", () => expect(Float.atan(1. /. -1.)) |> toEqual(Eq.radians, -0.7853981633974483)) +test ("atan(-1. /. -1.)", () => expect(Float.atan(-1. /. -1.)) |> toEqual(Eq.radians, 0.7853981633974483)) +test ("atan(-1. /. 1.)", () => expect(Float.atan(-1. /. 1.)) |> toEqual(Eq.radians, -0.7853981633974483)) +test ("atan2(~y=0.,~x=0.)", () => expect(Float.atan2(~y=0.,~x=0.)) |> toEqual(Eq.radians, 0.)) +test ("atan2(~y=1.,~x=1.)", () => expect(Float.atan2(~y=1.,~x=1.)) |> toEqual(Eq.radians, 0.7853981633974483)) +test ("atan2(~y=1.,~x=-1.)", () => expect(Float.atan2(~y=1.,~x=-1.)) |> toEqual(Eq.radians, 2.356194490192345)) +test ("atan2(~y=-1.,~x=-1.)", () => expect(Float.atan2(~y=-1.,~x=-1.)) |> toEqual(Eq.radians, -2.356194490192345)) +test ("atan2(~y=-1.,~x=1.)", () => expect(Float.atan2(~y=-1.,~x=1.)) |> toEqual(Eq.radians, -0.7853981633974483)) +test ("ceiling(1.2)", () => expect(Float.ceiling(1.2)) |> toEqual(Eq.float, 2.)) +test ("ceiling(1.5)", () => expect(Float.ceiling(1.5)) |> toEqual(Eq.float, 2.)) +test ("ceiling(1.8)", () => expect(Float.ceiling(1.8)) |> toEqual(Eq.float, 2.)) +test ("ceiling(-1.2)", () => expect(Float.ceiling(-1.2)) |> toEqual(Eq.float, -1.)) +test ("ceiling(-1.5)", () => expect(Float.ceiling(-1.5)) |> toEqual(Eq.float, -1.)) +test ("ceiling(-1.8)", () => expect(Float.ceiling(-1.8)) |> toEqual(Eq.float, -1.)) +test ("cos(degrees(60.))", () => expect(Float.cos(degrees(60.))) |> toEqual(Eq.float, 0.5)) +test ("cos(radians(pi /. 3.))", () => expect(Float.cos(radians(pi /. 3.))) |> toEqual(Eq.float, 0.5)) +test ("degrees(180.)", () => expect(Float.degrees(180.)) |> toEqual(Eq.radians, pi)) +test ("divide(3.14,~by=2.)", () => expect(Float.divide(3.14,~by=2.)) |> toEqual(Eq.float, 1.57)) +test ("divide(3.14,~by=0.)", () => expect(Float.divide(3.14,~by=0.)) |> toEqual(Eq.float, infinity)) +test ("divide(3.14,~by=-0.)", () => expect(Float.divide(3.14,~by=-0.)) |> toEqual(Eq.float, negativeInfinity)) +test ("floor(1.2)", () => expect(Float.floor(1.2)) |> toEqual(Eq.float, 1.)) +test ("floor(1.5)", () => expect(Float.floor(1.5)) |> toEqual(Eq.float, 1.)) +test ("floor(1.8)", () => expect(Float.floor(1.8)) |> toEqual(Eq.float, 1.)) +test ("floor(-1.2)", () => expect(Float.floor(-1.2)) |> toEqual(Eq.float, -2.)) +test ("floor(-1.5)", () => expect(Float.floor(-1.5)) |> toEqual(Eq.float, -2.)) +test ("floor(-1.8)", () => expect(Float.floor(-1.8)) |> toEqual(Eq.float, -2.)) +test ("fromInt(5)", () => expect(Float.fromInt(5)) |> toEqual(Eq.float, 5.0)) +test ("fromInt(0)", () => expect(Float.fromInt(0)) |> toEqual(Eq.float, 0.0)) +test ("fromInt(-7)", () => expect(Float.fromInt(-7)) |> toEqual(Eq.float, -7.0)) +test ("fromString(NaN)", () => expect(Float.fromString("NaN")) |> toEqual({open Eq +option(float)}, Some(Js.Float._NaN),)) +test ("fromString(nan)", () => expect(Float.fromString("nan")) |> toEqual({open Eq +option(float)}, Some(Js.Float._NaN))) +test ("fromString(Infinity)", () => expect(Float.fromString("Infinity")) |> toEqual({open Eq +option(float)}, Some(infinity))) +test ("fromString(infinity)", () => expect(Float.fromString("infinity")) |> toEqual({open Eq +option(float)}, None)) +test ("fromString(55)", () => expect(Float.fromString("55")) |> toEqual({open Eq +option(float)}, Some(55.))) +test ("fromString(-100)", () => expect(Float.fromString("-100")) |> toEqual({open Eq +option(float)}, Some(-100.))) +test ("fromString(not number)", () => expect(Float.fromString("not number")) |> toEqual({open Eq +option(float)}, None)) +test ("hypotenuse(3.,4.)", () => expect(Float.hypotenuse(3.,4.)) |> toEqual(Eq.float, 5.)) +test ("inRange(3.,~lower=2.,~upper=4.)", () => expect(Float.inRange(3.,~lower=2.,~upper=4.)) |> toEqual(Eq.bool, true)) +test ("inRange(8.,~lower=2.,~upper=4.)", () => expect(Float.inRange(8.,~lower=2.,~upper=4.)) |> toEqual(Eq.bool, false)) +test ("inRange(1.,~lower= 2.,~upper=4.)", () => expect(Float.inRange(1.,~lower= 2.,~upper=4.)) |> toEqual(Eq.bool, false)) +test ("inRange(2.,~lower=1.,~upper=2.)", () => expect(Float.inRange(2.,~lower=1.,~upper=2.)) |> toEqual(Eq.bool, false)) +test ("inRange(-6.6,~lower=-7.9,~upper=-5.2)", () => expect(Float.inRange(-6.6,~lower=-7.9,~upper=-5.2)) |> toEqual(Eq.bool, true)) +test ("inRange(-6.6,~lower=-7.9,~upper=nan)", () => expect(Float.inRange(-6.6,~lower=-7.9,~upper=nan)) |> toEqual(Eq.bool, false)) +test ("inRange(-6.6,~lower=nan,~upper=0.)", () => expect(Float.inRange(-6.6,~lower=nan,~upper=0.)) |> toEqual(Eq.bool, false)) +test ("inRange(nan,~lower=2.,~upper=8.)", () => expect(Float.inRange(nan,~lower=2.,~upper=8.)) |> toEqual(Eq.bool, false)) +test ("inRange(3.,~lower=7.,~upper=1.)", () => expect(() => Float.inRange(3.,~lower=7.,~upper=1.)) |> toThrow) +test ("isFinite(infinity)", () => expect(Float.isFinite(infinity)) |> toEqual(Eq.bool, false)) +test ("isFinite(negativeInfinity)", () => expect(Float.isFinite(negativeInfinity)) |> toEqual(Eq.bool, false)) +test ("isFinite(nan)", () => expect(Float.isFinite(nan)) |> toEqual(Eq.bool, false)) +test ("isFinite(-5.)", () => expect(Float.isFinite(-5.)) |> toEqual(Eq.bool, true)) +test ("isFinite(-0.314)", () => expect(Float.isFinite(-0.314)) |> toEqual(Eq.bool, true)) +test ("isFinite(0.)", () => expect(Float.isFinite(0.)) |> toEqual(Eq.bool, true)) +test ("isFinite(3.14)", () => expect(Float.isFinite(3.14)) |> toEqual(Eq.bool, true)) +test ("isInfinite(infinity)", () => expect(Float.isInfinite(infinity)) |> toEqual(Eq.bool, true)) +test ("isInfinite(negativeInfinity)", () => expect(Float.isInfinite(negativeInfinity)) |> toEqual(Eq.bool, true)) +test ("isInfinite(nan)", () => expect(Float.isInfinite(nan)) |> toEqual(Eq.bool, false)) +test ("isInfinite(-5.)", () => expect(Float.isInfinite(-5.)) |> toEqual(Eq.bool, false)) +test ("isInfinite(-0.314)", () => expect(Float.isInfinite(-0.314)) |> toEqual(Eq.bool, false)) +test ("isInfinite(0.)", () => expect(Float.isInfinite(0.)) |> toEqual(Eq.bool, false)) +test ("isInfinite(3.14)", () => expect(Float.isInfinite(3.14)) |> toEqual(Eq.bool, false)) +test ("isInteger(5.0)", () => expect(Float.isInteger(5.0)) |> toEqual(Eq.bool, true)) +test ("isInteger(pi)", () => expect(Float.isInteger(pi)) |> toEqual(Eq.bool, false)) +test ("isNaN(nan)", () => expect(Float.isNaN(nan)) |> toEqual(Eq.bool, true)) +test ("isNaN(91.4)", () => expect(Float.isNaN(91.4)) |> toEqual(Eq.bool, false)) +test ("log(100.,~base=10.)", () => expect(Float.log(100.,~base=10.)) |> toEqual(Eq.float, 2.)) +test ("log(256.,~base=2.)", () => expect(Float.log(256.,~base=2.)) |> toEqual(Eq.float, 8.)) +test ("log(0.,~base=10.)", () => expect(Float.log(0.,~base=10.)) |> toEqual(Eq.float, negativeInfinity)) +test ("maximum(7.,9.)", () => expect(Float.maximum(7.,9.)) |> toEqual(Eq.float, 9.)) +test ("maximum(-4.,-1.)", () => expect(Float.maximum(-4.,-1.)) |> toEqual(Eq.float, -1.)) +test ("maximum(7.,nan)", () => expect(Float.maximum(7.,nan)) |> toEqual(Eq.float, NaN)) +test ("maximum(7.,infinity)", () => expect(Float.maximum(7.,infinity)) |> toEqual(Eq.float, infinity)) +test ("maximum(7.,negativeInfinity)", () => expect(Float.maximum(7.,negativeInfinity)) |> toEqual(Eq.float, 7.)) +test ("minimum(7.,9.)", () => expect(Float.minimum(7.,9.)) |> toEqual(Eq.float, 7.)) +test ("minimum(-4.,-1.)", () => expect(Float.minimum(-4.,-1.)) |> toEqual(Eq.float, -4.)) +test ("minimum(7.,nan)", () => expect(Float.minimum(7.,nan)) |> toEqual(Eq.float, NaN)) +test ("minimum(7.,infinity)", () => expect(Float.minimum(7.,infinity)) |> toEqual(Eq.float, 7.)) +test ("minimum(7.,negativeInfinity)", () => expect(Float.minimum(7.,negativeInfinity)) |> toEqual(Eq.float, negativeInfinity)) +test ("multiply(2.,7.)", () => expect(Float.multiply(2.,7.)) |> toEqual(Eq.float, 14.)) +test ("negate(8.)", () => expect(Float.negate(8.)) |> toEqual(Eq.float, -8.)) +test ("negate(-7.)", () => expect(Float.negate(-7.)) |> toEqual(Eq.float, 7.)) +test ("negate(0.)", () => expect(Float.negate(0.)) |> toEqual(Eq.float, -0.)) +test ("power(~base=7.,~exponent=3.)", () => expect(Float.power(~base=7.,~exponent=3.)) |> toEqual(Eq.float, 343.)) +test ("power(~base=0.,~exponent=3.)", () => expect(Float.power(~base=0.,~exponent=3.)) |> toEqual(Eq.float, 0.)) +test ("power(~base=7.,~exponent=0.)", () => expect(Float.power(~base=7.,~exponent=0.)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Zero,1.2)", () => expect(Float.round(~direction=#Zero,1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Zero,1.5)", () => expect(Float.round(~direction=#Zero,1.5)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Zero,1.8)", () => expect(Float.round(~direction=#Zero,1.8)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Zero,-1.2)", () => expect(Float.round(~direction=#Zero,-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Zero,-1.5)", () => expect(Float.round(~direction=#Zero,-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Zero,-1.8)", () => expect(Float.round(~direction=#Zero,-1.8)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#AwayFromZero,1.2)", () => expect(Float.round(~direction=#AwayFromZero,1.2)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#AwayFromZero,1.5)", () => expect(Float.round(~direction=#AwayFromZero,1.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#AwayFromZero,1.8)", () => expect(Float.round(~direction=#AwayFromZero,1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#AwayFromZero,-1.2)", () => expect(Float.round(~direction=#AwayFromZero,-1.2)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#AwayFromZero,-1.5)", () => expect(Float.round(~direction=#AwayFromZero,-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#AwayFromZero,-1.8)", () => expect(Float.round(~direction=#AwayFromZero,-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Up,1.2)", () => expect(Float.round(~direction=#Up,1.2)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Up,1.5)", () => expect(Float.round(~direction=#Up,1.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Up,1.8)", () => expect(Float.round(~direction=#Up,1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Up,-1.2)", () => expect(Float.round(~direction=#Up,-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Up,-1.5)", () => expect(Float.round(~direction=#Up,-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Up,-1.8)", () => expect(Float.round(~direction=#Up,-1.8)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Down,1.2)", () => expect(Float.round(~direction=#Down,1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Down,1.5)", () => expect(Float.round(~direction=#Down,1.5)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Down,1.8)", () => expect(Float.round(~direction=#Down,1.8)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Down,-1.2)", () => expect(Float.round(~direction=#Down,-1.2)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Down,-1.5)", () => expect(Float.round(~direction=#Down,-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Down,-1.8)", () => expect(Float.round(~direction=#Down,-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#Zero),1.2)", () => expect(Float.round(~direction=#Closest(#Zero),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#Zero),1.5)", () => expect(Float.round(~direction=#Closest(#Zero),1.5)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#Zero),1.8)", () => expect(Float.round(~direction=#Closest(#Zero),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#Zero),-1.2)", () => expect(Float.round(~direction=#Closest(#Zero),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#Zero),-1.5)", () => expect(Float.round(~direction=#Closest(#Zero),-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#Zero),-1.8)", () => expect(Float.round(~direction=#Closest(#Zero),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#AwayFromZero),1.2)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#AwayFromZero),1.5)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#AwayFromZero),1.8)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#AwayFromZero),-1.2)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#AwayFromZero),-1.5)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#AwayFromZero),-1.8)", () => expect(Float.round(~direction=#Closest(#AwayFromZero),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#Up),1.2)", () => expect(Float.round(~direction=#Closest(#Up),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#Up),1.5)", () => expect(Float.round(~direction=#Closest(#Up),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#Up),1.8)", () => expect(Float.round(~direction=#Closest(#Up),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#Up),-1.2)", () => expect(Float.round(~direction=#Closest(#Up),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#Up),-1.5)", () => expect(Float.round(~direction=#Closest(#Up),-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#Up),-1.8)", () => expect(Float.round(~direction=#Closest(#Up),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#Down),1.2)", () => expect(Float.round(~direction=#Closest(#Down),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#Down),1.5)", () => expect(Float.round(~direction=#Closest(#Down),1.5)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#Down),1.8)", () => expect(Float.round(~direction=#Closest(#Down),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#Down),-1.2)", () => expect(Float.round(~direction=#Closest(#Down),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#Down),-1.5)", () => expect(Float.round(~direction=#Closest(#Down),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#Down),-1.8)", () => expect(Float.round(~direction=#Closest(#Down),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#ToEven),1.2)", () => expect(Float.round(~direction=#Closest(#ToEven),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(~direction=#Closest(#ToEven),1.5)", () => expect(Float.round(~direction=#Closest(#ToEven),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#ToEven),1.8)", () => expect(Float.round(~direction=#Closest(#ToEven),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#ToEven),2.2)", () => expect(Float.round(~direction=#Closest(#ToEven),2.2)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#ToEven),2.5)", () => expect(Float.round(~direction=#Closest(#ToEven),2.5)) |> toEqual(Eq.float, 2.)) +test ("round(~direction=#Closest(#ToEven),2.8)", () => expect(Float.round(~direction=#Closest(#ToEven),2.8)) |> toEqual(Eq.float, 3.)) +test ("round(~direction=#Closest(#ToEven),-1.2)", () => expect(Float.round(~direction=#Closest(#ToEven),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(~direction=#Closest(#ToEven),-1.5)", () => expect(Float.round(~direction=#Closest(#ToEven),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#ToEven),-1.8)", () => expect(Float.round(~direction=#Closest(#ToEven),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#ToEven),-2.2)", () => expect(Float.round(~direction=#Closest(#ToEven),-2.2)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#ToEven),-2.5)", () => expect(Float.round(~direction=#Closest(#ToEven),-2.5)) |> toEqual(Eq.float, -2.)) +test ("round(~direction=#Closest(#ToEven),-2.8)", () => expect(Float.round(~direction=#Closest(#ToEven),-2.8)) |> toEqual(Eq.float, -3.)) +test ("radians(pi)", () => expect(Float.radians(pi)) |> toEqual(Eq.radians, pi)) +test ("sin(degrees(30.))", () => expect(Float.sin(degrees(30.))) |> toEqual(Eq.float, 0.5)) +test ("sin(radians(pi /. 6.))", () => expect(Float.sin(radians(pi /. 6.))) |> toEqual(Eq.float, 0.5)) +test ("squareRoot(4.)", () => expect(Float.squareRoot(4.)) |> toEqual(Eq.float, 2.)) +test ("squareRoot(20.25)", () => expect(Float.squareRoot(20.25)) |> toEqual(Eq.float, 4.5)) +test ("squareRoot(-1.)", () => expect(Float.squareRoot(-1.)) |> toEqual(Eq.float, NaN)) +test ("subtract(4.,3.)", () => expect(Float.subtract(4.,3.)) |> toEqual(Eq.float, 1.)) +test ("tan(degrees(45.))", () => expect(Float.tan(degrees(45.))) |> toEqual(Eq.float, 0.9999999999999999)) +test ("tan(radians(pi /. 4.))", () => expect(Float.tan(radians(pi /. 4.))) |> toEqual(Eq.float, 0.9999999999999999)) +test ("tan(0.)", () => expect(Float.tan(0.)) |> toEqual(Eq.float, 0.)) +test ("toInt(5.)", () => expect(Float.toInt(5.)) |> toEqual({open Eq +option(int)}, Some(5))) +test ("toInt(5.3)", () => expect(Float.toInt(5.3)) |> toEqual({open Eq +option(int)}, Some(5))) +test ("toInt(0.)", () => expect(Float.toInt(0.)) |> toEqual({open Eq +option(int)}, Some(0))) +test ("toInt(-7.)", () => expect(Float.toInt(-7.)) |> toEqual({open Eq +option(int)}, Some(-7))) +test ("toInt(nan)", () => expect(Float.toInt(nan)) |> toEqual({open Eq +option(int)}, None)) +test ("toInt(infinity)", () => expect(Float.toInt(infinity)) |> toEqual({open Eq +option(int)}, None)) +test ("toInt(negativeInfinity)", () => expect(Float.toInt(negativeInfinity)) |> toEqual({open Eq +option(int)}, None)) +test ("truncate(1.2)", () => expect(Float.truncate(1.2)) |> toEqual(Eq.float, 1.)) +test ("truncate(1.5)", () => expect(Float.truncate(1.5)) |> toEqual(Eq.float, 1.)) +test ("truncate(1.8)", () => expect(Float.truncate(1.8)) |> toEqual(Eq.float, 1.)) +test ("truncate(-1.2)", () => expect(Float.truncate(-1.2)) |> toEqual(Eq.float, -1.)) +test ("truncate(-1.5)", () => expect(Float.truncate(-1.5)) |> toEqual(Eq.float, -1.)) +test ("truncate(-1.8)", () => expect(Float.truncate(-1.8)) |> toEqual(Eq.float, -1.)) +test ("turns(1.)", () => expect(Float.turns(1.)) |> toEqual(Eq.radians, 2. *. pi)) +}) \ No newline at end of file diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res new file mode 100644 index 00000000..dddc3336 --- /dev/null +++ b/test/rescriptTests/IntTest.res @@ -0,0 +1,99 @@ +open Tablecloth +open AlcoJest + +let suite= suite("Int", () => { + open Int +test ("absolute(8)", () => expect(Int.absolute(8)) |> toEqual(Eq.int, 8)) +test ("absolute(-7)", () => expect(Int.absolute(-7)) |> toEqual(Eq.int, 7)) +test ("absolute(0)", () => expect(Int.absolute(0)) |> toEqual(Eq.int, 0)) +test ("add(1,2)", () => expect(Int.add(1,2)) |> toEqual(Eq.int, 3)) +test ("add(1,1)", () => expect(Int.add(1,1)) |> toEqual(Eq.int, 2)) +test ("clamp(5,~lower=0,~upper=8)", () => expect(Int.clamp(5,~lower=0,~upper=8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,~lower=0,~upper=8)", () => expect(Int.clamp(9,~lower=0,~upper=8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,~lower=2,~upper=8)", () => expect(Int.clamp(1,~lower=2,~upper=8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,~lower=-10,~upper=-5)", () => expect(Int.clamp(5,~lower=-10,~upper=-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,~lower=-10,~upper=-5)", () => expect(Int.clamp(-15,~lower=-10,~upper=-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,~lower=7,~upper=1)", () => expect(() => Int.clamp(3,~lower=7,~upper=1)) |> toThrow) +test ("divide(3,~by=2)", () => expect(Int.divide(3,~by=2)) |> toEqual(Eq.int, 1)) +test ("divide(3,~by=0)", () => expect(() => Int.divide(3,~by=0)) |> toThrow) +test ("divide(27,~by=5)", () => expect(Int.divide(27,~by=5)) |> toEqual(Eq.int, 5)) +test ("divideFloat(3,~by=2)", () => expect(Int.divideFloat(3,~by=2)) |> toEqual(Eq.float, 1.5)) +test ("divideFloat(27,~by=5)", () => expect(Int.divideFloat(27,~by=5)) |> toEqual(Eq.float, 5.4)) +test ("divideFloat(8,~by=4)", () => expect(Int.divideFloat(8,~by=4)) |> toEqual(Eq.float, 2)) +test ("divideFloat(8,~by=0)", () => expect(Int.divideFloat(8,~by=0)) |> toEqual(Eq.float, Float.infinity)) +test ("divideFloat(-8,~by=0)", () => expect(Int.divideFloat(-8,~by=0)) |> toEqual(Eq.float, Float.negativeInfinity)) +test ("fromString(0)", () => expect(Int.fromString("0")) |> toEqual({open Eq +option(int)}, Some(0))) +test ("fromString(-0)", () => expect(Int.fromString("-0")) |> toEqual({open Eq +option(int)}, Some(-0))) +test ("fromString(42)", () => expect(Int.fromString("42")) |> toEqual({open Eq +option(int)}, Some(42))) +test ("fromString(123_456)", () => expect(Int.fromString("123_456")) |> toEqual({open Eq +option(int)}, Some(123_456))) +test ("fromString(-42)", () => expect(Int.fromString("-42")) |> toEqual({open Eq +option(int)}, Some(-42))) +test ("fromString(0XFF)", () => expect(Int.fromString("0XFF")) |> toEqual({open Eq +option(int)}, Some(255))) +test ("fromString(0X000A)", () => expect(Int.fromString("0X000A")) |> toEqual({open Eq +option(int)}, Some(10))) +test ("fromString(Infinity)", () => expect(Int.fromString("Infinity")) |> toEqual({open Eq +option(int)}, None)) +test ("fromString(-Infinity)", () => expect(Int.fromString("-Infinity")) |> toEqual({open Eq +option(int)}, None)) +test ("fromString(NaN)", () => expect(Int.fromString("NaN")) |> toEqual({open Eq +option(int)}, None)) +test ("fromString(abc)", () => expect(Int.fromString("abc")) |> toEqual({open Eq +option(int)}, None)) +test ("fromString(--4)", () => expect(Int.fromString("--4")) |> toEqual({open Eq +option(int)}, None)) +test ("fromString( )", () => expect(Int.fromString(" ")) |> toEqual({open Eq +option(int)}, None)) +test ("inRange(3,~lower=2,~upper=4)", () => expect(Int.inRange(3,~lower=2,~upper=4)) |> toEqual(Eq.bool, true)) +test ("inRange(8,~lower=2,~upper=4)", () => expect(Int.inRange(8,~lower=2,~upper=4)) |> toEqual(Eq.bool, false)) +test ("inRange(1,~lower=2,~upper=4)", () => expect(Int.inRange(1,~lower=2,~upper=4)) |> toEqual(Eq.bool, false)) +test ("inRange(2,~lower=1,~upper=2)", () => expect(Int.inRange(2,~lower=1,~upper=2)) |> toEqual(Eq.bool, false)) +test ("inRange(-6,~lower=-7,~upper=-5)", () => expect(Int.inRange(-6,~lower=-7,~upper=-5)) |> toEqual(Eq.bool, true)) +test ("inRange(3,~lower=7,~upper=1)", () => expect(() => Int.inRange(3,~lower=7,~upper=1)) |> toThrow) +test ("isEven(8)", () => expect(Int.isEven(8)) |> toEqual(Eq.bool, true)) +test ("isEven(9)", () => expect(Int.isEven(9)) |> toEqual(Eq.bool, false)) +test ("isEven(0)", () => expect(Int.isEven(0)) |> toEqual(Eq.bool, true)) +test ("isOdd(8)", () => expect(Int.isOdd(8)) |> toEqual(Eq.bool, false)) +test ("isOdd(9)", () => expect(Int.isOdd(9)) |> toEqual(Eq.bool, true)) +test ("isOdd(0)", () => expect(Int.isOdd(0)) |> toEqual(Eq.bool, false)) +test ("maximum(8,18)", () => expect(Int.maximum(8,18)) |> toEqual(Eq.int, 18)) +test ("maximum(5,0)", () => expect(Int.maximum(5,0)) |> toEqual(Eq.int, 5)) +test ("maximum(-4,-1)", () => expect(Int.maximum(-4,-1)) |> toEqual(Eq.int, -1)) +test ("minimum(8,18)", () => expect(Int.minimum(8,18)) |> toEqual(Eq.int, 8)) +test ("minimum(5,0)", () => expect(Int.minimum(5,0)) |> toEqual(Eq.int, 0)) +test ("minimum(-4,-1)", () => expect(Int.minimum(-4,-1)) |> toEqual(Eq.int, -4)) +test ("modulo(-4,~by=3)", () => expect(Int.modulo(-4,~by=3)) |> toEqual(Eq.int, 2)) +test ("modulo(-3,~by=3)", () => expect(Int.modulo(-3,~by=3)) |> toEqual(Eq.int, 0)) +test ("modulo(-2,~by=3)", () => expect(Int.modulo(-2,~by=3)) |> toEqual(Eq.int, 1)) +test ("modulo(-1,~by=3)", () => expect(Int.modulo(-1,~by=3)) |> toEqual(Eq.int, 2)) +test ("modulo(0,~by=3)", () => expect(Int.modulo(0,~by=3)) |> toEqual(Eq.int, 0)) +test ("modulo(1,~by=3)", () => expect(Int.modulo(1,~by=3)) |> toEqual(Eq.int, 1)) +test ("modulo(2,~by=3)", () => expect(Int.modulo(2,~by=3)) |> toEqual(Eq.int, 2)) +test ("modulo(3,~by=3)", () => expect(Int.modulo(3,~by=3)) |> toEqual(Eq.int, 0)) +test ("modulo(4,~by=3)", () => expect(Int.modulo(4,~by=3)) |> toEqual(Eq.int, 1)) +test ("multiply(2,7)", () => expect(Int.multiply(2,7)) |> toEqual(Eq.int, 14)) +test ("negate(8)", () => expect(Int.negate(8)) |> toEqual(Eq.int, -8)) +test ("negate(-7)", () => expect(Int.negate(-7)) |> toEqual(Eq.int, 7)) +test ("negate(0)", () => expect(Int.negate(0)) |> toEqual(Eq.int, 0)) +test ("power(~base=7,~exponent=3)", () => expect(Int.power(~base=7,~exponent=3)) |> toEqual(Eq.int, 343)) +test ("power(~base=0,~exponent=3)", () => expect(Int.power(~base=0,~exponent=3)) |> toEqual(Eq.int, 0)) +test ("power(~base=7,~exponent=0)", () => expect(Int.power(~base=7,~exponent=0)) |> toEqual(Eq.int, 1)) +test ("remainder(-4,~by=3)", () => expect(Int.remainder(-4,~by=3)) |> toEqual(Eq.int, -1)) +test ("remainder(-2,~by=3)", () => expect(Int.remainder(-2,~by=3)) |> toEqual(Eq.int, -2)) +test ("remainder(-1,~by=3)", () => expect(Int.remainder(-1,~by=3)) |> toEqual(Eq.int, -1)) +test ("remainder(0,~by=3)", () => expect(Int.remainder(0,~by=3)) |> toEqual(Eq.int, 0)) +test ("remainder(1,~by=3)", () => expect(Int.remainder(1,~by=3)) |> toEqual(Eq.int, 1)) +test ("remainder(2,~by=3)", () => expect(Int.remainder(2,~by=3)) |> toEqual(Eq.int, 2)) +test ("remainder(3,~by=3)", () => expect(Int.remainder(3,~by=3)) |> toEqual(Eq.int, 0)) +test ("remainder(4,~by=3)", () => expect(Int.remainder(4,~by=3)) |> toEqual(Eq.int, 1)) +test ("subtract(4,3)", () => expect(Int.subtract(4,3)) |> toEqual(Eq.int, 1)) +test ("toFloat(5)", () => expect(Int.toFloat(5)) |> toEqual(Eq.float, 5.)) +test ("toFloat(0)", () => expect(Int.toFloat(0)) |> toEqual(Eq.float, 0.)) +test ("toFloat(-7)", () => expect(Int.toFloat(-7)) |> toEqual(Eq.float, -7.)) +test ("toString(1)", () => expect(Int.toString(1)) |> toEqual(Eq.string, "1")) +test ("toString(-1)", () => expect(Int.toString(-1)) |> toEqual(Eq.string, "-1")) +}) \ No newline at end of file diff --git a/yaml-files/Array.all.yaml b/yaml-files/Array.all.yaml new file mode 100644 index 00000000..28d2fdf6 --- /dev/null +++ b/yaml-files/Array.all.yaml @@ -0,0 +1,31 @@ +module: Array +name: all +docstring: Determine if [f] returns true for [all] values in an array. Iteration is stopped as soon as [f] returns [false]. +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: true + - inputs: [[2, 4], Int.isEven] + output: true + - inputs: [[2, 3], Int.isEven] + output: false +examples: + - inputs: [[], Int.isEven] + output: true + - inputs: [[2, 4], Int.isEven] + output: true + - inputs: [[2, 3], Int.isEven] + output: false +added: 0.1.0 diff --git a/yaml-files/Array.any.yaml b/yaml-files/Array.any.yaml new file mode 100644 index 00000000..72af6d29 --- /dev/null +++ b/yaml-files/Array.any.yaml @@ -0,0 +1,31 @@ +module: Array +name: any +docstring: Determine if [f] returns true for [any] values in an array. Iteration is stopped as soon as [f] returns [true] +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: false + - inputs: [[1, 3, 4, 5, 7], Int.isEven] + output: true + - inputs: [[1, 3, 5, 7], Int.isEven] + output: false +examples: + - inputs: [[], Int.isEven] + output: false + - inputs: [[1, 3, 4, 5, 7], Int.isEven] + output: true + - inputs: [[1, 3, 5, 7], Int.isEven] + output: false +added: 0.1.0 diff --git a/yaml-files/Array.append.yaml b/yaml-files/Array.append.yaml new file mode 100644 index 00000000..33a4ad66 --- /dev/null +++ b/yaml-files/Array.append.yaml @@ -0,0 +1,22 @@ +module: Array +name: append +docstring: Creates a new array which is the result of appending the second array onto the end of the first +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: array<'a> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [repeat(~length=2, 42), repeat(~length=3, 81)] + output: [42, 42, 81, 81, 81] +examples: + - inputs: [repeat(~length=2, 42), repeat(~length=3, 81)] + output: [42, 42, 81, 81, 81] +added: 0.1.0 diff --git a/yaml-files/Array.chunksOf.yaml b/yaml-files/Array.chunksOf.yaml new file mode 100644 index 00000000..765ce4c7 --- /dev/null +++ b/yaml-files/Array.chunksOf.yaml @@ -0,0 +1,30 @@ +module: Array +name: chunksOf +docstring: Split an array into equally sized chunks. If there aren't enough elements to make the last 'chunk', those elements are ignored +parameters: + - name: a + type: array<'a> + label: false + - name: size + type: int + label: true +returnType: array> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B", "#23001E"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] + - inputs: [[], 2] + output: [] +examples: + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B", "#23001E"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] + - inputs: [[], 2] + output: [] +added: 0.1.0 diff --git a/yaml-files/Array.clone.yaml b/yaml-files/Array.clone.yaml new file mode 100644 index 00000000..be1ff8b7 --- /dev/null +++ b/yaml-files/Array.clone.yaml @@ -0,0 +1,23 @@ +module: Array +name: clone +docstring: Create a shallow copy of an array +parameters: + - name: a + type: array<'a> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: [1, 2, 3] + - inputs: [[1, 2, 3], [4, 9, 6], [7, 8, 9]] + output: [[1, 2, 3], [4, 9, 6], [7, 8, 9]] +examples: + - inputs: [1, 2, 3] + output: [1, 2, 3] + - inputs: [[1, 2, 3], [4, 9, 6], [7, 8, 9]] + output: [[1, 2, 3], [4, 9, 6], [7, 8, 9]] +added: 0.1.0 diff --git a/yaml-files/Array.compare.yaml b/yaml-files/Array.compare.yaml new file mode 100644 index 00000000..40d7d26b --- /dev/null +++ b/yaml-files/Array.compare.yaml @@ -0,0 +1,33 @@ +module: Array +name: compare +docstring: Compare two arrays using the provided [f] function to compare pairs of elements +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: array<'a> + label: false + - name: f + type: ('a, 'a) => int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], [1, 2, 3, 4], Int.compare] + output: -1 + - inputs: [[1, 2, 3], [1, 2, 3], Int.compare] + output: 0 + - inputs: [[1, 2, 5], [1, 2, 3], Int.compare] + output: 1 +examples: + - inputs: [[1, 2, 3], [1, 2, 3, 4], Int.compare] + output: -1 + - inputs: [[1, 2, 3], [1, 2, 3], Int.compare] + output: 0 + - inputs: [[1, 2, 5], [1, 2, 3], Int.compare] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Array.count.yaml b/yaml-files/Array.count.yaml new file mode 100644 index 00000000..e060a34e --- /dev/null +++ b/yaml-files/Array.count.yaml @@ -0,0 +1,31 @@ +module: Array +name: count +docstring: Count the number of elements which function [f] will return [true] +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: 2 + - inputs: [[1, 3], Int.isEven] + output: 0 + - inputs: [[], Int.isEven] + output: 0 +examples: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: 2 + - inputs: [[1, 3], Int.isEven] + output: 0 + - inputs: [[], Int.isEven] + output: 0 +added: 0.1.0 diff --git a/yaml-files/Array.extent.yaml b/yaml-files/Array.extent.yaml new file mode 100644 index 00000000..5d1e56c7 --- /dev/null +++ b/yaml-files/Array.extent.yaml @@ -0,0 +1,30 @@ +module: Array +name: extent +docstring: Find a {!Tuple2} of the {!minimum} and {!maximum} in a single pass. Returns [None] if called on an empty array +parameters: + - name: a + type: array<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<('a,'a)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, -2, 3], Int.compare] + output: Some(-2, 3) + - inputs: [[1], Int.compare] + output: Some(1, 1) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[1, -2, 3], Int.compare] + output: Some(-2, 3) + - inputs: [[1], Int.compare] + output: Some(1, 1) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.filter.yaml b/yaml-files/Array.filter.yaml new file mode 100644 index 00000000..b2c0cf2c --- /dev/null +++ b/yaml-files/Array.filter.yaml @@ -0,0 +1,22 @@ +module: Array +name: filter +docstring: Keep elements where function [f] will return [true] +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: (int, 'a) => 'b + label: true +returnType: array<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5, 6], Int.isEven] + output: [2, 4, 6] +examples: + - inputs: [[1, 2, 3, 4, 5, 6], Int.isEven] + output: [2, 4, 6] +added: 0.1.0 diff --git a/yaml-files/Array.find.yaml b/yaml-files/Array.find.yaml new file mode 100644 index 00000000..75b045ae --- /dev/null +++ b/yaml-files/Array.find.yaml @@ -0,0 +1,31 @@ +module: Array +name: find +docstring: Returns, as an {!Option}, the first element for which [f] evaluates to [true]. If [f] doesn't return [true] for any of the elements [find] will return [None] +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: Some(4) + - inputs: [[0, 2, 4, 8], Int.isOdd] + output: None + - inputs: [[], Int.isEven] + output: None +examples: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: Some(4) + - inputs: [[0, 2, 4, 8], Int.isOdd] + output: None + - inputs: [[], Int.isEven] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.findIndex.yaml b/yaml-files/Array.findIndex.yaml new file mode 100644 index 00000000..6c0c495d --- /dev/null +++ b/yaml-files/Array.findIndex.yaml @@ -0,0 +1,30 @@ +module: Array +name: findIndex +docstring: Similar to {!Array.find} but [f] is also called with the current index, and the return value will be a tuple of the index the passing value was found at and the passing value +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: (int, 'a) => bool + label: true +returnType: option<(int, 'a)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 8], (index, number) => index > 2 && Int.isEven(number)] + output: Some(3, 8) + - inputs: [[0, 2, 4, 8], (_, _) => false] + output: None + - inputs: [[], (index, number) => index > 2 && Int.isEven(number)] + output: None +examples: + - inputs: [[1, 3, 4, 8], (index, number) => index > 2 && Int.isEven(number)] + output: Some(3, 8) + - inputs: [[0, 2, 4, 8], (_, _) => false] + output: None + - inputs: [[], (index, number) => index > 2 && Int.isEven(number)] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.first.yaml b/yaml-files/Array.first.yaml new file mode 100644 index 00000000..0ad3fdc2 --- /dev/null +++ b/yaml-files/Array.first.yaml @@ -0,0 +1,23 @@ +module: Array +name: first +docstring: Get the first element of an array. Returns [None] if the array is empty +parameters: + - name: a + type: array<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: Some(1) + - inputs: [] + output: None +examples: + - inputs: [1, 2, 3] + output: Some(1) + - inputs: [] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.flatten.yaml b/yaml-files/Array.flatten.yaml new file mode 100644 index 00000000..6645f03a --- /dev/null +++ b/yaml-files/Array.flatten.yaml @@ -0,0 +1,19 @@ +module: Array +name: flatten +docstring: Flatten an array of arrays into a single array +parameters: + - name: a + type: array> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2], [3], [4, 5]] + output: [1, 2, 3, 4, 5] +examples: + - inputs: [[1, 2], [3], [4, 5]] + output: [1, 2, 3, 4, 5] +added: 0.1.0 diff --git a/yaml-files/Array.fromList.yaml b/yaml-files/Array.fromList.yaml new file mode 100644 index 00000000..bc1147b5 --- /dev/null +++ b/yaml-files/Array.fromList.yaml @@ -0,0 +1,19 @@ +module: Array +name: fromList +docstring: Create an array from a {!List} +parameters: + - name: a + type: list<'a> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: [1, 2, 3] +examples: + - inputs: [1, 2, 3] + output: [1, 2, 3] +added: 0.1.0 diff --git a/yaml-files/Array.get.yaml b/yaml-files/Array.get.yaml new file mode 100644 index 00000000..c16ee453 --- /dev/null +++ b/yaml-files/Array.get.yaml @@ -0,0 +1,39 @@ +module: Array +name: get +docstring: Get the element at the specified index. +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: int + label: false +returnType: >- + 'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["cat", "dog", "eel"], [2]] + output: "eel" + - inputs: [[0, 1, 2], [-1]] + output: exception + - inputs: [[0, 1, 2], [3]] + output: exception + - inputs: [[0, 1, 2], [5]] + output: exception + - inputs: [[], [0]] + output: exception +examples: + - inputs: [["cat", "dog", "eel"], [2]] + output: "eel" + - inputs: [[0, 1, 2], [-1]] + output: exception + - inputs: [[0, 1, 2], [3]] + output: exception + - inputs: [[0, 1, 2], [5]] + output: exception + - inputs: [[], [0]] + output: exception +added: 0.1.0 diff --git a/yaml-files/Array.getAt.yaml b/yaml-files/Array.getAt.yaml new file mode 100644 index 00000000..e711e7e6 --- /dev/null +++ b/yaml-files/Array.getAt.yaml @@ -0,0 +1,30 @@ +module: Array +name: getAt +docstring: Returns, as an {!Option}, the element at index number [n] of array [a]. Returns [None] if [n] is outside the range [0] to [(Array.length(a) - 1)] +parameters: + - name: a + type: array<'a> + label: false + - name: index + type: int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["cat", "dog", "eel"], 2] + output: Some("eel") + - inputs: [[0, 1, 2], 5] + output: None + - inputs: [[], 0] + output: None +examples: + - inputs: [["cat", "dog", "eel"], 2] + output: Some("eel") + - inputs: [[0, 1, 2], 5] + output: None + - inputs: [[], 0] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.includes.yaml b/yaml-files/Array.includes.yaml new file mode 100644 index 00000000..18ed9076 --- /dev/null +++ b/yaml-files/Array.includes.yaml @@ -0,0 +1,34 @@ +module: Array +name: includes +docstring: Test if an array contains the specified element using the provided [equal] to test for equality +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: >- + 'a + label: false + - name: equal + type: ('a, 'a) => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], 2, \"="] + output: true + - inputs: [[1, 5, 3], 2, \"="] + output: false + - inputs: [[], 2, \"="] + output: false +examples: + - inputs: [[1, 2, 3], 2, \"="] + output: true + - inputs: [[1, 5, 3], 2, \"="] + output: false + - inputs: [[], 2, \"="] + output: false +added: 0.1.0 diff --git a/yaml-files/Array.initialize.yaml b/yaml-files/Array.initialize.yaml new file mode 100644 index 00000000..de029fd6 --- /dev/null +++ b/yaml-files/Array.initialize.yaml @@ -0,0 +1,30 @@ +module: Array +name: initialize +docstring: Initialize an array. [Array.initialize n ~f] creates an array of length [n] with the element at index [i] initialized to the result of [(f i)] +parameters: + - name: a + type: int + label: false + - name: f + type: int => 'a + label: true +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [0, Fun.identity] + output: [] + - inputs: [-1, Fun.identity] + output: [] + - inputs: [3, Fun.identity] + output: [0, 1, 2] +examples: + - inputs: [0, Fun.identity] + output: [] + - inputs: [-1, Fun.identity] + output: [] + - inputs: [3, Fun.identity] + output: [0, 1, 2] +added: 0.1.0 diff --git a/yaml-files/Array.intersperse.yaml b/yaml-files/Array.intersperse.yaml new file mode 100644 index 00000000..f3667dca --- /dev/null +++ b/yaml-files/Array.intersperse.yaml @@ -0,0 +1,27 @@ +module: Array +name: intersperse +docstring: Places [sep] between all the elements of the given array +parameters: + - name: a + type: array<'a> + label: false + - name: sep + type: >- + 'a + label: true +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["turtles", "turtles", "turtles"], "on"] + output: ["turtles", "on", "turtles", "on", "turtles"] + - inputs: [[], 0] + output: [] +examples: + - inputs: [["turtles", "turtles", "turtles"], "on"] + output: ["turtles", "on", "turtles", "on", "turtles"] + - inputs: [[], 0] + output: [] +added: 0.1.0 diff --git a/yaml-files/Array.isEmpty.yaml b/yaml-files/Array.isEmpty.yaml new file mode 100644 index 00000000..ae91b64a --- /dev/null +++ b/yaml-files/Array.isEmpty.yaml @@ -0,0 +1,23 @@ +module: Array +name: isEmpty +docstring: Check if an array is empty +parameters: + - name: a + type: array<'a> + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: true + - inputs: [1234] + output: false +examples: + - inputs: [] + output: true + - inputs: [1234] + output: false +added: 0.1.0 diff --git a/yaml-files/Array.join.yaml b/yaml-files/Array.join.yaml new file mode 100644 index 00000000..160ca608 --- /dev/null +++ b/yaml-files/Array.join.yaml @@ -0,0 +1,26 @@ +module: Array +name: join +docstring: Converts an array of strings into a {!String}, placing [sep] between each string in the result +parameters: + - name: a + type: array + label: false + - name: sep + type: string + label: true +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["Ant", "Bat", "Cat"], ", "] + output: "Ant, Bat, Cat" + - inputs: [[], ", "] + output: "" +examples: + - inputs: [["Ant", "Bat", "Cat"], ", "] + output: "Ant, Bat, Cat" + - inputs: [[], ", "] + output: "" +added: 0.1.0 diff --git a/yaml-files/Array.last.yaml b/yaml-files/Array.last.yaml new file mode 100644 index 00000000..d24f4e31 --- /dev/null +++ b/yaml-files/Array.last.yaml @@ -0,0 +1,23 @@ +module: Array +name: last +docstring: Get the last element of an array. Returns [None] if the array is empty +parameters: + - name: a + type: array<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: Some(3) + - inputs: [] + output: None +examples: + - inputs: [1, 2, 3] + output: Some(3) + - inputs: [] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.length.yaml b/yaml-files/Array.length.yaml new file mode 100644 index 00000000..62cc95c1 --- /dev/null +++ b/yaml-files/Array.length.yaml @@ -0,0 +1,27 @@ +module: Array +name: length +docstring: Return the length of an array +parameters: + - name: a + type: array<'a> + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: 0 + - inputs: ["a"] + output: 1 + - inputs: ["a", "b"] + output: 2 +examples: + - inputs: [] + output: 0 + - inputs: ["a"] + output: 1 + - inputs: ["a", "b"] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Array.map.yaml b/yaml-files/Array.map.yaml new file mode 100644 index 00000000..a4e0d83c --- /dev/null +++ b/yaml-files/Array.map.yaml @@ -0,0 +1,23 @@ +module: Array +name: map +docstring: Create a new array which is the result of applying a function [f] to every element +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => 'b + label: true +returnType: array<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1.0, 4.0, 9.0], Float.squareRoot] + output: [1.0, 2.0, 3.0] +examples: + - inputs: [[1.0, 4.0, 9.0], Float.squareRoot] + output: [1.0, 2.0, 3.0] +added: 0.1.0 diff --git a/yaml-files/Array.map2.yaml b/yaml-files/Array.map2.yaml new file mode 100644 index 00000000..a108660a --- /dev/null +++ b/yaml-files/Array.map2.yaml @@ -0,0 +1,29 @@ +module: Array +name: map2 +docstring: Combine two arrays, using [f] to combine each pair of elements +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: array<'b> + label: false + - name: f + type: ('a, 'b) => 'c + label: true +returnType: array<'c> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], [4, 5, 6], \"+"] + output: [5, 7, 9] + - inputs: [["alice", "bob", "chuck"], [2, 5, 7, 8], Tuple2.make] + output: [("alice", 2), ("bob", 5), ("chuck", 7)] +examples: + - inputs: [[1, 2, 3], [4, 5, 6], \"+"] + output: [5, 7, 9] + - inputs: [["alice", "bob", "chuck"], [2, 5, 7, 8], Tuple2.make] + output: [("alice", 2), ("bob", 5), ("chuck", 7)] +added: 0.1.0 diff --git a/yaml-files/Array.map3.yaml b/yaml-files/Array.map3.yaml new file mode 100644 index 00000000..6fa4b8eb --- /dev/null +++ b/yaml-files/Array.map3.yaml @@ -0,0 +1,57 @@ +module: Array +name: map3 +docstring: Combine three arrays, using [f] to combine each trio of elements +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: array<'b> + label: false + - name: c + type: array<'c> + label: false + - name: f + type: ('a, 'b, 'c) => 'd + label: true +returnType: array<'d> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: + [ + ["alice", "bob", "chuck"], + [2, 5, 7, 8], + [true, false, true, false], + Tuple3.make, + ] + output: [("alice", 2, true), ("bob", 5, false), ("chuck", 7, true)] +examples: + - inputs: + [ + ["alice", "bob", "chuck"], + [2, 5, 7, 8], + [true, false, true, false], + Tuple3.make, + ] + output: [("alice", 2, true), ("bob", 5, false), ("chuck", 7, true)] +added: 0.1.0 + + + + + describe("map3", () => + test("maps elements of 3 arrays", () => + expect( + map3(~f=Tuple3.make, ["alice", "bob", "chuck"], [2, 5, 7, 8], [true, false, true, false]), + ) |> toEqual( + { + open Eq + array(trio(string, int, bool)) + }, + [("alice", 2, true), ("bob", 5, false), ("chuck", 7, true)], + ) + ) + ) diff --git a/yaml-files/Array.mapWithIndex.yaml b/yaml-files/Array.mapWithIndex.yaml new file mode 100644 index 00000000..1e0236f0 --- /dev/null +++ b/yaml-files/Array.mapWithIndex.yaml @@ -0,0 +1,22 @@ +module: Array +name: mapWithIndex +docstring: Apply a function [f] to every element with its index as the first argument +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: (int, 'a) => 'b + label: true +returnType: array<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[5, 5, 5], \"*"] + output: [0, 5, 10] +examples: + - inputs: [[5, 5, 5], \"*"] + output: [0, 5, 10] +added: 0.1.0 diff --git a/yaml-files/Array.maximum.yaml b/yaml-files/Array.maximum.yaml new file mode 100644 index 00000000..92694705 --- /dev/null +++ b/yaml-files/Array.maximum.yaml @@ -0,0 +1,26 @@ +module: Array +name: maximum +docstring: Find the largest element using the provided [compare] function. Returns [None] if called on an empty array +parameters: + - name: a + type: array<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, -2, 3], Int.compare] + output: Some(3) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[1, -2, 3], Int.compare] + output: Some(3) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.minimum.yaml b/yaml-files/Array.minimum.yaml new file mode 100644 index 00000000..0f322b16 --- /dev/null +++ b/yaml-files/Array.minimum.yaml @@ -0,0 +1,26 @@ +module: Array +name: minimum +docstring: Find the smallest element using the provided [compare] function. Returns [None] if called on an empty array +parameters: + - name: a + type: array<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, -2, 3], Int.compare] + output: Some(-2) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[1, -2, 3], Int.compare] + output: Some(-2) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/Array.partition.yaml b/yaml-files/Array.partition.yaml new file mode 100644 index 00000000..8c8fbcb1 --- /dev/null +++ b/yaml-files/Array.partition.yaml @@ -0,0 +1,23 @@ +module: Array +name: partition +docstring: Split an array into a {!Tuple2} of arrays. Values which [f] returns true for will end up in {!Tuple2.first} +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: (array<'a>, array<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5, 6], Int.isOdd] + output: ([1, 3, 5], [2, 4, 6]) +examples: + - inputs: [[1, 2, 3, 4, 5, 6], Int.isOdd] + output: ([1, 3, 5], [2, 4, 6]) +added: 0.1.0 diff --git a/yaml-files/Array.range.yaml b/yaml-files/Array.range.yaml new file mode 100644 index 00000000..13780710 --- /dev/null +++ b/yaml-files/Array.range.yaml @@ -0,0 +1,38 @@ +module: Array +name: range +docstring: Creates an array containing all of the integers from [from] up to but not including [to]. Returns an empty array for invalid arguments. +parameters: + - name: from + type: int + label: true + - name: to + type: int + label: true +returnType: array +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 5 + output: [0, 1, 2, 3, 4] + - inputs: 0 + output: [] + - inputs: [2, 5] + output: [2, 3, 4] + - inputs: [-2, 3] + output: [-2, -1, 0, 1, 2] + - inputs: [5, 0] + output: [] +examples: + - inputs: 5 + output: [0, 1, 2, 3, 4] + - inputs: 0 + output: [] + - inputs: [2, 5] + output: [2, 3, 4] + - inputs: [-2, 3] + output: [-2, -1, 0, 1, 2] + - inputs: [5, 0] + output: [] +added: 0.1.0 diff --git a/yaml-files/Array.repeat.yaml b/yaml-files/Array.repeat.yaml new file mode 100644 index 00000000..c9afe548 --- /dev/null +++ b/yaml-files/Array.repeat.yaml @@ -0,0 +1,34 @@ +module: Array +name: repeat +docstring: Create an array of length with the value of populated at each index. +parameters: + - name: a + type: \'a + label: false + - name: length + type: int + label: true +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [0, 0] + output: [] + - inputs: [0, -1] + output: [] + - inputs: [0, 3] + output: [0, 0, 0] + - inputs: ["cat", 3] + output: ["cat", "cat", "cat"] +examples: + - inputs: [0, 0] + output: [] + - inputs: [0, -1] + output: [] + - inputs: [0, 3] + output: [0, 0, 0] + - inputs: ["cat", 3] + output: ["cat", "cat", "cat"] +added: 0.1.0 diff --git a/yaml-files/Array.reverse.yaml b/yaml-files/Array.reverse.yaml new file mode 100644 index 00000000..22a510c2 --- /dev/null +++ b/yaml-files/Array.reverse.yaml @@ -0,0 +1,19 @@ +module: Array +name: reverse +docstring: Reverses an array {b in place}, mutating the existing array +parameters: + - name: a + type: array<'a> + label: false +returnType: unit +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: [3, 2, 1] +examples: + - inputs: [1, 2, 3] + output: [3, 2, 1] +added: 0.1.0 diff --git a/yaml-files/Array.setAt.yaml b/yaml-files/Array.setAt.yaml new file mode 100644 index 00000000..c3427b16 --- /dev/null +++ b/yaml-files/Array.setAt.yaml @@ -0,0 +1,30 @@ +module: Array +name: setAt +docstring: Modifies an array in place, replacing the element at [index] with [value] +parameters: + - name: a + type: array<'a> + label: false + - name: index + type: int + label: true + - name: value + type: >- + 'a + label: true +returnType: unit +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], 1, 0] + output: [1, 0, 3] + - inputs: [["ant", "bat", "cat"], 0, "antelope"] + output: ["antelope", "bat", "cat"] +examples: + - inputs: [[1, 2, 3], 1, 0] + output: [1, 0, 3] + - inputs: [["ant", "bat", "cat"], 0, "antelope"] + output: ["antelope", "bat", "cat"] +added: 0.1.0 diff --git a/yaml-files/Array.singleton.yaml b/yaml-files/Array.singleton.yaml new file mode 100644 index 00000000..69247b66 --- /dev/null +++ b/yaml-files/Array.singleton.yaml @@ -0,0 +1,24 @@ +module: Array +name: singleton +docstring: Create an array with only one element +parameters: + - name: a + type: >- + 'a + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1234 + output: [1234] + - inputs: 1 + output: 1 +examples: + - inputs: 1234 + output: [1234] + - inputs: 1 + output: 1 +added: 0.1.0 diff --git a/yaml-files/Array.sliding.yaml b/yaml-files/Array.sliding.yaml new file mode 100644 index 00000000..a3ada1e0 --- /dev/null +++ b/yaml-files/Array.sliding.yaml @@ -0,0 +1,49 @@ +module: Array +name: sliding +docstring: Provides a sliding 'window' of sub-arrays over an array +parameters: + - name: a + type: array<'a> + label: false + - name: size + type: int + label: true + - name: step + type: int=? + label: true +returnType: array> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5], 1] + output: [[1], [2], [3], [4], [5]] + - inputs: [[1, 2, 3, 4, 5], 2] + output: [[1, 2], [2, 3], [3, 4], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 3] + output: [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + - inputs: [[1, 2, 3, 4, 5], 2, 2] + output: [[1, 2], [3, 4]] + - inputs: [[1, 2, 3, 4, 5], 1, 3] + output: [[1], [4]] + - inputs: [[1, 2, 3, 4, 5], 2, 3] + output: [[1, 2], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 7] + output: [] +examples: + - inputs: [[1, 2, 3, 4, 5], 1] + output: [[1], [2], [3], [4], [5]] + - inputs: [[1, 2, 3, 4, 5], 2] + output: [[1, 2], [2, 3], [3, 4], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 3] + output: [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + - inputs: [[1, 2, 3, 4, 5], 2, 2] + output: [[1, 2], [3, 4]] + - inputs: [[1, 2, 3, 4, 5], 1, 3] + output: [[1], [4]] + - inputs: [[1, 2, 3, 4, 5], 2, 3] + output: [[1, 2], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 7] + output: [] +added: 0.1.0 diff --git a/yaml-files/Array.sort.yaml b/yaml-files/Array.sort.yaml new file mode 100644 index 00000000..a3999352 --- /dev/null +++ b/yaml-files/Array.sort.yaml @@ -0,0 +1,30 @@ +module: Array +name: sort +docstring: Sort in place, modifying the existing array, using the provided [compare] function to determine order +parameters: + - name: a + type: array<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: unit +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.compare] + output: [] + - inputs: [[5], Int.compare] + output: [5] + - inputs: [[5, 6, 8, 3, 6], Int.compare] + output: [3, 5, 6, 6, 8] +examples: + - inputs: [[], Int.compare] + output: [] + - inputs: [[5], Int.compare] + output: [5] + - inputs: [[5, 6, 8, 3, 6], Int.compare] + output: [3, 5, 6, 6, 8] +added: 0.1.0 diff --git a/yaml-files/Array.splitAt.yaml b/yaml-files/Array.splitAt.yaml new file mode 100644 index 00000000..bb0de814 --- /dev/null +++ b/yaml-files/Array.splitAt.yaml @@ -0,0 +1,26 @@ +module: Array +name: splitAt +docstring: Divides an array into a {!Tuple2} of arrays. Elements which have index upto (but not including) [index] will be in the first component of the tuple. Elements with an index greater than or equal to [index] will be in the second. +parameters: + - name: a + type: array<'a> + label: false + - name: index + type: int + label: true +returnType: (array<'a>, array<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5], 2] + output: ([1, 2], [3, 4, 5]) + - inputs: [[1, 2, 3, 4, 5], 0] + output: ([], [1, 2, 3, 4, 5]) +examples: + - inputs: [[1, 2, 3, 4, 5], 2] + output: ([1, 2], [3, 4, 5]) + - inputs: [[1, 2, 3, 4, 5], 0] + output: ([], [1, 2, 3, 4, 5]) +added: 0.1.0 diff --git a/yaml-files/Array.splitWhen.yaml b/yaml-files/Array.splitWhen.yaml new file mode 100644 index 00000000..7bcc86ea --- /dev/null +++ b/yaml-files/Array.splitWhen.yaml @@ -0,0 +1,35 @@ +module: Array +name: splitWhen +docstring: Divides an array at the first element [f] returns [true] for. Returns a {!Tuple2}, the first component contains the elements [f] returned false for, the second component includes the element that [f] retutned [true] for an all the remaining elements +parameters: + - name: a + type: array<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: (array<'a>, array<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[5, 7, 8, 6, 4], Int.isEven] + output: ([5, 7], [8, 6, 4]) + - inputs: [[5, 7, 8, 7, 4], Int.isEven] + output: ([5, 7], [8, 7, 4]) + - inputs: [["Ant", "Bat", "Cat"], animal => String.length(animal) > 3] + output: (["Ant", "Bat", "Cat"], []) + - inputs: [[2.0, Float.pi, 1.111], Float.isInteger] + output: ([], [2.0, Float.pi, 1.111]) +examples: + - inputs: [[5, 7, 8, 6, 4], Int.isEven] + output: ([5, 7], [8, 6, 4]) + - inputs: [[5, 7, 8, 7, 4], Int.isEven] + output: ([5, 7], [8, 7, 4]) + - inputs: [["Ant", "Bat", "Cat"], animal => String.length(animal) > 3] + output: (["Ant", "Bat", "Cat"], []) + - inputs: [[2.0, Float.pi, 1.111], Float.isInteger] + output: ([], [2.0, Float.pi, 1.111]) +added: 0.1.0 diff --git a/yaml-files/Array.swap.yaml b/yaml-files/Array.swap.yaml new file mode 100644 index 00000000..c530a60b --- /dev/null +++ b/yaml-files/Array.swap.yaml @@ -0,0 +1,25 @@ +module: Array +name: swap +docstring: Swaps the values at the provided indicies +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: int + label: false + - name: c + type: int + label: false +returnType: unit +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], 1, 2] + output: [1, 3, 2] +examples: + - inputs: [[1, 2, 3], 1, 2] + output: [1, 3, 2] +added: 0.1.0 diff --git a/yaml-files/Array.toIndexedList.yaml b/yaml-files/Array.toIndexedList.yaml new file mode 100644 index 00000000..af922fbc --- /dev/null +++ b/yaml-files/Array.toIndexedList.yaml @@ -0,0 +1,23 @@ +module: Array +name: toIndexedList +docstring: Create an indexed {!List} from an array. Each element of the array will be paired with its index as a {!Tuple2} +parameters: + - name: a + type: array<'a> + label: false +returnType: list<(int, 'a)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: [] + - inputs: ["cat", "dog"] + output: [(0, "cat"), (1, "dog")] +examples: + - inputs: [] + output: [] + - inputs: ["cat", "dog"] + output: [(0, "cat"), (1, "dog")] +added: 0.1.0 diff --git a/yaml-files/Array.toList.yaml b/yaml-files/Array.toList.yaml new file mode 100644 index 00000000..7224f6c5 --- /dev/null +++ b/yaml-files/Array.toList.yaml @@ -0,0 +1,19 @@ +module: Array +name: toList +docstring: Create a {!List} of elements from an array +parameters: + - name: a + type: array<'a> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2, 3] + output: [1, 2, 3] +examples: + - inputs: [1, 2, 3] + output: [1, 2, 3] +added: 0.1.0 diff --git a/yaml-files/Array.unzip.yaml b/yaml-files/Array.unzip.yaml new file mode 100644 index 00000000..129c2f35 --- /dev/null +++ b/yaml-files/Array.unzip.yaml @@ -0,0 +1,19 @@ +module: Array +name: zip +docstring: Decompose an array of {!Tuple2}s into a {!Tuple2} of arrays +parameters: + - name: a + type: array<('a, 'b)> + label: false +returnType: (array<'a>, array<'b>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [(0, true), (17, false), (1337, true)] + output: ([0, 17, 1337], [true, false, true]) +examples: + - inputs: [(0, true), (17, false), (1337, true)] + output: ([0, 17, 1337], [true, false, true]) +added: 0.1.0 diff --git a/yaml-files/Array.values.yaml b/yaml-files/Array.values.yaml new file mode 100644 index 00000000..dc3f1433 --- /dev/null +++ b/yaml-files/Array.values.yaml @@ -0,0 +1,23 @@ +module: Array +name: values +docstring: Return all of the [Some] values from an array of options +parameters: + - name: a + type: array> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some("Ant"), None, Some("Cat")] + output: ["Ant", "Cat"] + - inputs: [] + output: [] +examples: + - inputs: [Some("Ant"), None, Some("Cat")] + output: ["Ant", "Cat"] + - inputs: [] + output: [] +added: 0.1.0 diff --git a/yaml-files/Array.zip.yaml b/yaml-files/Array.zip.yaml new file mode 100644 index 00000000..4db7628e --- /dev/null +++ b/yaml-files/Array.zip.yaml @@ -0,0 +1,26 @@ +module: Array +name: zip +docstring: Combine two arrays by merging each pair of elements into a {!Tuple2} +parameters: + - name: a + type: array<'a> + label: false + - name: b + type: array<'b> + label: false +returnType: array<('a, 'b)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5], ["Dog", "Eagle", "Ferret"]] + output: [(1, "Dog"), (2, "Eagle"), (3, "Ferret")] + - inputs: [[], ["Dog", "Eagle", "Ferret"]] + output: [] +examples: + - inputs: [[1, 2, 3, 4, 5], ["Dog", "Eagle", "Ferret"]] + output: [(1, "Dog"), (2, "Eagle"), (3, "Ferret")] + - inputs: [[], ["Dog", "Eagle", "Ferret"]] + output: [] +added: 0.1.0 diff --git a/yaml-files/Bool.compare.yaml b/yaml-files/Bool.compare.yaml new file mode 100644 index 00000000..5b845c1c --- /dev/null +++ b/yaml-files/Bool.compare.yaml @@ -0,0 +1,34 @@ +module: Bool +name: compare +docstring: Compare two and . +parameters: + - name: a + type: bool + label: false + - name: b + type: bool + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [true, true] + output: 0 + - inputs: [true, false] + output: 1 + - inputs: [false, true] + output: -1 + - inputs: [false, false] + output: 0 +examples: + - inputs: [true, true] + output: 0 + - inputs: [true, false] + output: 1 + - inputs: [false, true] + output: -1 + - inputs: [false, false] + output: 0 +added: 0.1.0 diff --git a/yaml-files/Bool.equal.yaml b/yaml-files/Bool.equal.yaml new file mode 100644 index 00000000..4c2c7293 --- /dev/null +++ b/yaml-files/Bool.equal.yaml @@ -0,0 +1,30 @@ +module: Bool +name: equal +docstring: Test for the equality of and +parameters: + - name: a + type: bool + label: false + - name: b + type: bool + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [true, true] + output: true + - inputs: [false, false] + output: true + - inputs: [true, false] + output: false +examples: + - inputs: [true, true] + output: true + - inputs: [false, false] + output: true + - inputs: [true, false] + output: false +added: 0.1.0 diff --git a/yaml-files/Bool.fromInt.yaml b/yaml-files/Bool.fromInt.yaml new file mode 100644 index 00000000..5825577c --- /dev/null +++ b/yaml-files/Bool.fromInt.yaml @@ -0,0 +1,43 @@ +module: Bool +name: fromInt +docstring: Convert (Int) into a Boolean +parameters: + - name: a + type: int + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 0 + output: Some(false) + - inputs: 1 + output: Some(true) + - inputs: Int.minimumValue + output: None + - inputs: -2 + output: None + - inputs: -1 + output: None + - inputs: 2 + output: None + - inputs: Int.maximumValue + output: None +examples: + - inputs: 0 + output: Some(false) + - inputs: 1 + output: Some(true) + - inputs: Int.minimumValue + output: None + - inputs: -2 + output: None + - inputs: -1 + output: None + - inputs: 2 + output: None + - inputs: Int.maximumValue + output: None +added: 0.1.0 diff --git a/yaml-files/Bool.fromString.yaml b/yaml-files/Bool.fromString.yaml new file mode 100644 index 00000000..29479d02 --- /dev/null +++ b/yaml-files/Bool.fromString.yaml @@ -0,0 +1,31 @@ +module: Bool +name: fromString +docstring: Convert (String) into a Boolean +parameters: + - name: a + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "true" + output: Some(true) + - inputs: "false" + output: Some(false) + - inputs: "True" + output: None + - inputs: "1" + output: None +examples: + - inputs: "true" + output: Some(true) + - inputs: "false" + output: Some(false) + - inputs: "True" + output: None + - inputs: "1" + output: None +added: 0.1.0 diff --git a/yaml-files/Bool.toInt.yaml b/yaml-files/Bool.toInt.yaml new file mode 100644 index 00000000..8cf3b5a1 --- /dev/null +++ b/yaml-files/Bool.toInt.yaml @@ -0,0 +1,23 @@ +module: Bool +name: toInt +docstring: Convert (Bool) into an Int +parameters: + - name: a + type: bool + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: true + output: 1 + - inputs: false + output: 0 +examples: + - inputs: true + output: 1 + - inputs: false + output: 0 +added: 0.1.0 diff --git a/yaml-files/Bool.toString.yaml b/yaml-files/Bool.toString.yaml new file mode 100644 index 00000000..f9d54284 --- /dev/null +++ b/yaml-files/Bool.toString.yaml @@ -0,0 +1,23 @@ +module: Bool +name: toString +docstring: Convert (Bool) into a String +parameters: + - name: a + type: bool + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: true + output: "true" + - inputs: false + output: "false" +examples: + - inputs: true + output: "true" + - inputs: false + output: "false" +added: 0.1.0 diff --git a/yaml-files/Bool.xor.yaml b/yaml-files/Bool.xor.yaml new file mode 100644 index 00000000..970d8883 --- /dev/null +++ b/yaml-files/Bool.xor.yaml @@ -0,0 +1,34 @@ +module: Bool +name: xor +docstring: Perform the exclusive or operator on and .Returning [true] if exactly one of its operands is [true]. +parameters: + - name: a + type: bool + label: false + - name: b + type: bool + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [true, true] + output: false + - inputs: [true, false] + output: true + - inputs: [false, true] + output: true + - inputs: [false, false] + output: false +examples: + - inputs: [true, true] + output: false + - inputs: [true, false] + output: true + - inputs: [false, true] + output: true + - inputs: [false, false] + output: false +added: 0.1.0 diff --git a/yaml-files/Char.fromCode.yaml b/yaml-files/Char.fromCode.yaml new file mode 100644 index 00000000..09754753 --- /dev/null +++ b/yaml-files/Char.fromCode.yaml @@ -0,0 +1,27 @@ +module: Char +name: fromCode +docstring: Convert an ASCII code point to a character +parameters: + - name: a + type: int + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 97 + output: Some('a') + - inputs: -1 + output: None + - inputs: 256 + output: None +examples: + - inputs: 97 + output: Some('a') + - inputs: -1 + output: None + - inputs: 256 + output: None +added: 0.1.0 diff --git a/yaml-files/Char.fromString.yaml b/yaml-files/Char.fromString.yaml new file mode 100644 index 00000000..05cd63f3 --- /dev/null +++ b/yaml-files/Char.fromString.yaml @@ -0,0 +1,27 @@ +module: Char +name: fromString +docstring: Converts a string to character +parameters: + - name: a + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "a" + output: Some('a') + - inputs: "abc" + output: None + - inputs: "" + output: None +examples: + - inputs: "a" + output: Some('a') + - inputs: "abc" + output: None + - inputs: "" + output: None +added: 0.1.0 diff --git a/yaml-files/Char.isAlphanumeric.yaml b/yaml-files/Char.isAlphanumeric.yaml new file mode 100644 index 00000000..68f79049 --- /dev/null +++ b/yaml-files/Char.isAlphanumeric.yaml @@ -0,0 +1,27 @@ +module: Char +name: isAlphanumeric +docstring: Detect upper case, lower case and digit ASCII characters +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'A' + output: true + - inputs: >- + '?' + output: false +examples: + - inputs: >- + 'A' + output: true + - inputs: >- + '?' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.isDigit.yaml b/yaml-files/Char.isDigit.yaml new file mode 100644 index 00000000..af8ca1cf --- /dev/null +++ b/yaml-files/Char.isDigit.yaml @@ -0,0 +1,81 @@ +module: Char +name: isDigit +docstring: Detect when a character is a number +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + '0' + output: true + - inputs: >- + '1' + output: true + - inputs: >- + '2' + output: true + - inputs: >- + '3' + output: true + - inputs: >- + '4' + output: true + - inputs: >- + '5' + output: true + - inputs: >- + '6' + output: true + - inputs: >- + '7' + output: true + - inputs: >- + '8' + output: true + - inputs: >- + '9' + output: true + - inputs: >- + 'a' + output: false +examples: + - inputs: >- + '0' + output: true + - inputs: >- + '1' + output: true + - inputs: >- + '2' + output: true + - inputs: >- + '3' + output: true + - inputs: >- + '4' + output: true + - inputs: >- + '5' + output: true + - inputs: >- + '6' + output: true + - inputs: >- + '7' + output: true + - inputs: >- + '8' + output: true + - inputs: >- + '9' + output: true + - inputs: >- + 'a' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.isLetter.yaml b/yaml-files/Char.isLetter.yaml new file mode 100644 index 00000000..b4703695 --- /dev/null +++ b/yaml-files/Char.isLetter.yaml @@ -0,0 +1,51 @@ +module: Char +name: isLetter +docstring: Detect upper and lower case ASCII alphabetic characters. +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'A' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + ' ' + output: false + - inputs: >- + '\n' + output: false + - inputs: >- + '\001' + output: false + - inputs: >- + '\236' + output: false +examples: + - inputs: >- + 'A' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + ' ' + output: false + - inputs: >- + '\n' + output: false + - inputs: >- + '\001' + output: false + - inputs: >- + '\236' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.isLowercase.yaml b/yaml-files/Char.isLowercase.yaml new file mode 100644 index 00000000..d22bbd55 --- /dev/null +++ b/yaml-files/Char.isLowercase.yaml @@ -0,0 +1,33 @@ +module: Char +name: isLowercase +docstring: Detect lower case ASCII characters +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'a' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + '\236' + output: false +examples: + - inputs: >- + 'a' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + '\236' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.isPrintable.yaml b/yaml-files/Char.isPrintable.yaml new file mode 100644 index 00000000..84a02a5f --- /dev/null +++ b/yaml-files/Char.isPrintable.yaml @@ -0,0 +1,25 @@ +module: Char +name: isPrintable +docstring: Detect if a character is a printable character +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + '~' + output: true + - inputs: fromCode(31) |> Option.map(~f=isPrintable) + output: Some(false) +examples: + - inputs: >- + '~' + output: true + - inputs: fromCode(31) |> Option.map(~f=isPrintable) + output: Some(false) +added: 0.1.0 diff --git a/yaml-files/Char.isUppercase.yaml b/yaml-files/Char.isUppercase.yaml new file mode 100644 index 00000000..04d0039d --- /dev/null +++ b/yaml-files/Char.isUppercase.yaml @@ -0,0 +1,33 @@ +module: Char +name: isUppercase +docstring: Detect upper case ASCII characters +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'A' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + '\237' + output: false +examples: + - inputs: >- + 'A' + output: true + - inputs: >- + '7' + output: false + - inputs: >- + '\237' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.isWhitespace.yaml b/yaml-files/Char.isWhitespace.yaml new file mode 100644 index 00000000..18b499ec --- /dev/null +++ b/yaml-files/Char.isWhitespace.yaml @@ -0,0 +1,27 @@ +module: Char +name: isWhitespace +docstring: Detect one of the following characters ['\t'] (tab), ['\n'] (newline), ['\011'] (vertical tab), ['\012'] (form feed), ['\r'] (carriage return), [' '] (space) +parameters: + - name: a + type: char + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + ' ' + output: true + - inputs: >- + 'a' + output: false +examples: + - inputs: >- + ' ' + output: true + - inputs: >- + 'a' + output: false +added: 0.1.0 diff --git a/yaml-files/Char.toCode.yaml b/yaml-files/Char.toCode.yaml new file mode 100644 index 00000000..9b491980 --- /dev/null +++ b/yaml-files/Char.toCode.yaml @@ -0,0 +1,21 @@ +module: Char +name: toCode +docstring: Convert to the corresponding ASCII code point +parameters: + - name: a + type: char + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'a' + output: 97 +examples: + - inputs: >- + 'a' + output: 97 +added: 0.1.0 diff --git a/yaml-files/Char.toDigit.yaml b/yaml-files/Char.toDigit.yaml new file mode 100644 index 00000000..2b102ee8 --- /dev/null +++ b/yaml-files/Char.toDigit.yaml @@ -0,0 +1,33 @@ +module: Char +name: toDigit +docstring: Converts a digit character to its corresponding {!Int} +parameters: + - name: a + type: char + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + '0' + output: Some(0) + - inputs: >- + '8' + output: Some(8) + - inputs: >- + 'a' + output: None +examples: + - inputs: >- + '0' + output: Some(0) + - inputs: >- + '8' + output: Some(8) + - inputs: >- + 'a' + output: None +added: 0.1.0 diff --git a/yaml-files/Char.toLowercase.yaml b/yaml-files/Char.toLowercase.yaml new file mode 100644 index 00000000..e1df35a9 --- /dev/null +++ b/yaml-files/Char.toLowercase.yaml @@ -0,0 +1,47 @@ +module: Char +name: toLowercase +docstring: Converts an ASCII character to lower case, preserving non alphabetic ASCII characters +parameters: + - name: a + type: char + label: false +returnType: char +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'A' + output: >- + 'a' + - inputs: >- + 'a' + output: >- + 'a' + - inputs: >- + '7' + output: >- + '7' + - inputs: >- + '\233' + output: >- + '\233' +examples: + - inputs: >- + 'A' + output: >- + 'a' + - inputs: >- + 'a' + output: >- + 'a' + - inputs: >- + '7' + output: >- + '7' + - inputs: >- + '\233' + output: >- + '\233' +added: 0.1.0 diff --git a/yaml-files/Char.toString.yaml b/yaml-files/Char.toString.yaml new file mode 100644 index 00000000..e06330e5 --- /dev/null +++ b/yaml-files/Char.toString.yaml @@ -0,0 +1,21 @@ +module: Char +name: toString +docstring: Convert to a [string] +parameters: + - name: a + type: char + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'a' + output: "a" +examples: + - inputs: >- + 'a' + output: "a" +added: 0.1.0 diff --git a/yaml-files/Char.toUppercase.yaml b/yaml-files/Char.toUppercase.yaml new file mode 100644 index 00000000..0dffa860 --- /dev/null +++ b/yaml-files/Char.toUppercase.yaml @@ -0,0 +1,47 @@ +module: Char +name: toUppercase +docstring: Converts an ASCII character to upper case, preserving non alphabetic ASCII characters +parameters: + - name: a + type: char + label: false +returnType: char +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'a' + output: >- + 'A' + - inputs: >- + 'A' + output: >- + 'A' + - inputs: >- + '7' + output: >- + '7' + - inputs: >- + '\233' + output: >- + '\233' +examples: + - inputs: >- + 'a' + output: >- + 'A' + - inputs: >- + 'A' + output: >- + 'A' + - inputs: >- + '7' + output: >- + '7' + - inputs: >- + '\233' + output: >- + '\233' +added: 0.1.0 diff --git a/yaml-files/Float.absolute.yaml b/yaml-files/Float.absolute.yaml new file mode 100644 index 00000000..72afbfec --- /dev/null +++ b/yaml-files/Float.absolute.yaml @@ -0,0 +1,27 @@ +module: Float +name: absolute +docstring: Get the absolute value of +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "8." + output: "8." + - inputs: "-7." + output: "7." + - inputs: "0." + output: "0." +examples: + - inputs: "8." + output: "8." + - inputs: "-7." + output: "7." + - inputs: "0." + output: "0." +added: 0.1.0 diff --git a/yaml-files/Float.add.yaml b/yaml-files/Float.add.yaml new file mode 100644 index 00000000..7da22ac1 --- /dev/null +++ b/yaml-files/Float.add.yaml @@ -0,0 +1,22 @@ +module: Float +name: add +docstring: Add to , returning their sum +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3.14, 3.14] + output: 6.28 +examples: + - inputs: [3.14, 3.14] + output: 6.28 +added: 0.1.0 diff --git a/yaml-files/Float.atan.yaml b/yaml-files/Float.atan.yaml new file mode 100644 index 00000000..3132da27 --- /dev/null +++ b/yaml-files/Float.atan.yaml @@ -0,0 +1,35 @@ +module: Float +name: atan +docstring: Find the angle (in radians) to an [(x, y)] coordinate +parameters: + - name: a + type: float + label: false +returnType: radians +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "0." + output: "0." + - inputs: 1. /. 1. + output: 0.7853981633974483 + - inputs: 1. /. -1. + output: -0.7853981633974483 + - inputs: -1. /. -1. + output: 0.7853981633974483 + - inputs: -1. /. 1. + output: -0.7853981633974483 +examples: + - inputs: "0." + output: "0." + - inputs: 1. /. 1. + output: 0.7853981633974483 + - inputs: 1. /. -1. + output: -0.7853981633974483 + - inputs: -1. /. -1. + output: 0.7853981633974483 + - inputs: -1. /. 1. + output: -0.7853981633974483 +added: 0.1.0 diff --git a/yaml-files/Float.atan2.yaml b/yaml-files/Float.atan2.yaml new file mode 100644 index 00000000..98aeb581 --- /dev/null +++ b/yaml-files/Float.atan2.yaml @@ -0,0 +1,38 @@ +module: Float +name: atan2 +docstring: Find the angle (in radians) to an [(x, y)] coordinate +parameters: + - name: y + type: float + label: true + - name: x + type: float + label: true +returnType: radians +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["0.", "0."] + output: "0." + - inputs: ["1.", "1."] + output: 0.7853981633974483 + - inputs: ["1.", "-1."] + output: 2.3561944901923449 + - inputs: ["-1.", "-1."] + output: -2.3561944901923449 + - inputs: ["-1.", "1."] + output: -0.7853981633974483 +examples: + - inputs: ["0.", "0."] + output: "0." + - inputs: ["1.", "1."] + output: 0.7853981633974483 + - inputs: ["1.", "-1."] + output: 2.3561944901923449 + - inputs: ["-1.", "-1."] + output: -2.3561944901923449 + - inputs: ["-1.", "1."] + output: -0.7853981633974483 +added: 0.1.0 diff --git a/yaml-files/Float.ceiling.yaml b/yaml-files/Float.ceiling.yaml new file mode 100644 index 00000000..73caebb5 --- /dev/null +++ b/yaml-files/Float.ceiling.yaml @@ -0,0 +1,39 @@ +module: Float +name: ceiling +docstring: Takes param, and returns the least number greater than or equal to param +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1.2 + output: "2." + - inputs: 1.5 + output: "2." + - inputs: 1.8 + output: "2." + - inputs: -1.2 + output: "-1." + - inputs: -1.5 + output: "-1." + - inputs: -1.8 + output: "-1." +examples: + - inputs: 1.2 + output: "2." + - inputs: 1.5 + output: "2." + - inputs: 1.8 + output: "2." + - inputs: -1.2 + output: "-1." + - inputs: -1.5 + output: "-1." + - inputs: -1.8 + output: "-1." +added: 0.1.0 diff --git a/yaml-files/Float.clamp.yaml b/yaml-files/Float.clamp.yaml new file mode 100644 index 00000000..9c1c97aa --- /dev/null +++ b/yaml-files/Float.clamp.yaml @@ -0,0 +1,57 @@ +module: Float +name: clamp +docstring: Clamps within the inclusive [lower] and [upper] bounds and throws a [System.ArgumentOutOfRangeException] exception if '>' +parameters: + - name: a + type: float + label: false + - name: lower + type: float + label: true + - name: upper + type: float + label: true +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["5.", "0.", "8."] + output: "5." + - inputs: ["9.", "0.", "8."] + output: "8." + - inputs: ["1.", "2.", "8."] + output: "2." + - inputs: ["5.", "-10.", "-5."] + output: "-5." + - inputs: ["-15.", "-10.", "-5."] + output: "-10." + - inputs: [-6.6, -7.9, nan] + output: NaN + - inputs: [-6.6, nan, "0."] + output: NaN + - inputs: [nan, "2.", "8."] + output: NaN + - inputs: ["3.", "7.", " 1."] + output: exception +examples: + - inputs: ["5.", "0.", "8."] + output: "5." + - inputs: ["9.", "0.", "8."] + output: "8." + - inputs: ["1.", "2.", "8."] + output: "2." + - inputs: ["5.", "-10.", "-5."] + output: "-5." + - inputs: ["-15.", "-10.", "-5."] + output: "-10." + - inputs: [-6.6, -7.9, nan] + output: NaN + - inputs: [-6.6, nan, "0."] + output: NaN + - inputs: [nan, "2.", "8."] + output: NaN + - inputs: ["3.", "7.", " 1."] + output: exception +added: 0.1.0 diff --git a/yaml-files/Float.cos.yaml b/yaml-files/Float.cos.yaml new file mode 100644 index 00000000..8364509f --- /dev/null +++ b/yaml-files/Float.cos.yaml @@ -0,0 +1,23 @@ +module: Float +name: cos +docstring: Takes in radians and figure out its cosine +parameters: + - name: a + type: radians + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: degrees(60.) + output: 0.5 + - inputs: radians(pi /. 3.) + output: 0.5 +examples: + - inputs: degrees(60.) + output: 0.5 + - inputs: radians(pi /. 3.) + output: 0.5 +added: 0.1.0 diff --git a/yaml-files/Float.degrees.yaml b/yaml-files/Float.degrees.yaml new file mode 100644 index 00000000..b69a420d --- /dev/null +++ b/yaml-files/Float.degrees.yaml @@ -0,0 +1,19 @@ +module: Float +name: degrees +docstring: Converts an angle in degrees to radians +parameters: + - name: a + type: float + label: false +returnType: radians +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "180." + output: pi +examples: + - inputs: "180." + output: pi +added: 0.1.0 diff --git a/yaml-files/Float.divide.yaml b/yaml-files/Float.divide.yaml new file mode 100644 index 00000000..d7b72a70 --- /dev/null +++ b/yaml-files/Float.divide.yaml @@ -0,0 +1,30 @@ +module: Float +name: divide +docstring: divide by , returning their quotient +parameters: + - name: a + type: float + label: false + - name: by + type: float + label: true +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3.14, "2."] + output: 1.57 + - inputs: [3.14, "0."] + output: infinity + - inputs: [3.14, "-0."] + output: negativeInfinity +examples: + - inputs: [3.14, "2."] + output: 1.57 + - inputs: [3.14, "0."] + output: infinity + - inputs: [3.14, "-0."] + output: negativeInfinity +added: 0.1.0 diff --git a/yaml-files/Float.floor.yaml b/yaml-files/Float.floor.yaml new file mode 100644 index 00000000..cf17a437 --- /dev/null +++ b/yaml-files/Float.floor.yaml @@ -0,0 +1,39 @@ +module: Float +name: floor +docstring: Takes param, and returns the greatest number less than or equal to param +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1.2 + output: "1." + - inputs: 1.5 + output: "1." + - inputs: 1.8 + output: "1." + - inputs: -1.2 + output: "-2." + - inputs: -1.5 + output: "-2." + - inputs: -1.8 + output: "-2." +examples: + - inputs: 1.2 + output: "1." + - inputs: 1.5 + output: "1." + - inputs: 1.8 + output: "1." + - inputs: -1.2 + output: "-2." + - inputs: -1.5 + output: "-2." + - inputs: -1.8 + output: "-2." +added: 0.1.0 diff --git a/yaml-files/Float.fromInt.yaml b/yaml-files/Float.fromInt.yaml new file mode 100644 index 00000000..4930adf0 --- /dev/null +++ b/yaml-files/Float.fromInt.yaml @@ -0,0 +1,27 @@ +module: Float +name: fromInt +docstring: Convert into a Float +parameters: + - name: a + type: int + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 5 + output: "5.0" + - inputs: 0 + output: "0.0" + - inputs: -7 + output: "-7.0" +examples: + - inputs: 5 + output: "5.0" + - inputs: 0 + output: "0.0" + - inputs: -7 + output: "-7.0" +added: 0.1.0 diff --git a/yaml-files/Float.fromString.yaml b/yaml-files/Float.fromString.yaml new file mode 100644 index 00000000..9c635fa2 --- /dev/null +++ b/yaml-files/Float.fromString.yaml @@ -0,0 +1,43 @@ +module: Float +name: fromString +docstring: Attempt to parse to a float +parameters: + - name: a + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "NaN" + output: Some(Js.Float._NaN), + - inputs: "nan" + output: Some(Js.Float._NaN) + - inputs: "Infinity" + output: Some(infinity) + - inputs: "infinity" + output: None + - inputs: "55" + output: Some(55.) + - inputs: "-100" + output: Some(-100.) + - inputs: "not number" + output: None +examples: + - inputs: "NaN" + output: Some(Js.Float._NaN), + - inputs: "nan" + output: Some(Js.Float._NaN) + - inputs: "Infinity" + output: Some(infinity) + - inputs: "infinity" + output: None + - inputs: "55" + output: Some(55.) + - inputs: "-100" + output: Some(-100.) + - inputs: "not number" + output: None +added: 0.1.0 diff --git a/yaml-files/Float.hypotenuse.yaml b/yaml-files/Float.hypotenuse.yaml new file mode 100644 index 00000000..2729661d --- /dev/null +++ b/yaml-files/Float.hypotenuse.yaml @@ -0,0 +1,22 @@ +module: Float +name: hypotenuse +docstring: returns the length of the hypotenuse of a right-angled triangle with sides of length and +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["3.", "4."] + output: "5." +examples: + - inputs: ["3.", "4."] + output: "5." +added: 0.1.0 diff --git a/yaml-files/Float.inRange.yaml b/yaml-files/Float.inRange.yaml new file mode 100644 index 00000000..428df612 --- /dev/null +++ b/yaml-files/Float.inRange.yaml @@ -0,0 +1,57 @@ +module: Float +name: inRange +docstring: Checks if is between and up to, but not including, +parameters: + - name: a + type: float + label: false + - name: lower + type: float + label: true + - name: upper + type: float + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["3.", "2.", "4."] + output: true + - inputs: ["8.", "2.", "4."] + output: false + - inputs: ["1.", " 2.", "4."] + output: false + - inputs: ["2.", "1.", "2."] + output: false + - inputs: [-6.6, -7.9, -5.2] + output: true + - inputs: [-6.6, -7.9, nan] + output: false + - inputs: [-6.6, nan, "0."] + output: false + - inputs: [nan, "2.", "8."] + output: false + - inputs: ["3.", "7.", "1."] + output: exception +examples: + - inputs: ["3.", "2.", "4."] + output: true + - inputs: ["8.", "2.", "4."] + output: false + - inputs: ["1.", " 2.", "4."] + output: false + - inputs: ["2.", "1.", "2."] + output: false + - inputs: [-6.6, -7.9, -5.2] + output: true + - inputs: [-6.6, -7.9, nan] + output: false + - inputs: [-6.6, nan, "0."] + output: false + - inputs: [nan, "2.", "8."] + output: false + - inputs: ["3.", "7.", "1."] + output: exception +added: 0.1.0 diff --git a/yaml-files/Float.isFinite.yaml b/yaml-files/Float.isFinite.yaml new file mode 100644 index 00000000..62350ace --- /dev/null +++ b/yaml-files/Float.isFinite.yaml @@ -0,0 +1,43 @@ +module: Float +name: isFinite +docstring: Determine whether is finite number. Returning True for any float except [Infinity], [-Infinity] or [NaN] +parameters: + - name: a + type: float + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: infinity + output: false + - inputs: negativeInfinity + output: false + - inputs: nan + output: false + - inputs: "-5." + output: true + - inputs: -0.314 + output: true + - inputs: "0." + output: true + - inputs: 3.14 + output: true +examples: + - inputs: infinity + output: false + - inputs: negativeInfinity + output: false + - inputs: nan + output: false + - inputs: "-5." + output: true + - inputs: -0.314 + output: true + - inputs: "0." + output: true + - inputs: 3.14 + output: true +added: 0.1.0 diff --git a/yaml-files/Float.isInfinite.yaml b/yaml-files/Float.isInfinite.yaml new file mode 100644 index 00000000..8e76276e --- /dev/null +++ b/yaml-files/Float.isInfinite.yaml @@ -0,0 +1,43 @@ +module: Float +name: isInfinite +docstring: Determine whether is positive or negative infinity. +parameters: + - name: a + type: float + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: infinity + output: true + - inputs: negativeInfinity + output: true + - inputs: nan + output: false + - inputs: "-5." + output: false + - inputs: -0.314 + output: false + - inputs: "0." + output: false + - inputs: 3.14 + output: false +examples: + - inputs: infinity + output: true + - inputs: negativeInfinity + output: true + - inputs: nan + output: false + - inputs: "-5." + output: false + - inputs: -0.314 + output: false + - inputs: "0." + output: false + - inputs: 3.14 + output: false +added: 0.1.0 diff --git a/yaml-files/Float.isInteger.yaml b/yaml-files/Float.isInteger.yaml new file mode 100644 index 00000000..5357e017 --- /dev/null +++ b/yaml-files/Float.isInteger.yaml @@ -0,0 +1,23 @@ +module: Float +name: isInteger +docstring: Determine whether the is an integer. +parameters: + - name: a + type: float + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "5.0" + output: true + - inputs: pi + output: false +examples: + - inputs: "5.0" + output: true + - inputs: pi + output: false +added: 0.1.0 diff --git a/yaml-files/Float.isNaN.yaml b/yaml-files/Float.isNaN.yaml new file mode 100644 index 00000000..685a6bf3 --- /dev/null +++ b/yaml-files/Float.isNaN.yaml @@ -0,0 +1,23 @@ +module: Float +name: isNaN +docstring: Determine whether is an [undefined] or unrepresentable number. +parameters: + - name: a + type: float + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: nan + output: true + - inputs: 91.4 + output: false +examples: + - inputs: nan + output: true + - inputs: 91.4 + output: false +added: 0.1.0 diff --git a/yaml-files/Float.log.yaml b/yaml-files/Float.log.yaml new file mode 100644 index 00000000..7895575c --- /dev/null +++ b/yaml-files/Float.log.yaml @@ -0,0 +1,30 @@ +module: Float +name: log +docstring: Calculate the logarithm of with a given base +parameters: + - name: a + type: float + label: false + - name: base + type: float + label: true +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["100.", "10."] + output: "2." + - inputs: ["256.", "2."] + output: "8." + - inputs: ["0.", "10."] + output: negativeInfinity +examples: + - inputs: ["100.", "10."] + output: "2." + - inputs: ["256.", "2."] + output: "8." + - inputs: ["0.", "10."] + output: negativeInfinity +added: 0.1.0 diff --git a/yaml-files/Float.maximum.yaml b/yaml-files/Float.maximum.yaml new file mode 100644 index 00000000..9e711e89 --- /dev/null +++ b/yaml-files/Float.maximum.yaml @@ -0,0 +1,38 @@ +module: Float +name: maximum +docstring: Compare and , returning the highest value +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["7.", "9."] + output: "9." + - inputs: ["-4.", "-1."] + output: "-1." + - inputs: ["7.", nan] + output: NaN + - inputs: ["7.", infinity] + output: infinity + - inputs: ["7.", negativeInfinity] + output: "7." +examples: + - inputs: ["7.", "9."] + output: "9." + - inputs: ["-4.", "-1."] + output: "-1." + - inputs: ["7.", nan] + output: NaN + - inputs: ["7.", infinity] + output: infinity + - inputs: ["7.", negativeInfinity] + output: "7." +added: 0.1.0 diff --git a/yaml-files/Float.minimum.yaml b/yaml-files/Float.minimum.yaml new file mode 100644 index 00000000..8d239fd6 --- /dev/null +++ b/yaml-files/Float.minimum.yaml @@ -0,0 +1,38 @@ +module: Float +name: minimum +docstring: Compare and , returning the lowest value +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["7.", "9."] + output: "7." + - inputs: ["-4.", "-1."] + output: "-4." + - inputs: ["7.", nan] + output: NaN + - inputs: ["7.", infinity] + output: "7." + - inputs: ["7.", negativeInfinity] + output: negativeInfinity +examples: + - inputs: ["7.", "9."] + output: "7." + - inputs: ["-4.", "-1."] + output: "-4." + - inputs: ["7.", nan] + output: NaN + - inputs: ["7.", infinity] + output: "7." + - inputs: ["7.", negativeInfinity] + output: negativeInfinity +added: 0.1.0 diff --git a/yaml-files/Float.multiply.yaml b/yaml-files/Float.multiply.yaml new file mode 100644 index 00000000..53a3cf51 --- /dev/null +++ b/yaml-files/Float.multiply.yaml @@ -0,0 +1,22 @@ +module: Float +name: multiply +docstring: Multiply by , returning their product +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["2.", "7."] + output: "14." +examples: + - inputs: ["2.", "7."] + output: "14." +added: 0.1.0 diff --git a/yaml-files/Float.negate.yaml b/yaml-files/Float.negate.yaml new file mode 100644 index 00000000..8769affe --- /dev/null +++ b/yaml-files/Float.negate.yaml @@ -0,0 +1,27 @@ +module: Float +name: negate +docstring: Flips the 'sign' of +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "8." + output: "-8." + - inputs: "-7." + output: "7." + - inputs: "0." + output: "-0." +examples: + - inputs: "8." + output: "-8." + - inputs: "-7." + output: "7." + - inputs: "0." + output: "-0." +added: 0.1.0 diff --git a/yaml-files/Float.power.yaml b/yaml-files/Float.power.yaml new file mode 100644 index 00000000..a7fff7fe --- /dev/null +++ b/yaml-files/Float.power.yaml @@ -0,0 +1,30 @@ +module: Float +name: power +docstring: Raise to the power of , returning the power +parameters: + - name: base + type: float + label: true + - name: exponent + type: float + label: true +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["7.", "3."] + output: "343." + - inputs: ["0.", "3."] + output: "0." + - inputs: ["7.", "0."] + output: "1." +examples: + - inputs: ["7.", "3."] + output: "343." + - inputs: ["0.", "3."] + output: "0." + - inputs: ["7.", "0."] + output: "1." +added: 0.1.0 diff --git a/yaml-files/Float.radians.yaml b/yaml-files/Float.radians.yaml new file mode 100644 index 00000000..a9e29e49 --- /dev/null +++ b/yaml-files/Float.radians.yaml @@ -0,0 +1,19 @@ +module: Float +name: radians +docstring: Convert to radians +parameters: + - name: a + type: float + label: false +returnType: radians +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: pi + output: pi +examples: + - inputs: pi + output: pi +added: 0.1.0 diff --git a/yaml-files/Float.round.yaml b/yaml-files/Float.round.yaml new file mode 100644 index 00000000..6e7160bc --- /dev/null +++ b/yaml-files/Float.round.yaml @@ -0,0 +1,258 @@ +module: Float +name: round +docstring: Round , by default to the to the closest [int] with halves rounded [`Up] (towards positive infinity) Other rounding strategies are available by using the optional [~direction] labelelled. +parameters: + - name: direction + type: Direction + label: true + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["#Zero", 1.2] + output: "1." + - inputs: ["#Zero", 1.5] + output: "1." + - inputs: ["#Zero", 1.8] + output: "1." + - inputs: ["#Zero", -1.2] + output: "-1." + - inputs: ["#Zero", -1.5] + output: "-1." + - inputs: ["#Zero", -1.8] + output: "-1." + - inputs: ["#AwayFromZero", 1.2] + output: "2." + - inputs: ["#AwayFromZero", 1.5] + output: "2." + - inputs: ["#AwayFromZero", 1.8] + output: "2." + - inputs: ["#AwayFromZero", -1.2] + output: "-2." + - inputs: ["#AwayFromZero", -1.5] + output: "-2." + - inputs: ["#AwayFromZero", -1.8] + output: "-2." + - inputs: ["#Up", 1.2] + output: "2." + - inputs: ["#Up", 1.5] + output: "2." + - inputs: ["#Up", 1.8] + output: "2." + - inputs: ["#Up", -1.2] + output: "-1." + - inputs: ["#Up", -1.5] + output: "-1." + - inputs: ["#Up", -1.8] + output: "-1." + - inputs: ["#Down", 1.2] + output: "1." + - inputs: ["#Down", 1.5] + output: "1." + - inputs: ["#Down", 1.8] + output: "1." + - inputs: ["#Down", -1.2] + output: "-2." + - inputs: ["#Down", -1.5] + output: "-2." + - inputs: ["#Down", -1.8] + output: "-2." + - inputs: ["#Closest(#Zero)", 1.2] + output: "1." + - inputs: ["#Closest(#Zero)", 1.5] + output: "1." + - inputs: ["#Closest(#Zero)", 1.8] + output: "2." + - inputs: ["#Closest(#Zero)", -1.2] + output: "-1." + - inputs: ["#Closest(#Zero)", -1.5] + output: "-1." + - inputs: ["#Closest(#Zero)", -1.8] + output: "-2." + - inputs: ["#Closest(#AwayFromZero)", 1.2] + output: "1." + - inputs: ["#Closest(#AwayFromZero)", 1.5] + output: "2." + - inputs: ["#Closest(#AwayFromZero)", 1.8] + output: "2." + - inputs: ["#Closest(#AwayFromZero)", -1.2] + output: "-1." + - inputs: ["#Closest(#AwayFromZero)", -1.5] + output: "-2." + - inputs: ["#Closest(#AwayFromZero)", -1.8] + output: "-2." + - inputs: ["#Closest(#Up)", 1.2] + output: "1." + - inputs: ["#Closest(#Up)", 1.5] + output: "2." + - inputs: ["#Closest(#Up)", 1.8] + output: "2." + - inputs: ["#Closest(#Up)", -1.2] + output: "-1." + - inputs: ["#Closest(#Up)", -1.5] + output: "-1." + - inputs: ["#Closest(#Up)", -1.8] + output: "-2." + - inputs: ["#Closest(#Down)", 1.2] + output: "1." + - inputs: ["#Closest(#Down)", 1.5] + output: "1." + - inputs: ["#Closest(#Down)", 1.8] + output: "2." + - inputs: ["#Closest(#Down)", -1.2] + output: "-1." + - inputs: ["#Closest(#Down)", -1.5] + output: "-2." + - inputs: ["#Closest(#Down)", -1.8] + output: "-2." + - inputs: ["#Closest(#ToEven)", 1.2] + output: "1." + - inputs: ["#Closest(#ToEven)", 1.5] + output: "2." + - inputs: ["#Closest(#ToEven)", 1.8] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.2] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.5] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.8] + output: "3." + - inputs: ["#Closest(#ToEven)", -1.2] + output: "-1." + - inputs: ["#Closest(#ToEven)", -1.5] + output: "-2." + - inputs: ["#Closest(#ToEven)", -1.8] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.2] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.5] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.8] + output: "-3." +examples: + - inputs: ["#Zero", 1.2] + output: "1." + - inputs: ["#Zero", 1.5] + output: "1." + - inputs: ["#Zero", 1.8] + output: "1." + - inputs: ["#Zero", -1.2] + output: "-1." + - inputs: ["#Zero", -1.5] + output: "-1." + - inputs: ["#Zero", -1.8] + output: "-1." + - inputs: ["#AwayFromZero", 1.2] + output: "2." + - inputs: ["#AwayFromZero", 1.5] + output: "2." + - inputs: ["#AwayFromZero", 1.8] + output: "2." + - inputs: ["#AwayFromZero", -1.2] + output: "-2." + - inputs: ["#AwayFromZero", -1.5] + output: "-2." + - inputs: ["#AwayFromZero", -1.8] + output: "-2." + - inputs: ["#Up", 1.2] + output: "2." + - inputs: ["#Up", 1.5] + output: "2." + - inputs: ["#Up", 1.8] + output: "2." + - inputs: ["#Up", -1.2] + output: "-1." + - inputs: ["#Up", -1.5] + output: "-1." + - inputs: ["#Up", -1.8] + output: "-1." + - inputs: ["#Down", 1.2] + output: "1." + - inputs: ["#Down", 1.5] + output: "1." + - inputs: ["#Down", 1.8] + output: "1." + - inputs: ["#Down", -1.2] + output: "-2." + - inputs: ["#Down", -1.5] + output: "-2." + - inputs: ["#Down", -1.8] + output: "-2." + - inputs: ["#Closest(#Zero)", 1.2] + output: "1." + - inputs: ["#Closest(#Zero)", 1.5] + output: "1." + - inputs: ["#Closest(#Zero)", 1.8] + output: "2." + - inputs: ["#Closest(#Zero)", -1.2] + output: "-1." + - inputs: ["#Closest(#Zero)", -1.5] + output: "-1." + - inputs: ["#Closest(#Zero)", -1.8] + output: "-2." + - inputs: ["#Closest(#AwayFromZero)", 1.2] + output: "1." + - inputs: ["#Closest(#AwayFromZero)", 1.5] + output: "2." + - inputs: ["#Closest(#AwayFromZero)", 1.8] + output: "2." + - inputs: ["#Closest(#AwayFromZero)", -1.2] + output: "-1." + - inputs: ["#Closest(#AwayFromZero)", -1.5] + output: "-2." + - inputs: ["#Closest(#AwayFromZero)", -1.8] + output: "-2." + - inputs: ["#Closest(#Up)", 1.2] + output: "1." + - inputs: ["#Closest(#Up)", 1.5] + output: "2." + - inputs: ["#Closest(#Up)", 1.8] + output: "2." + - inputs: ["#Closest(#Up)", -1.2] + output: "-1." + - inputs: ["#Closest(#Up)", -1.5] + output: "-1." + - inputs: ["#Closest(#Up)", -1.8] + output: "-2." + - inputs: ["#Closest(#Down)", 1.2] + output: "1." + - inputs: ["#Closest(#Down)", 1.5] + output: "1." + - inputs: ["#Closest(#Down)", 1.8] + output: "2." + - inputs: ["#Closest(#Down)", -1.2] + output: "-1." + - inputs: ["#Closest(#Down)", -1.5] + output: "-2." + - inputs: ["#Closest(#Down)", -1.8] + output: "-2." + - inputs: ["#Closest(#ToEven)", 1.2] + output: "1." + - inputs: ["#Closest(#ToEven)", 1.5] + output: "2." + - inputs: ["#Closest(#ToEven)", 1.8] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.2] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.5] + output: "2." + - inputs: ["#Closest(#ToEven)", 2.8] + output: "3." + - inputs: ["#Closest(#ToEven)", -1.2] + output: "-1." + - inputs: ["#Closest(#ToEven)", -1.5] + output: "-2." + - inputs: ["#Closest(#ToEven)", -1.8] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.2] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.5] + output: "-2." + - inputs: ["#Closest(#ToEven)", -2.8] + output: "-3." +added: 0.1.0 diff --git a/yaml-files/Float.sin.yaml b/yaml-files/Float.sin.yaml new file mode 100644 index 00000000..720c0250 --- /dev/null +++ b/yaml-files/Float.sin.yaml @@ -0,0 +1,23 @@ +module: Float +name: sin +docstring: Takes in radians and figure out its sine +parameters: + - name: a + type: radians + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: degrees(30.) + output: 0.5 + - inputs: radians(pi /. 6.) + output: 0.5 +examples: + - inputs: degrees(30.) + output: 0.5 + - inputs: radians(pi /. 6.) + output: 0.5 +added: 0.1.0 diff --git a/yaml-files/Float.squareRoot.yaml b/yaml-files/Float.squareRoot.yaml new file mode 100644 index 00000000..c1e9000a --- /dev/null +++ b/yaml-files/Float.squareRoot.yaml @@ -0,0 +1,27 @@ +module: Float +name: squareRoot +docstring: Takes and returns its square root or [NaN] when it is negative +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "4." + output: "2." + - inputs: 20.25 + output: 4.5 + - inputs: "-1." + output: NaN +examples: + - inputs: "4." + output: "2." + - inputs: 20.25 + output: 4.5 + - inputs: "-1." + output: NaN +added: 0.1.0 diff --git a/yaml-files/Float.subtract.yaml b/yaml-files/Float.subtract.yaml new file mode 100644 index 00000000..35cd496f --- /dev/null +++ b/yaml-files/Float.subtract.yaml @@ -0,0 +1,22 @@ +module: Float +name: subtract +docstring: Subtract from , returning their difference +parameters: + - name: a + type: float + label: false + - name: b + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["4.", "3."] + output: "1." +examples: + - inputs: ["4.", "3."] + output: "1." +added: 0.1.0 diff --git a/yaml-files/Float.tan.yaml b/yaml-files/Float.tan.yaml new file mode 100644 index 00000000..c9e0bf5d --- /dev/null +++ b/yaml-files/Float.tan.yaml @@ -0,0 +1,27 @@ +module: Float +name: tan +docstring: Takes and figure out its tangent +parameters: + - name: a + type: radians + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: degrees(45.) + output: 0.9999999999999999 + - inputs: radians(pi /. 4.) + output: 0.9999999999999999 + - inputs: "0." + output: "0." +examples: + - inputs: degrees(45.) + output: 0.9999999999999999 + - inputs: radians(pi /. 4.) + output: 0.9999999999999999 + - inputs: "0." + output: "0." +added: 0.1.0 diff --git a/yaml-files/Float.toInt.yaml b/yaml-files/Float.toInt.yaml new file mode 100644 index 00000000..17a92e50 --- /dev/null +++ b/yaml-files/Float.toInt.yaml @@ -0,0 +1,43 @@ +module: Float +name: toInt +docstring: Attempt to convert into an Int +parameters: + - name: a + type: float + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "5." + output: Some(5) + - inputs: 5.3 + output: Some(5) + - inputs: "0." + output: Some(0) + - inputs: "-7." + output: Some(-7) + - inputs: nan + output: None + - inputs: infinity + output: None + - inputs: negativeInfinity + output: None +examples: + - inputs: "5." + output: Some(5) + - inputs: 5.3 + output: Some(5) + - inputs: "0." + output: Some(0) + - inputs: "-7." + output: Some(-7) + - inputs: nan + output: None + - inputs: infinity + output: None + - inputs: negativeInfinity + output: None +added: 0.1.0 diff --git a/yaml-files/Float.truncate.yaml b/yaml-files/Float.truncate.yaml new file mode 100644 index 00000000..8d1f5e3a --- /dev/null +++ b/yaml-files/Float.truncate.yaml @@ -0,0 +1,39 @@ +module: Float +name: truncate +docstring: Takes and remove all the positions after the decimal point +parameters: + - name: a + type: float + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1.2 + output: "1." + - inputs: 1.5 + output: "1." + - inputs: 1.8 + output: "1." + - inputs: -1.2 + output: "-1." + - inputs: -1.5 + output: "-1." + - inputs: -1.8 + output: "-1." +examples: + - inputs: 1.2 + output: "1." + - inputs: 1.5 + output: "1." + - inputs: 1.8 + output: "1." + - inputs: -1.2 + output: "-1." + - inputs: -1.5 + output: "-1." + - inputs: -1.8 + output: "-1." +added: 0.1.0 diff --git a/yaml-files/Float.turns.yaml b/yaml-files/Float.turns.yaml new file mode 100644 index 00000000..5bd075c6 --- /dev/null +++ b/yaml-files/Float.turns.yaml @@ -0,0 +1,19 @@ +module: Float +name: turns +docstring: Convert an angle in turns into radians +parameters: + - name: a + type: float + label: false +returnType: radians +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "1." + output: 2. *. pi +examples: + - inputs: "1." + output: 2. *. pi +added: 0.1.0 diff --git a/yaml-files/Fun.apply.yaml b/yaml-files/Fun.apply.yaml new file mode 100644 index 00000000..11c1bed5 --- /dev/null +++ b/yaml-files/Fun.apply.yaml @@ -0,0 +1,25 @@ +module: Fun +name: apply +docstring: Calls function [f] with an argument [x] +parameters: + - name: a + type: >- + 'a => 'b + label: false + - name: b + type: >- + 'a + label: false +returnType: >- + 'b +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [a => a + 1, 1] + output: 2 +examples: + - inputs: [a => a + 1, 1] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Fun.compose..yaml b/yaml-files/Fun.compose..yaml new file mode 100644 index 00000000..2a5603e8 --- /dev/null +++ b/yaml-files/Fun.compose..yaml @@ -0,0 +1,29 @@ +module: Fun +name: compose +docstring: Function composition, passing result from left to right +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'a => 'b + label: false + - name: c + type: >- + 'b => 'c + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, x => x + 1, x => x * 2] + output: 4 +examples: + - inputs: [1, x => x + 1, x => x * 2] + output: 4 +added: 0.1.0 diff --git a/yaml-files/Fun.composeRight.yaml b/yaml-files/Fun.composeRight.yaml new file mode 100644 index 00000000..4fa24502 --- /dev/null +++ b/yaml-files/Fun.composeRight.yaml @@ -0,0 +1,29 @@ +module: Fun +name: compose +docstring: Function composition, passing result from right to left +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'b => 'c + label: false + - name: c + type: >- + 'a => 'b + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, x => x + 1, x => x * 2] + output: 3 +examples: + - inputs: [1, x => x + 1, x => x * 2] + output: 3 +added: 0.1.0 diff --git a/yaml-files/Fun.constant.yaml b/yaml-files/Fun.constant.yaml new file mode 100644 index 00000000..157623d7 --- /dev/null +++ b/yaml-files/Fun.constant.yaml @@ -0,0 +1,25 @@ +module: Fun +name: constant +docstring: Create a function that {b always} returns the same value +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'b + label: false +returnType: >- + 'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2] + output: 1 +examples: + - inputs: [1, 2] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Fun.curry.yaml b/yaml-files/Fun.curry.yaml new file mode 100644 index 00000000..0291bffe --- /dev/null +++ b/yaml-files/Fun.curry.yaml @@ -0,0 +1,28 @@ +module: Fun +name: curry +docstring: Takes a function [f] which takes a single argument of a tuple [('a, 'b)] and returns a function which takes two arguments that can be partially applied +parameters: + - name: a + type: (('a, 'b)) => 'c + label: false + - name: b + type: >- + 'a + label: false + - name: c + type: >- + 'b + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [((a, b)) => a / b, 8, 4] + output: 2 +examples: + - inputs: [((a, b)) => a / b, 8, 4] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Fun.curry3.yaml b/yaml-files/Fun.curry3.yaml new file mode 100644 index 00000000..d55c81ec --- /dev/null +++ b/yaml-files/Fun.curry3.yaml @@ -0,0 +1,32 @@ +module: Fun +name: curry3 +docstring: Takes a function [f] which takes a single argument of a tuple3 [('a, 'b, 'c)] and returns a function which takes three arguments that can be partially applied +parameters: + - name: a + type: (('a, 'b, 'c)) => 'd + label: false + - name: b + type: >- + 'a + label: false + - name: c + type: >- + 'b + label: false + - name: d + type: >- + 'c + label: false +returnType: >- + 'd +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [((a, b, c)) => a + b + c, 3, 4, 5] + output: 12 +examples: + - inputs: [((a, b, c)) => a + b + c, 3, 4, 5] + output: 12 +added: 0.1.0 diff --git a/yaml-files/Fun.flip.yaml b/yaml-files/Fun.flip.yaml new file mode 100644 index 00000000..45c222c7 --- /dev/null +++ b/yaml-files/Fun.flip.yaml @@ -0,0 +1,28 @@ +module: Fun +name: flip +docstring: Reverses the argument order of a function +parameters: + - name: f + type: ('a, 'b) => 'c + label: true + - name: a + type: >- + 'b + label: false + - name: b + type: >- + 'a + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Int.subtract, 2, 4] + output: 2 +examples: + - inputs: [Int.subtract, 2, 4] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Fun.identity.yaml b/yaml-files/Fun.identity.yaml new file mode 100644 index 00000000..f622f92f --- /dev/null +++ b/yaml-files/Fun.identity.yaml @@ -0,0 +1,21 @@ +module: Fun +name: identity +docstring: Given a value, returns exactly the same value +parameters: + - name: a + type: >- + 'a + label: false +returnType: >- + 'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1 + output: 1 +examples: + - inputs: 1 + output: 1 +added: 0.1.0 diff --git a/yaml-files/Fun.ignore.yaml b/yaml-files/Fun.ignore.yaml new file mode 100644 index 00000000..afba8c2e --- /dev/null +++ b/yaml-files/Fun.ignore.yaml @@ -0,0 +1,19 @@ +module: Fun +name: ignore +docstring: Discards the value it is given and returns [()] +parameters: + - name: a + type: _ + label: false +returnType: unit +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1 + output: () +examples: + - inputs: 1 + output: () +added: 0.1.0 diff --git a/yaml-files/Fun.negate.yaml b/yaml-files/Fun.negate.yaml new file mode 100644 index 00000000..afc335ed --- /dev/null +++ b/yaml-files/Fun.negate.yaml @@ -0,0 +1,24 @@ +module: Fun +name: negate +docstring: Negate a function +parameters: + - name: a + type: >- + 'a => bool + label: false + - name: b + type: >- + 'a + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [n => n > 4, 5] + output: false +examples: + - inputs: [n => n > 4, 5] + output: false +added: 0.1.0 diff --git a/yaml-files/Fun.sequence.yaml b/yaml-files/Fun.sequence.yaml new file mode 100644 index 00000000..d6efd2d3 --- /dev/null +++ b/yaml-files/Fun.sequence.yaml @@ -0,0 +1,25 @@ +module: Fun +name: sequence +docstring: Create a function which always returns its second argument +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'b + label: false +returnType: >- + 'b +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2] + output: 2 +examples: + - inputs: [1, 2] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Fun.uncurry.yaml b/yaml-files/Fun.uncurry.yaml new file mode 100644 index 00000000..6cade79b --- /dev/null +++ b/yaml-files/Fun.uncurry.yaml @@ -0,0 +1,23 @@ +module: Fun +name: uncurry +docstring: Takes a function which takes two arguments and returns a function which takes a single argument of a tuple +parameters: + - name: a + type: ('a, 'b) => 'c + label: false + - name: b + type: ('a, 'b) + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [(a, b) => a / b, (8, 4)] + output: 2 +examples: + - inputs: [(a, b) => a / b, (8, 4)] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Fun.uncurry3.yaml b/yaml-files/Fun.uncurry3.yaml new file mode 100644 index 00000000..1d292b20 --- /dev/null +++ b/yaml-files/Fun.uncurry3.yaml @@ -0,0 +1,23 @@ +module: Fun +name: uncurry3 +docstring: Takes a function which takes three arguments and returns a function which takes a single argument of a tuple3 +parameters: + - name: a + type: ('a, 'b, 'c) => 'd + label: false + - name: b + type: ('a, 'b, 'c) + label: false +returnType: >- + 'd +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [(a, b, c) => a + b + c, (3, 4, 5)] + output: 12 +examples: + - inputs: [(a, b, c) => a + b + c, (3, 4, 5)] + output: 12 +added: 0.1.0 diff --git a/yaml-files/Int.absolute.yaml b/yaml-files/Int.absolute.yaml new file mode 100644 index 00000000..9b3b8d72 --- /dev/null +++ b/yaml-files/Int.absolute.yaml @@ -0,0 +1,27 @@ +module: Int +name: absolute +docstring: Get the absolute value of +parameters: + - name: a + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 8 + output: 8 + - inputs: -7 + output: 7 + - inputs: 0 + output: 0 +examples: + - inputs: 8 + output: 8 + - inputs: -7 + output: 7 + - inputs: 0 + output: 0 +added: 0.1.0 diff --git a/yaml-files/Int.add.yaml b/yaml-files/Int.add.yaml new file mode 100644 index 00000000..8066ff04 --- /dev/null +++ b/yaml-files/Int.add.yaml @@ -0,0 +1,26 @@ +module: Int +name: add +docstring: Add to , returning their sum +parameters: + - name: a + type: int + label: false + - name: b + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [1, 2] + output: 3 + - inputs: [1, 1] + output: 2 +examples: + - inputs: [1, 2] + output: 3 + - inputs: [1, 1] + output: 2 +added: 0.1.0 diff --git a/yaml-files/Int.clamp.yaml b/yaml-files/Int.clamp.yaml new file mode 100644 index 00000000..73840ed1 --- /dev/null +++ b/yaml-files/Int.clamp.yaml @@ -0,0 +1,45 @@ +module: Int +name: clamp +docstring: Clamps within the inclusive [lower] and [upper] bounds and throws a [System.ArgumentOutOfRangeException] exception if '>' +parameters: + - name: a + type: int + label: false + - name: lower + type: int + label: true + - name: upper + type: int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [5, 0, 8] + output: 5 + - inputs: [9, 0, 8] + output: 8 + - inputs: [1, 2, 8] + output: 2 + - inputs: [5, -10, -5] + output: -5 + - inputs: [-15, -10, -5] + output: -10 + - inputs: [3, 7, 1] + output: exception +examples: + - inputs: [5, 0, 8] + output: 5 + - inputs: [9, 0, 8] + output: 8 + - inputs: [1, 2, 8] + output: 2 + - inputs: [5, -10, -5] + output: -5 + - inputs: [-15, -10, -5] + output: -10 + - inputs: [3, 7, 1] + output: exception +added: 0.1.0 diff --git a/yaml-files/Int.divide.yaml b/yaml-files/Int.divide.yaml new file mode 100644 index 00000000..771ad335 --- /dev/null +++ b/yaml-files/Int.divide.yaml @@ -0,0 +1,30 @@ +module: Int +name: divide +docstring: divide by , returning their quotient +parameters: + - name: a + type: int + label: false + - name: by + type: int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3, 2] + output: 1 + - inputs: [3, 0] + output: exception + - inputs: [27, 5] + output: 5 +examples: + - inputs: [3, 2] + output: 1 + - inputs: [3, 0] + output: exception + - inputs: [27, 5] + output: 5 +added: 0.1.0 diff --git a/yaml-files/Int.divideFloat.yaml b/yaml-files/Int.divideFloat.yaml new file mode 100644 index 00000000..6b3e67ad --- /dev/null +++ b/yaml-files/Int.divideFloat.yaml @@ -0,0 +1,38 @@ +module: Int +name: divideFloat +docstring: divide by , returning their quotient +parameters: + - name: a + type: int + label: false + - name: by + type: int + label: true +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3, 2] + output: 1.5 + - inputs: [27, 5] + output: 5.4 + - inputs: [8, 4] + output: 2.0 + - inputs: [8, 0] + output: Float.infinity + - inputs: [-8, 0] + output: Float.negativeInfinity +examples: + - inputs: [3, 2] + output: 1.5 + - inputs: [27, 5] + output: 5.4 + - inputs: [8, 4] + output: 2.0 + - inputs: [8, 0] + output: Float.infinity + - inputs: [-8, 0] + output: Float.negativeInfinity +added: 0.1.0 diff --git a/yaml-files/Int.fromString.yaml b/yaml-files/Int.fromString.yaml new file mode 100644 index 00000000..8f451850 --- /dev/null +++ b/yaml-files/Int.fromString.yaml @@ -0,0 +1,67 @@ +module: Int +name: fromString +docstring: Attempt to parse to an int +parameters: + - name: a + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "0" + output: Some(0) + - inputs: "-0" + output: Some(-0) + - inputs: "42" + output: Some(42) + - inputs: "123_456" + output: Some(123_456) + - inputs: "-42" + output: Some(-42) + - inputs: "0XFF" + output: Some(255) + - inputs: "0X000A" + output: Some(10) + - inputs: "Infinity" + output: None + - inputs: "-Infinity" + output: None + - inputs: "NaN" + output: None + - inputs: "abc" + output: None + - inputs: "--4" + output: None + - inputs: " " + output: None +examples: + - inputs: "0" + output: Some(0) + - inputs: "-0" + output: Some(-0) + - inputs: "42" + output: Some(42) + - inputs: "123_456" + output: Some(123_456) + - inputs: "-42" + output: Some(-42) + - inputs: "0XFF" + output: Some(255) + - inputs: "0X000A" + output: Some(10) + - inputs: "Infinity" + output: None + - inputs: "-Infinity" + output: None + - inputs: "NaN" + output: None + - inputs: "abc" + output: None + - inputs: "--4" + output: None + - inputs: " " + output: None +added: 0.1.0 diff --git a/yaml-files/Int.inRange.yaml b/yaml-files/Int.inRange.yaml new file mode 100644 index 00000000..c37e5156 --- /dev/null +++ b/yaml-files/Int.inRange.yaml @@ -0,0 +1,45 @@ +module: Int +name: inRange +docstring: Checks if is between and up to, but not including, +parameters: + - name: a + type: int + label: false + - name: lower + type: int + label: true + - name: upper + type: int + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3, 2, 4] + output: true + - inputs: [8, 2, 4] + output: false + - inputs: [1, 2, 4] + output: false + - inputs: [2, 1, 2] + output: false + - inputs: [-6, -7, -5] + output: true + - inputs: [3, 7, 1] + output: exception +examples: + - inputs: [3, 2, 4] + output: true + - inputs: [8, 2, 4] + output: false + - inputs: [1, 2, 4] + output: false + - inputs: [2, 1, 2] + output: false + - inputs: [-6, -7, -5] + output: true + - inputs: [3, 7, 1] + output: exception +added: 0.1.0 diff --git a/yaml-files/Int.isEven.yaml b/yaml-files/Int.isEven.yaml new file mode 100644 index 00000000..37ce01e2 --- /dev/null +++ b/yaml-files/Int.isEven.yaml @@ -0,0 +1,27 @@ +module: Int +name: isEven +docstring: Calculate mod 2, returning true if the remainder equals to 0, and false otherwise +parameters: + - name: a + type: int + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 8 + output: true + - inputs: 9 + output: false + - inputs: 0 + output: true +examples: + - inputs: 8 + output: true + - inputs: 9 + output: false + - inputs: 0 + output: true +added: 0.1.0 diff --git a/yaml-files/Int.isOdd.yaml b/yaml-files/Int.isOdd.yaml new file mode 100644 index 00000000..f04d94c7 --- /dev/null +++ b/yaml-files/Int.isOdd.yaml @@ -0,0 +1,27 @@ +module: Int +name: isOdd +docstring: Calculate mod 2, returning false if the remainder equals to 0, and true otherwise +parameters: + - name: a + type: int + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 8 + output: false + - inputs: 9 + output: true + - inputs: 0 + output: false +examples: + - inputs: 8 + output: false + - inputs: 9 + output: true + - inputs: 0 + output: false +added: 0.1.0 diff --git a/yaml-files/Int.maximum.yaml b/yaml-files/Int.maximum.yaml new file mode 100644 index 00000000..b16f1d99 --- /dev/null +++ b/yaml-files/Int.maximum.yaml @@ -0,0 +1,30 @@ +module: Int +name: maximum +docstring: Compare and , returning the highest value +parameters: + - name: a + type: int + label: false + - name: b + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [8, 18] + output: 18 + - inputs: [5, 0] + output: 5 + - inputs: [-4, -1] + output: -1 +examples: + - inputs: [8, 18] + output: 18 + - inputs: [5, 0] + output: 5 + - inputs: [-4, -1] + output: -1 +added: 0.1.0 diff --git a/yaml-files/Int.minimum..yaml b/yaml-files/Int.minimum..yaml new file mode 100644 index 00000000..bdf24dcc --- /dev/null +++ b/yaml-files/Int.minimum..yaml @@ -0,0 +1,30 @@ +module: Int +name: minimum +docstring: Compare and , returning the lowest value +parameters: + - name: a + type: int + label: false + - name: b + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [8, 18] + output: 8 + - inputs: [5, 0] + output: 0 + - inputs: [-4, -1] + output: -4 +examples: + - inputs: [8, 18] + output: 8 + - inputs: [5, 0] + output: 0 + - inputs: [-4, -1] + output: -4 +added: 0.1.0 diff --git a/yaml-files/Int.modulo.yaml b/yaml-files/Int.modulo.yaml new file mode 100644 index 00000000..158d324d --- /dev/null +++ b/yaml-files/Int.modulo.yaml @@ -0,0 +1,54 @@ +module: Int +name: modulo +docstring: Perform modular arithmetic +parameters: + - name: a + type: int + label: false + - name: by + type: int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [-4, 3] + output: 2 + - inputs: [-3, 3] + output: 0 + - inputs: [-2, 3] + output: 1 + - inputs: [-1, 3] + output: 2 + - inputs: [0, 3] + output: 0 + - inputs: [1, 3] + output: 1 + - inputs: [2, 3] + output: 2 + - inputs: [3, 3] + output: 0 + - inputs: [4, 3] + output: 1 +examples: + - inputs: [-4, 3] + output: 2 + - inputs: [-3, 3] + output: 0 + - inputs: [-2, 3] + output: 1 + - inputs: [-1, 3] + output: 2 + - inputs: [0, 3] + output: 0 + - inputs: [1, 3] + output: 1 + - inputs: [2, 3] + output: 2 + - inputs: [3, 3] + output: 0 + - inputs: [4, 3] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Int.multiply.yaml b/yaml-files/Int.multiply.yaml new file mode 100644 index 00000000..8f0c5b8e --- /dev/null +++ b/yaml-files/Int.multiply.yaml @@ -0,0 +1,26 @@ +module: Int +name: multiply +docstring: Multiply by , returning their product +parameters: + - name: a + type: int + label: false + - name: b + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [2, 7] + output: 14 +examples: + - inputs: [2, 7] + output: 14 +added: 0.1.0 + + describe("multiply", () => + test("multiply", () => expect(Int.multiply(2, 7)) |> toEqual(Eq.int, 14)) + ) diff --git a/yaml-files/Int.negate.yaml b/yaml-files/Int.negate.yaml new file mode 100644 index 00000000..bbb07808 --- /dev/null +++ b/yaml-files/Int.negate.yaml @@ -0,0 +1,27 @@ +module: Int +name: negate +docstring: Flips the 'sign' of +parameters: + - name: a + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 8 + output: -8 + - inputs: -7 + output: 7 + - inputs: 0 + output: -0 +examples: + - inputs: 8 + output: -8 + - inputs: -7 + output: 7 + - inputs: 0 + output: -0 +added: 0.1.0 diff --git a/yaml-files/Int.power.yaml b/yaml-files/Int.power.yaml new file mode 100644 index 00000000..a273462d --- /dev/null +++ b/yaml-files/Int.power.yaml @@ -0,0 +1,30 @@ +module: Int +name: power +docstring: Raise to the power of , returning the power +parameters: + - name: base + type: int + label: true + - name: exponent + type: int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [7, 3] + output: 343 + - inputs: [0, 3] + output: 0 + - inputs: [7, 0] + output: 1 +examples: + - inputs: [7, 3] + output: 343 + - inputs: [0, 3] + output: 0 + - inputs: [7, 0] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Int.remainder.yaml b/yaml-files/Int.remainder.yaml new file mode 100644 index 00000000..18b23768 --- /dev/null +++ b/yaml-files/Int.remainder.yaml @@ -0,0 +1,50 @@ +module: Int +name: remainder +docstring: divide by , returning their remainder +parameters: + - name: a + type: int + label: false + - name: by + type: int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [-4, 3] + output: -1 + - inputs: [-2, 3] + output: -2 + - inputs: [-1, 3] + output: -1 + - inputs: [0, 3] + output: 0 + - inputs: [1, 3] + output: 1 + - inputs: [2, 3] + output: 2 + - inputs: [3, 3] + output: 0 + - inputs: [4, 3] + output: 1 +examples: + - inputs: [-4, 3] + output: -1 + - inputs: [-2, 3] + output: -2 + - inputs: [-1, 3] + output: -1 + - inputs: [0, 3] + output: 0 + - inputs: [1, 3] + output: 1 + - inputs: [2, 3] + output: 2 + - inputs: [3, 3] + output: 0 + - inputs: [4, 3] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Int.subtract.yaml b/yaml-files/Int.subtract.yaml new file mode 100644 index 00000000..d6260ece --- /dev/null +++ b/yaml-files/Int.subtract.yaml @@ -0,0 +1,22 @@ +module: Int +name: subtract +docstring: Subtract from , returning their difference +parameters: + - name: a + type: int + label: false + - name: b + type: int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [4, 3] + output: 1 +examples: + - inputs: [4, 3] + output: 1 +added: 0.1.0 diff --git a/yaml-files/Int.toFloat.yaml b/yaml-files/Int.toFloat.yaml new file mode 100644 index 00000000..15181f53 --- /dev/null +++ b/yaml-files/Int.toFloat.yaml @@ -0,0 +1,33 @@ +module: Int +name: toFloat +docstring: Convert into a [float] representation +parameters: + - name: a + type: int + label: false +returnType: float +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 5 + output: >- + 5. + - inputs: 0 + output: >- + 0. + - inputs: -7 + output: >- + -7. +examples: + - inputs: 5 + output: >- + 5. + - inputs: 0 + output: >- + 0. + - inputs: -7 + output: >- + -7. +added: 0.1.0 diff --git a/yaml-files/Int.toString.yaml b/yaml-files/Int.toString.yaml new file mode 100644 index 00000000..db76de14 --- /dev/null +++ b/yaml-files/Int.toString.yaml @@ -0,0 +1,23 @@ +module: Int +name: toString +docstring: Convert into a [string] representation +parameters: + - name: a + type: int + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 1 + output: "1" + - inputs: -1 + output: "-1" +examples: + - inputs: 1 + output: "1" + - inputs: -1 + output: "-1" +added: 0.1.0 diff --git a/yaml-files/List.all.yaml b/yaml-files/List.all.yaml new file mode 100644 index 00000000..6d030ccc --- /dev/null +++ b/yaml-files/List.all.yaml @@ -0,0 +1,35 @@ +module: List +name: all +docstring: Determine if [f] returns true for [all] values in a list. Stops iteration as soon as [f] returns false +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: true + - inputs: [[2, 3], Int.isEven] + output: false + - inputs: [[2, 4], Int.isEven] + output: true + - inputs: [[1, 3], Int.isEven] + output: false +examples: + - inputs: [[], Int.isEven] + output: true + - inputs: [[2, 3], Int.isEven] + output: false + - inputs: [[2, 4], Int.isEven] + output: true + - inputs: [[1, 3], Int.isEven] + output: false +added: 0.1.0 diff --git a/yaml-files/List.any.yaml b/yaml-files/List.any.yaml new file mode 100644 index 00000000..6894a5e9 --- /dev/null +++ b/yaml-files/List.any.yaml @@ -0,0 +1,31 @@ +module: List +name: any +docstring: Determine if [f] returns true for [any] values in a list. Stops iteration as soon as [f] returns true +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: false + - inputs: [[2, 3], Int.isEven] + output: true + - inputs: [[1, 3], Int.isEven] + output: false +examples: + - inputs: [[], Int.isEven] + output: false + - inputs: [[2, 3], Int.isEven] + output: true + - inputs: [[1, 3], Int.isEven] + output: false +added: 0.1.0 diff --git a/yaml-files/List.append.yaml b/yaml-files/List.append.yaml new file mode 100644 index 00000000..6b2f6bc4 --- /dev/null +++ b/yaml-files/List.append.yaml @@ -0,0 +1,34 @@ +module: List +name: append +docstring: Creates a new list which is the result of appending the second list onto the end of the first +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: list<'a> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], []] + output: [] + - inputs: [[], ["turtles"]] + output: ["turtles"] + - inputs: [["turtles"], []] + output: ["turtles"] + - inputs: [["on"], ["turtles"]] + output: ["on", "turtles"] +examples: + - inputs: [[], []] + output: [] + - inputs: [[], ["turtles"]] + output: ["turtles"] + - inputs: [["turtles"], []] + output: ["turtles"] + - inputs: [["on"], ["turtles"]] + output: ["on", "turtles"] +added: 0.1.0 diff --git a/yaml-files/List.chunksOf.yaml b/yaml-files/List.chunksOf.yaml new file mode 100644 index 00000000..aaa21b74 --- /dev/null +++ b/yaml-files/List.chunksOf.yaml @@ -0,0 +1,26 @@ +module: List +name: chunksOf +docstring: Split a list into equally sized chunks. If there aren't enough elements to make the last 'chunk', those elements are ignored +parameters: + - name: a + type: list<'a> + label: false + - name: size + type: int + label: true +returnType: list> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 2] + output: [] + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B", "#23001E"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] +examples: + - inputs: [[], 2] + output: [] + - inputs: [["#FFBA49", "#9984D4", "#20A39E", "#EF5B5B", "#23001E"], 2] + output: [["#FFBA49", "#9984D4"], ["#20A39E", "#EF5B5B"]] +added: 0.1.0 diff --git a/yaml-files/List.compare.yaml b/yaml-files/List.compare.yaml new file mode 100644 index 00000000..02c22bbd --- /dev/null +++ b/yaml-files/List.compare.yaml @@ -0,0 +1,37 @@ +module: List +name: compare +docstring: Compare two lists using the provided [f] function to compare elements +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: list<'a> + label: false + - name: c + type: ('a, 'a) => int + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[2, 5, 6, 11], [2, 5, 6, 11], Int.compare] + output: 0 + - inputs: [[2, 5, -6, 11], [2, 5, 6, 11], Int.compare] + output: -1 + - inputs: [[2, 5, 6, 11], [2, 5, 6], Int.compare] + output: 1 + - inputs: [["hi", "hello", "hey"], ["hi", "hello", "hey"], String.compare] + output: 0 +examples: + - inputs: [[2, 5, 6, 11], [2, 5, 6, 11], Int.compare] + output: 0 + - inputs: [[2, 5, -6, 11], [2, 5, 6, 11], Int.compare] + output: -1 + - inputs: [[2, 5, 6, 11], [2, 5, 6], Int.compare] + output: 1 + - inputs: [["hi", "hello", "hey"], ["hi", "hello", "hey"], String.compare] + output: 0 +added: 0.1.0 diff --git a/yaml-files/List.cons.yaml b/yaml-files/List.cons.yaml new file mode 100644 index 00000000..426253e4 --- /dev/null +++ b/yaml-files/List.cons.yaml @@ -0,0 +1,27 @@ +module: List +name: cons +docstring: Prepend a value to the front of a list +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: >- + 'a + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 1] + output: [1] + - inputs: [[2, 3, 4], 1] + output: [1, 2, 3, 4] +examples: + - inputs: [[], 1] + output: [1] + - inputs: [[2, 3, 4], 1] + output: [1, 2, 3, 4] +added: 0.1.0 diff --git a/yaml-files/List.count.yaml b/yaml-files/List.count.yaml new file mode 100644 index 00000000..60d60c79 --- /dev/null +++ b/yaml-files/List.count.yaml @@ -0,0 +1,31 @@ +module: List +name: count +docstring: Count the number of elements where function [f] returns [true] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: 0 + - inputs: [[2, 3], Int.isEven] + output: 1 + - inputs: [[2, 4], Int.isEven] + output: 2 +examples: + - inputs: [[], Int.isEven] + output: 0 + - inputs: [[2, 3], Int.isEven] + output: 1 + - inputs: [[2, 4], Int.isEven] + output: 2 +added: 0.1.0 diff --git a/yaml-files/List.drop.yaml b/yaml-files/List.drop.yaml new file mode 100644 index 00000000..34563946 --- /dev/null +++ b/yaml-files/List.drop.yaml @@ -0,0 +1,42 @@ +module: List +name: drop +docstring: Drop the first [count] elements from the front of a list. If the list has fewer than [count] elements, returns []. If count is zero or negative, returns the entire list. +parameters: + - name: a + type: list<'a> + label: false + - name: count + type: int + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 1] + output: [] + - inputs: [[1, 2, 3], 0] + output: [1, 2, 3] + - inputs: [[1, 2, 3], 1] + output: [2, 3] + - inputs: [[1, 2, 3], 3] + output: [] + - inputs: [[1, 2, 3], 4] + output: [] + - inputs: [[1, 2, 3], -1] + output: [1, 2, 3] +examples: + - inputs: [[], 1] + output: [] + - inputs: [[1, 2, 3], 0] + output: [1, 2, 3] + - inputs: [[1, 2, 3], 1] + output: [2, 3] + - inputs: [[1, 2, 3], 3] + output: [] + - inputs: [[1, 2, 3], 4] + output: [] + - inputs: [[1, 2, 3], -1] + output: [1, 2, 3] +added: 0.1.0 diff --git a/yaml-files/List.dropWhile.yaml b/yaml-files/List.dropWhile.yaml new file mode 100644 index 00000000..3f09921f --- /dev/null +++ b/yaml-files/List.dropWhile.yaml @@ -0,0 +1,35 @@ +module: List +name: dropWhile +docstring: Drop elements from a list until [f] returns [false] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [7, 8, 9] + - inputs: [[3, 4, 7, 8, 9], Int.isEven] + output: [3, 4, 7, 8, 9] + - inputs: [[2, 4, 6, 8], Int.isEven] + output: [] + - inputs: [[1, 3, 5, 7], Int.isEven] + output: [1, 3, 5, 7] +examples: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [7, 8, 9] + - inputs: [[3, 4, 7, 8, 9], Int.isEven] + output: [3, 4, 7, 8, 9] + - inputs: [[2, 4, 6, 8], Int.isEven] + output: [] + - inputs: [[1, 3, 5, 7], Int.isEven] + output: [1, 3, 5, 7] +added: 0.1.0 diff --git a/yaml-files/List.equal.yaml b/yaml-files/List.equal.yaml new file mode 100644 index 00000000..1e3dacf5 --- /dev/null +++ b/yaml-files/List.equal.yaml @@ -0,0 +1,33 @@ +module: List +name: equal +docstring: Test two lists for equality using the provided function to test elements +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: list<'a> + label: false + - name: c + type: ('a, 'a) => bool + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[2, 5, 6, 11], [2, 5, 6, 11], Int.equal] + output: true + - inputs: [[2, 5, -6, 11], [2, 5, 6, 11], Int.equal] + output: false + - inputs: [["hi", "hello", "hey"], ["hi", "hello", "hey"], String.equal] + output: true +examples: + - inputs: [[2, 5, 6, 11], [2, 5, 6, 11], Int.equal] + output: true + - inputs: [[2, 5, -6, 11], [2, 5, 6, 11], Int.equal] + output: false + - inputs: [["hi", "hello", "hey"], ["hi", "hello", "hey"], String.equal] + output: true +added: 0.1.0 diff --git a/yaml-files/List.extent.yaml b/yaml-files/List.extent.yaml new file mode 100644 index 00000000..b4a3c40c --- /dev/null +++ b/yaml-files/List.extent.yaml @@ -0,0 +1,30 @@ +module: List +name: extent +docstring: Find a {!Tuple2} of the [(minimum, maximum)] elements using the provided [compare] function. Returns [None] if called on an empty list +parameters: + - name: a + type: list<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<('a, 'a)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[7, 5, 8, 6], Int.compare] + output: Some(5, 8) + - inputs: [[5], Int.compare] + output: Some(5, 5) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[7, 5, 8, 6], Int.compare] + output: Some(5, 8) + - inputs: [[5], Int.compare] + output: Some(5, 5) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/List.filter.yaml b/yaml-files/List.filter.yaml new file mode 100644 index 00000000..709e413f --- /dev/null +++ b/yaml-files/List.filter.yaml @@ -0,0 +1,31 @@ +module: List +name: filter +docstring: Keep elements that [f] returns [true] for +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [2, 4, 6, 8] + - inputs: [[5, 7, 9], Int.isEven] + output: [] + - inputs: [[2, 4, 6], Int.isEven] + output: [2, 4, 6] +examples: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [2, 4, 6, 8] + - inputs: [[5, 7, 9], Int.isEven] + output: [] + - inputs: [[2, 4, 6], Int.isEven] + output: [2, 4, 6] +added: 0.1.0 diff --git a/yaml-files/List.filterMap.yaml b/yaml-files/List.filterMap.yaml new file mode 100644 index 00000000..0ca972ee --- /dev/null +++ b/yaml-files/List.filterMap.yaml @@ -0,0 +1,25 @@ +module: List +name: filterMap +docstring: Allows you to combine {!map} and {!filter} into a single pass +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => option<'b> + label: true +returnType: list<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[-1, 80, 99], Char.fromCode] + output: >- + ['P', 'c'] +examples: + - inputs: [[-1, 80, 99], Char.fromCode] + output: >- + ['P', 'c'] +added: 0.1.0 diff --git a/yaml-files/List.filterWithIndex.yaml b/yaml-files/List.filterWithIndex.yaml new file mode 100644 index 00000000..451a1cbd --- /dev/null +++ b/yaml-files/List.filterWithIndex.yaml @@ -0,0 +1,31 @@ +module: List +name: filterWithIndex +docstring: Like {!filter} but [f] is also called with each elements index +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + (int, 'a) => bool + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + [[2, 99, 0, 3], (i, _) => i > 1] + output: [0, 3] + - inputs: >- + [[], (i, _) => i > 1] + output: [] +examples: + - inputs: >- + [[2, 99, 0, 3], (i, _) => i > 1] + output: [0, 3] + - inputs: >- + [[], (i, _) => i > 1] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.find.yaml b/yaml-files/List.find.yaml new file mode 100644 index 00000000..61cab401 --- /dev/null +++ b/yaml-files/List.find.yaml @@ -0,0 +1,31 @@ +module: List +name: find +docstring: Returns, as an [option], the first element for which [f] evaluates to true. If [f] doesn't return [true] for any of the elements [find] will return [None] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: Some(4) + - inputs: [[0, 2, 4, 8], Int.isOdd] + output: None + - inputs: [[], Int.isEven] + output: None +examples: + - inputs: [[1, 3, 4, 8], Int.isEven] + output: Some(4) + - inputs: [[0, 2, 4, 8], Int.isOdd] + output: None + - inputs: [[], Int.isEven] + output: None +added: 0.1.0 diff --git a/yaml-files/List.findIndex.yaml b/yaml-files/List.findIndex.yaml new file mode 100644 index 00000000..c51a052c --- /dev/null +++ b/yaml-files/List.findIndex.yaml @@ -0,0 +1,30 @@ +module: List +name: findIndex +docstring: Returns, as an option, a tuple of the first element and its index for which [f] evaluates to true. If [f] doesnt return [true] for any [(index, element)] pair, returns [None] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: (int, 'a)=> bool + label: true +returnType: option<(int, 'a)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 8], (index, number) => index > 2 && Int.isEven(number)] + output: Some(3, 8) + - inputs: [[0, 2, 4, 8], (_, _) => false] + output: None + - inputs: [[], (index, number) => index > 2 && Int.isEven(number)] + output: None +examples: + - inputs: [[1, 3, 4, 8], (index, number) => index > 2 && Int.isEven(number)] + output: Some(3, 8) + - inputs: [[0, 2, 4, 8], (_, _) => false] + output: None + - inputs: [[], (index, number) => index > 2 && Int.isEven(number)] + output: None +added: 0.1.0 diff --git a/yaml-files/List.flatMap.yaml b/yaml-files/List.flatMap.yaml new file mode 100644 index 00000000..9e0565cb --- /dev/null +++ b/yaml-files/List.flatMap.yaml @@ -0,0 +1,37 @@ +module: List +name: flatMap +docstring: Apply a function [f] onto a list and {!flatten} the resulting list of lists +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => list<'b> + label: true +returnType: list<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + [[1, 2, 3], x => list{x, x}, list{1, 2, 3}] + output: [1, 1, 2, 2, 3, 3] + - inputs: >- + [[], x => list{x, x}] + output: [] + - inputs: >- + [[[1, 1], [2], [3]], x => append(x, list{1})] + output: [1, 1, 1, 2, 1, 3, 1] +examples: + - inputs: >- + [[1, 2, 3], x => list{x, x}, list{1, 2, 3}] + output: [1, 1, 2, 2, 3, 3] + - inputs: >- + [[], x => list{x, x}] + output: [] + - inputs: >- + [[[1, 1], [2], [3]], x => append(x, list{1})] + output: [1, 1, 1, 2, 1, 3, 1] +added: 0.1.0 diff --git a/yaml-files/List.flatten.yaml b/yaml-files/List.flatten.yaml new file mode 100644 index 00000000..ffb26536 --- /dev/null +++ b/yaml-files/List.flatten.yaml @@ -0,0 +1,31 @@ +module: List +name: flatten +docstring: Concatenate a list of lists into a single list + - name: a + type: list> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], []] + output: [] + - inputs: [[1], []] + output: [1] + - inputs: [[1], [2], [3]] + output: [1, 2, 3] + - inputs: [[1], [], [2], [], [3]] + output: [1, 2, 3] +examples: + - inputs: [[], []] + output: [] + - inputs: [[1], []] + output: [1] + - inputs: [[1], [2], [3]] + output: [1, 2, 3] + - inputs: [[1], [], [2], [], [3]] + output: [1, 2, 3] +added: 0.1.0 + diff --git a/yaml-files/List.fromArray.yaml b/yaml-files/List.fromArray.yaml new file mode 100644 index 00000000..589be36b --- /dev/null +++ b/yaml-files/List.fromArray.yaml @@ -0,0 +1,31 @@ +module: List +name: fromArray +docstring: Create a list from an {!Array} +parameters: + - name: a + type: array<'a> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: [] + - inputs: >- + ['h', 'e', 'l', 'l', 'o'] + output: >- + ['h', 'e', 'l', 'l', 'o'] + - inputs: [-1, 3, 2, 7] + output: [-1, 3, 2, 7] +examples: + - inputs: [] + output: [] + - inputs: >- + ['h', 'e', 'l', 'l', 'o'] + output: >- + ['h', 'e', 'l', 'l', 'o'] + - inputs: [-1, 3, 2, 7] + output: [-1, 3, 2, 7] +added: 0.1.0 diff --git a/yaml-files/List.getAt.yaml b/yaml-files/List.getAt.yaml new file mode 100644 index 00000000..c395fcce --- /dev/null +++ b/yaml-files/List.getAt.yaml @@ -0,0 +1,34 @@ +module: List +name: getAt +docstring: Returns the element at position [index] in the list. Returns [None] if [index] is outside of the bounds of the list. +parameters: + - name: a + type: list<'a> + label: false + - name: index + type: int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 2] + output: None + - inputs: [[1, 2, 3], 1] + output: Some(2) + - inputs: [[1, 2, 3], 100] + output: None + - inputs: [[1, 2, 3], -2] + output: None +examples: + - inputs: [[], 2] + output: None + - inputs: [[1, 2, 3], 1] + output: Some(2) + - inputs: [[1, 2, 3], 100] + output: None + - inputs: [[1, 2, 3], -2] + output: None +added: 0.1.0 diff --git a/yaml-files/List.groupWhile.yaml b/yaml-files/List.groupWhile.yaml new file mode 100644 index 00000000..6f30391d --- /dev/null +++ b/yaml-files/List.groupWhile.yaml @@ -0,0 +1,32 @@ +module: List +name: groupWhile +docstring: Divide a list into groups. [f] is called with consecutive elements, when [f] returns [false] a new group is started +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: ('a, 'a) => bool + label: true +returnType: list> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], String.equal] + output: [] + - inputs: [["a", "b", "b", "a", "a", "a", "b", "a"], \"<>"] + output: [["a"], ["b", "b"], ["a", "a", "a"], ["b"], ["a"]] + - inputs: >- + [[2, 4, 6, 5, 3, 1, 8, 7, 9], (x, y) => mod(x, 2) !== mod(y, 2)] + output: [[2, 4, 6], [5, 3, 1], [8], [7, 9]] +examples: + - inputs: [[], String.equal] + output: [] + - inputs: [["a", "b", "b", "a", "a", "a", "b", "a"], \"<>"] + output: [["a"], ["b", "b"], ["a", "a", "a"], ["b"], ["a"]] + - inputs: >- + [[2, 4, 6, 5, 3, 1, 8, 7, 9], (x, y) => mod(x, 2) !== mod(y, 2)] + output: [[2, 4, 6], [5, 3, 1], [8], [7, 9]] +added: 0.1.0 diff --git a/yaml-files/List.head.yaml b/yaml-files/List.head.yaml new file mode 100644 index 00000000..b436b08a --- /dev/null +++ b/yaml-files/List.head.yaml @@ -0,0 +1,23 @@ +module: List +name: head +docstring: Returns, as an {!Option}, the first element of a list. If the list is empty, returns [None]. +parameters: + - name: a + type: list<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: None + - inputs: [-3, 2, 3, 4, 6] + output: Some(-3) +examples: + - inputs: [] + output: None + - inputs: [-3, 2, 3, 4, 6] + output: Some(-3) +added: 0.1.0 diff --git a/yaml-files/List.includes.yaml b/yaml-files/List.includes.yaml new file mode 100644 index 00000000..84153fa4 --- /dev/null +++ b/yaml-files/List.includes.yaml @@ -0,0 +1,34 @@ +module: List +name: includes +docstring: Test if a list contains the specified element using the provided [equal] to test for equality +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: >- + 'a + label: false + - name: equal + type: ('a, 'a) => bool + label: true +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 5, 7], 3, Int.equal] + output: true + - inputs: [[1, 3, 5, 7], 4, Int.equal] + output: false + - inputs: [[], 5, Int.equal] + output: false +examples: + - inputs: [[1, 3, 5, 7], 3, Int.equal] + output: true + - inputs: [[1, 3, 5, 7], 4, Int.equal] + output: false + - inputs: [[], 5, Int.equal] + output: false +added: 0.1.0 diff --git a/yaml-files/List.initial.yaml b/yaml-files/List.initial.yaml new file mode 100644 index 00000000..1fef1ea9 --- /dev/null +++ b/yaml-files/List.initial.yaml @@ -0,0 +1,31 @@ +module: List +name: initial +docstring: As an {!Option} get of all of the elements of a list except the last one. Returns [None] if the list is empty +parameters: + - name: a + type: list<'a> + label: false +returnType: option> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: None + - inputs: >- + ['a'] + output: Some([]) + - inputs: >- + ['a', 'b'] + output: Some(['a']) +examples: + - inputs: [] + output: None + - inputs: >- + ['a'] + output: Some([]) + - inputs: >- + ['a', 'b'] + output: Some(['a']) +added: 0.1.0 diff --git a/yaml-files/List.initialize.yaml b/yaml-files/List.initialize.yaml new file mode 100644 index 00000000..7c1a1e45 --- /dev/null +++ b/yaml-files/List.initialize.yaml @@ -0,0 +1,26 @@ +module: List +name: initialize +docstring: Initialize a list +parameters: + - name: a + type: int + label: false + - name: f + type: int => 'a + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [4, index => index] + output: [0, 1, 2, 3] + - inputs: [4, index => index * index] + output: [0, 1, 4, 9] +examples: + - inputs: [4, index => index] + output: [0, 1, 2, 3] + - inputs: [4, index => index * index] + output: [0, 1, 4, 9] +added: 0.1.0 diff --git a/yaml-files/List.insertAt.yaml b/yaml-files/List.insertAt.yaml new file mode 100644 index 00000000..6721903b --- /dev/null +++ b/yaml-files/List.insertAt.yaml @@ -0,0 +1,62 @@ +module: List +name: insertAt +docstring: Insert a new element at the specified index. The element previously occupying [index] will now be at [index + 1]. If [index] is greater than then length of the list, it will be appended +parameters: + - name: a + type: list<'a> + label: false + - name: index + type: int + label: true + - name: value + type: >- + 'a + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 0, 1] + output: [1] + - inputs: [[1, 3], 1, 2] + output: [1, 2, 3] + - inputs: [[1, 3], 0, 2] + output: [2, 1, 3] + - inputs: [[1, 3], 4, 2] + output: [1, 3, 2] + - inputs: [[0, 2, 3, 4, 5, 6, 7, 8, 9], 5, 1] + output: [0, 2, 3, 4, 5, 1, 6, 7, 8, 9] + - inputs: [[100, 101, 102, 103], 2, 999] + output: [100, 101, 999, 102, 103] + - inputs: [[100, 101, 102, 103], 0, 999] + output: [999, 100, 101, 102, 103] + - inputs: [[100, 101, 102, 103], 4, 999] + output: [100, 101, 102, 103, 999] + - inputs: [[100, 101, 102, 103], -1, 999] + output: [999, 100, 101, 102, 103] + - inputs: [[100, 101, 102, 103], 5, 999] + output: [100, 101, 102, 103, 999] +examples: + - inputs: [[], 0, 1] + output: [1] + - inputs: [[1, 3], 1, 2] + output: [1, 2, 3] + - inputs: [[1, 3], 0, 2] + output: [2, 1, 3] + - inputs: [[1, 3], 4, 2] + output: [1, 3, 2] + - inputs: [[0, 2, 3, 4, 5, 6, 7, 8, 9], 5, 1] + output: [0, 2, 3, 4, 5, 1, 6, 7, 8, 9] + - inputs: [[100, 101, 102, 103], 2, 999] + output: [100, 101, 999, 102, 103] + - inputs: [[100, 101, 102, 103], 0, 999] + output: [999, 100, 101, 102, 103] + - inputs: [[100, 101, 102, 103], 4, 999] + output: [100, 101, 102, 103, 999] + - inputs: [[100, 101, 102, 103], -1, 999] + output: [999, 100, 101, 102, 103] + - inputs: [[100, 101, 102, 103], 5, 999] + output: [100, 101, 102, 103, 999] +added: 0.1.0 diff --git a/yaml-files/List.intersperse.yaml b/yaml-files/List.intersperse.yaml new file mode 100644 index 00000000..a74f70f4 --- /dev/null +++ b/yaml-files/List.intersperse.yaml @@ -0,0 +1,31 @@ +module: List +name: intersperse +docstring: Places [sep] between all the elements of the given list +parameters: + - name: a + type: list<'a> + label: false + - name: sep + type: >- + 'a + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], "on"] + output: [] + - inputs: [["turtles"], "on"] + output: ["turtles"] + - inputs: [["turtles", "turtles", "turtles"], "on"] + output: ["turtles", "on", "turtles", "on", "turtles"] +examples: + - inputs: [[], "on"] + output: [] + - inputs: [["turtles"], "on"] + output: ["turtles"] + - inputs: [["turtles", "turtles", "turtles"], "on"] + output: ["turtles", "on", "turtles", "on", "turtles"] +added: 0.1.0 diff --git a/yaml-files/List.isEmpty.yaml b/yaml-files/List.isEmpty.yaml new file mode 100644 index 00000000..564f12b0 --- /dev/null +++ b/yaml-files/List.isEmpty.yaml @@ -0,0 +1,27 @@ +module: List +name: isEmpty +docstring: Determine if a list is empty +parameters: + - name: a + type: list<_> + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: List.empty + output: true + - inputs: [] + output: true + - inputs: [1, -4, 5, 6] + output: false +examples: + - inputs: List.empty + output: true + - inputs: [] + output: true + - inputs: [1, -4, 5, 6] + output: false +added: 0.1.0 diff --git a/yaml-files/List.join.yaml b/yaml-files/List.join.yaml new file mode 100644 index 00000000..c889bacc --- /dev/null +++ b/yaml-files/List.join.yaml @@ -0,0 +1,26 @@ +module: List +name: join +docstring: Converts a list of strings into a {!String}, placing [sep] between each string in the result +parameters: + - name: a + type: list + label: false + - name: sep + type: string + label: true +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [["Ant", "Bat", "Cat"], ", "] + output: "Ant, Bat, Cat" + - inputs: [[], ", "] + output: "" +examples: + - inputs: [["Ant", "Bat", "Cat"], ", "] + output: "Ant, Bat, Cat" + - inputs: [[], ", "] + output: "" +added: 0.1.0 diff --git a/yaml-files/List.last.yaml b/yaml-files/List.last.yaml new file mode 100644 index 00000000..eb8a4d63 --- /dev/null +++ b/yaml-files/List.last.yaml @@ -0,0 +1,31 @@ +module: List +name: last +docstring: As an {!Option} get of all of the elements of a list except the last one. Returns [None] if the list is emptyGet the last element of a list. Returns [None] if the list is empty. +parameters: + - name: a + type: list<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: None + - inputs: >- + ['a'] + output: Some('a') + - inputs: >- + ['a', 'b'] + output: Some('b') +examples: + - inputs: [] + output: None + - inputs: >- + ['a'] + output: Some('a') + - inputs: >- + ['a', 'b'] + output: Some('b') +added: 0.1.0 diff --git a/yaml-files/List.length.yaml b/yaml-files/List.length.yaml new file mode 100644 index 00000000..67e3bf1a --- /dev/null +++ b/yaml-files/List.length.yaml @@ -0,0 +1,23 @@ +module: List +name: length +docstring: Return the number of elements in a list +parameters: + - name: a + type: list<'a> + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: 0 + - inputs: [1, -4, 5, 6] + output: 4 +examples: + - inputs: [] + output: 0 + - inputs: [1, -4, 5, 6] + output: 4 +added: 0.1.0 diff --git a/yaml-files/List.map.yaml b/yaml-files/List.map.yaml new file mode 100644 index 00000000..b260165e --- /dev/null +++ b/yaml-files/List.map.yaml @@ -0,0 +1,39 @@ +module: List +name: map +docstring: Create a new list which is the result of applying a function [f] to every element +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => 'b + label: true +returnType: list<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + [[1.0, 4.0, 9.0], Float.squareRoot] + output: >- + [1.0, 2.0, 3.0] + - inputs: >- + [[['i'], ['a'], ['o', 'p']], element => cons(element, 'h')] + output: >- + [['h', 'i'], ['h', 'a'], ['h', 'o', 'p']] + - inputs: [[], Float.squareRoot] + output: [] +examples: + - inputs: >- + [[1.0, 4.0, 9.0], Float.squareRoot] + output: >- + [1.0, 2.0, 3.0] + - inputs: >- + [[['i'], ['a'], ['o', 'p']], element => cons(element, 'h')] + output: >- + [['h', 'i'], ['h', 'a'], ['h', 'o', 'p']] + - inputs: [[], Float.squareRoot] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.map2.yaml b/yaml-files/List.map2.yaml new file mode 100644 index 00000000..726bd140 --- /dev/null +++ b/yaml-files/List.map2.yaml @@ -0,0 +1,37 @@ +module: List +name: map2 +docstring: Combine two lists, using [f] to combine each pair of elements. If one list is longer, the extra elements are dropped. +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: list<'b> + label: false + - name: f + type: ('a, 'b) => 'c) + label: true +returnType: list<'c> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], [], \"+"] + output: [] + - inputs: [[1], [1], \"+"] + output: [2] + - inputs: [[1, 2], [1, 2], \"+"] + output: [2, 4] + - inputs: [[1, 2, 3], [1, 2], \"+"] + output: [2, 4] +examples: + - inputs: [[], [], \"+"] + output: [] + - inputs: [[1], [1], \"+"] + output: [2] + - inputs: [[1, 2], [1, 2], \"+"] + output: [2, 4] + - inputs: [[1, 2, 3], [1, 2], \"+"] + output: [2, 4] +added: 0.1.0 diff --git a/yaml-files/List.map3.yaml b/yaml-files/List.map3.yaml new file mode 100644 index 00000000..8253ea3b --- /dev/null +++ b/yaml-files/List.map3.yaml @@ -0,0 +1,48 @@ +module: List +name: map3 +docstring: Combine three lists, using [f] to combine each trio of elements. If one list is longer, the extra elements are dropped +parameters: + - name: a + type: list<'a> + label: false + - name: b + type: list<'b> + label: false + - name: c + type: list<'c> + label: false + - name: f + type: ('a, 'b, 'c) => 'd + label: true +returnType: list<'d> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + [[], [], [], (x, y, z) => x + y + z] + output: [] + - inputs: >- + [[1], [1], [1],(x, y, z) => x + y + z] + output: [3] + - inputs: >- + [[1, 2], [1, 2], [1, 2], (x, y, z) => x + y + z] + output: [3, 6] + - inputs: >- + [[1, 2, 3],[1, 2, 3], [1, 2], (x, y, z) => x + y + z] + output: [3, 6] +examples: + - inputs: >- + [[], [],[], (x, y, z) => x + y + z] + output: [] + - inputs: >- + [[1], [1], [1],(x, y, z) => x + y + z] + output: [3] + - inputs: >- + [[1, 2], [1, 2], [1, 2], (x, y, z) => x + y + z] + output: [3, 6] + - inputs: >- + [[1, 2, 3],[1, 2, 3], [1, 2], (x, y, z) => x + y + z] + output: [3, 6] +added: 0.1.0 diff --git a/yaml-files/List.mapWithIndex.yaml b/yaml-files/List.mapWithIndex.yaml new file mode 100644 index 00000000..9dd59a10 --- /dev/null +++ b/yaml-files/List.mapWithIndex.yaml @@ -0,0 +1,36 @@ +module: List +name: mapWithIndex +docstring: Apply a function [f] to every element and its index +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: (int, 'a) => 'b) + label: true +returnType: list<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + [[], (i, _) => i] + output: [] + - inputs: >- + [['a'], (i, _) => i] + output: [0] + - inputs: >- + [['a', 'b'], (i, _) => i] + output: [0, 1] +examples: + - inputs: >- + [[], (i, _) => i] + output: [] + - inputs: >- + [['a'], (i, _) => i] + output: [0] + - inputs: >- + [['a', 'b'], (i, _) => i] + output: [0, 1] +added: 0.1.0 diff --git a/yaml-files/List.maximum.yaml b/yaml-files/List.maximum.yaml new file mode 100644 index 00000000..9c31d62e --- /dev/null +++ b/yaml-files/List.maximum.yaml @@ -0,0 +1,26 @@ +module: List +name: maximum +docstring: Find the largest element using the provided [compare] function. Returns [None] if called on an empty list +parameters: + - name: a + type: list<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[7, 9, 15, 10, 3], Int.compare] + output: Some(15) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[7, 9, 15, 10, 3], Int.compare] + output: Some(15) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/List.maximumBy.yaml b/yaml-files/List.maximumBy.yaml new file mode 100644 index 00000000..9f2a2100 --- /dev/null +++ b/yaml-files/List.maximumBy.yaml @@ -0,0 +1,30 @@ +module: List +name: maximumBy +docstring: >- + [List.maximumBy ~f:fcn xs], when given a non-empty list, returns the item in the list for which [fcn item] is a maximum. It is returned as [Some item]. + If given an empty list, [List.maximumBy] returns [None]. If more than one value has a maximum value for [fcn item], the first one is returned. + The function provided takes a list item as its parameter and must return a value that can be compared: for example, a [string] or [int] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => 'comparable + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[7, 9, 15, 10, 3, 22], x => mod(x, 12)] + output: Some(10) + - inputs: [[], x => mod(x, 12)] + output: None +examples: + - inputs: [[7, 9, 15, 10, 3, 22], x => mod(x, 12)] + output: Some(10) + - inputs: [[], x => mod(x, 12)] + output: None +added: 0.1.0 diff --git a/yaml-files/List.minimum.yaml b/yaml-files/List.minimum.yaml new file mode 100644 index 00000000..a1921999 --- /dev/null +++ b/yaml-files/List.minimum.yaml @@ -0,0 +1,26 @@ +module: List +name: minimum +docstring: Find the smallest element using the provided [compare] function. Returns [None] if called on an empty list. +parameters: + - name: a + type: list<'a> + label: false + - name: compare + type: ('a, 'a) => int + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[7, 9, 15, 10, 3], Int.compare] + output: Some(3) + - inputs: [[], Int.compare] + output: None +examples: + - inputs: [[7, 9, 15, 10, 3], Int.compare] + output: Some(3) + - inputs: [[], Int.compare] + output: None +added: 0.1.0 diff --git a/yaml-files/List.minimumBy.yaml b/yaml-files/List.minimumBy.yaml new file mode 100644 index 00000000..2f03adf5 --- /dev/null +++ b/yaml-files/List.minimumBy.yaml @@ -0,0 +1,30 @@ +module: List +name: minimumBy +docstring: >- + [List.minimumBy(xs, ~f=fcn)], when given a non-empty list, returns the item in the list for which [fcn item] is a minimum. It is returned as [Some(item)]. + If given an empty list, [List.minimumBy] returns [None]. If more than one value has a minimum value for [fcn item], the first one is returned. + The function provided takes a list item as its parameter and must return a value that can be compared: for example, a [string] or [int]. +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => 'comparable + label: true +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[7, 9, 15, 10, 3, 22], x => mod(x, 12)] + output: Some(15) + - inputs: [[], x => mod(x, 12)] + output: None +examples: + - inputs: [[7, 9, 15, 10, 3, 22], x => mod(x, 12)] + output: Some(15) + - inputs: [[], x => mod(x, 12)] + output: None +added: 0.1.0 diff --git a/yaml-files/List.partition.yaml b/yaml-files/List.partition.yaml new file mode 100644 index 00000000..f0da1216 --- /dev/null +++ b/yaml-files/List.partition.yaml @@ -0,0 +1,31 @@ +module: List +name: partition +docstring: Split a list into a {!Tuple2} of lists. Values which [f] returns true for will end up in {!Tuple2.first} +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: (list<'a>, list<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: ([],[]) + - inputs: [[1], Int.isEven] + output: ([],[1]) + - inputs: [[1, 2, 3, 4], Int.isEven] + output: ([2, 4],[1,3]) +examples: + - inputs: [[], Int.isEven] + output: ([],[]) + - inputs: [[1], Int.isEven] + output: ([],[1]) + - inputs: [[1, 2, 3, 4], Int.isEven] + output: ([2, 4],[1,3]) +added: 0.1.0 diff --git a/yaml-files/List.range.yaml b/yaml-files/List.range.yaml new file mode 100644 index 00000000..ffa4b788 --- /dev/null +++ b/yaml-files/List.range.yaml @@ -0,0 +1,38 @@ +module: List +name: range +docstring: Creates a list containing all of the integers from [from] if it is provided or [0] if not, up to but not including [to] +parameters: + - name: from + type: int=? + label: true + - name: a + type: int + label: false +returnType: list +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: 0 + output: [] + - inputs: 5 + output: [0, 1, 2, 3, 4] + - inputs: [2, 5] + output: [2, 3, 4] + - inputs: [-2, 2] + output: [-2, -1, 0, 1] + - inputs: [5, 2] + output: [] +examples: + - inputs: 0 + output: [] + - inputs: 5 + output: [0, 1, 2, 3, 4] + - inputs: [2, 5] + output: [2, 3, 4] + - inputs: [-2, 2] + output: [-2, -1, 0, 1] + - inputs: [5, 2] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.removeAt.yaml b/yaml-files/List.removeAt.yaml new file mode 100644 index 00000000..9eec90d6 --- /dev/null +++ b/yaml-files/List.removeAt.yaml @@ -0,0 +1,42 @@ +module: List +name: removeAt +docstring: Creates a new list without the element at [index]. If [index] is outside of the bounds of the list, returns the list as-is +parameters: + - name: a + type: list<'a> + label: false + - name: index + type: int + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3], -1] + output: [1, 3] + - inputs: [[], 0] + output: [] + - inputs: [[], 2] + output: [] + - inputs: [[1, 3], 1] + output: [1] + - inputs: [[1, 3], 0] + output: [3] + - inputs: [[1, 3], 4] + output: [1, 3] +examples: + - inputs: [[1, 3], -1] + output: [1, 3] + - inputs: [[], 0] + output: [] + - inputs: [[], 2] + output: [] + - inputs: [[1, 3], 1] + output: [1] + - inputs: [[1, 3], 0] + output: [3] + - inputs: [[1, 3], 4] + output: [1, 3] +added: 0.1.0 diff --git a/yaml-files/List.repeat.yaml b/yaml-files/List.repeat.yaml new file mode 100644 index 00000000..d75bf0bc --- /dev/null +++ b/yaml-files/List.repeat.yaml @@ -0,0 +1,35 @@ +module: List +name: repeat +docstring: Creates a list of length [times] with the value [a] populated at each index +parameters: + - name: a + type: >- + 'a + label: false + - name: times + type: int + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [7, 0] + output: [] + - inputs: [7, -10] + output: [] + - inputs: >- + ['a', 5] + output: >- + ['a', 'a', 'a', 'a', 'a'] +examples: + - inputs: [7, 0] + output: [] + - inputs: [7, -10] + output: [] + - inputs: >- + ['a', 5] + output: >- + ['a', 'a', 'a', 'a', 'a'] +added: 0.1.0 diff --git a/yaml-files/List.reverse.yaml b/yaml-files/List.reverse.yaml new file mode 100644 index 00000000..789a0cd6 --- /dev/null +++ b/yaml-files/List.reverse.yaml @@ -0,0 +1,27 @@ +module: List +name: reverse +docstring: Reverse the elements in a list +parameters: + - name: a + type: list<'a> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: [] + - inputs: [0] + output: [0] + - inputs: [0, 1] + output: [1, 0] +examples: + - inputs: [] + output: [] + - inputs: [0] + output: [0] + - inputs: [0, 1] + output: [1, 0] +added: 0.1.0 diff --git a/yaml-files/List.singleton.yaml b/yaml-files/List.singleton.yaml new file mode 100644 index 00000000..3e64def5 --- /dev/null +++ b/yaml-files/List.singleton.yaml @@ -0,0 +1,28 @@ +module: List +name: singleton +docstring: Create a list with only one element +parameters: + - name: a + type: >- + 'a + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "" + output: [""] + - inputs: 1234 + output: [1234] + - inputs: "hello" + output: ["hello"] +examples: + - inputs: "" + output: [""] + - inputs: 1234 + output: [1234] + - inputs: "hello" + output: ["hello"] +added: 0.1.0 diff --git a/yaml-files/List.sliding.yaml b/yaml-files/List.sliding.yaml new file mode 100644 index 00000000..a055ef27 --- /dev/null +++ b/yaml-files/List.sliding.yaml @@ -0,0 +1,49 @@ +module: List +name: sliding +docstring: Provides a sliding 'window' of sub-lists over a list +parameters: + - name: a + type: list<'a> + label: false + - name: size + type: int + label: true + - name: step + type: int=? + label: true +returnType: list> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5], 1] + output: [[1], [2], [3], [4], [5]] + - inputs: [[1, 2, 3, 4, 5], 2] + output: [[1, 2], [2, 3], [3, 4], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 3] + output: [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + - inputs: [[1, 2, 3, 4, 5], 2, 2] + output: [[1, 2], [3, 4]] + - inputs: [[1, 2, 3, 4, 5], 1, 3] + output: [[1], [4]] + - inputs: [[1, 2, 3, 4, 5], 2, 3] + output: [[1, 2], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 7] + output: [] +examples: + - inputs: [[1, 2, 3, 4, 5], 1] + output: [[1], [2], [3], [4], [5]] + - inputs: [[1, 2, 3, 4, 5], 2] + output: [[1, 2], [2, 3], [3, 4], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 3] + output: [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + - inputs: [[1, 2, 3, 4, 5], 2, 2] + output: [[1, 2], [3, 4]] + - inputs: [[1, 2, 3, 4, 5], 1, 3] + output: [[1], [4]] + - inputs: [[1, 2, 3, 4, 5], 2, 3] + output: [[1, 2], [4, 5]] + - inputs: [[1, 2, 3, 4, 5], 7] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.sort.yaml b/yaml-files/List.sort.yaml new file mode 100644 index 00000000..30520555 --- /dev/null +++ b/yaml-files/List.sort.yaml @@ -0,0 +1,34 @@ +module: List +name: sort +docstring: Sort using the provided [compare] function +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: ('a, 'a) => int + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.compare] + output: [] + - inputs: [[5], Int.compare] + output: [5] + - inputs: [[5, 6, 8, 3, 6], Int.compare] + output: [3, 5, 6, 6, 8] + - inputs: [[5, 6, -8, 3, 6], Int.compare] + output: [-8, 3, 5, 6, 6] +examples: + - inputs: [[], Int.compare] + output: [] + - inputs: [[5], Int.compare] + output: [5] + - inputs: [[5, 6, 8, 3, 6], Int.compare] + output: [3, 5, 6, 6, 8] + - inputs: [[5, 6, -8, 3, 6], Int.compare] + output: [-8, 3, 5, 6, 6] +added: 0.1.0 diff --git a/yaml-files/List.splitAt.yaml b/yaml-files/List.splitAt.yaml new file mode 100644 index 00000000..8616fd97 --- /dev/null +++ b/yaml-files/List.splitAt.yaml @@ -0,0 +1,48 @@ +module: List +name: splitAt +docstring: Divides a list into a {!Tuple2} of lists. +Elements which have index upto (but not including) [index] will be in the first component of the tuple. +Elements with an index greater than or equal to [index] will be in the second. +If [index] is zero or negative, all elements will be in the second component of the tuple. +If [index] is greater than the length of the list, all elements will be in the second component of the tuple. +parameters: + - name: a + type: list<'a> + label: false + - name: index + type: int + label: true +returnType: (list<'a>, list<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], 1] + output: ([], []) + - inputs: [[2, 4, 6], 0] + output: ([], [2, 4, 6]) + - inputs: [[1, 3, 2, 4], 2] + output: ([1, 3], [2, 4]) + - inputs: [[1, 3, 5], 3] + output: ([1, 3, 5], []) + - inputs: [[1, 3, 5], 6] + output: ([1, 3, 5], []) + - inputs: [[1, 3, 5], -1] + output: ([], [1, 3, 5]) +examples: + - inputs: [[], 1] + output: ([], []) + - inputs: [[2, 4, 6], 0] + output: ([], [2, 4, 6]) + - inputs: [[1, 3, 2, 4], 2] + output: ([1, 3], [2, 4]) + - inputs: [[1, 3, 5], 3] + output: ([1, 3, 5], []) + - inputs: [[1, 3, 5], 6] + output: ([1, 3, 5], []) + - inputs: [[1, 3, 5], -1] + output: ([], [1, 3, 5]) +added: 0.1.0 + + diff --git a/yaml-files/List.splitWhen.yaml b/yaml-files/List.splitWhen.yaml new file mode 100644 index 00000000..629d4221 --- /dev/null +++ b/yaml-files/List.splitWhen.yaml @@ -0,0 +1,36 @@ +module: List +name: splitWhen +docstring: Divides a list into a {!Tuple2} at the first element where function [f] will return [true]. +Elements up to (but not including) the first element [f] returns [true] for will be in the first component of the tuple, the remaining elements will be in the second. +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: (list<'a>, list<'a>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[], Int.isEven] + output: ([], []) + - inputs: [[2, 4, 6], Int.isEven] + output: ([], [2, 4, 6]) + - inputs: [[1, 3, 2, 4], Int.isEven] + output: ([1, 3], [2, 4]) + - inputs: [[1, 3, 5], Int.isEven] + output: ([1, 3, 5], []) +examples: + - inputs: [[], Int.isEven] + output: ([], []) + - inputs: [[2, 4, 6], Int.isEven] + output: ([], [2, 4, 6]) + - inputs: [[1, 3, 2, 4], Int.isEven] + output: ([1, 3], [2, 4]) + - inputs: [[1, 3, 5], Int.isEven] + output: ([1, 3, 5], []) +added: 0.1.0 diff --git a/yaml-files/List.take.yaml b/yaml-files/List.take.yaml new file mode 100644 index 00000000..f92af01d --- /dev/null +++ b/yaml-files/List.take.yaml @@ -0,0 +1,34 @@ +module: List +name: take +docstring: Attempt to take the first [count] elements of a list. If the list has fewer than [count] elements, returns the entire list. If count is zero or negative, returns [list{}] +parameters: + - name: a + type: list<'a> + label: false + - name: count + type: int + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3], 2] + output: [1, 2] + - inputs: [[], 2] + output: [] + - inputs: [[1, 2, 3, 4], 8] + output: [1, 2, 3, 4] + - inputs: [[1, 2, 3, 4], -1] + output: [] +examples: + - inputs: [[1, 2, 3], 2] + output: [1, 2] + - inputs: [[], 2] + output: [] + - inputs: [[1, 2, 3, 4], 8] + output: [1, 2, 3, 4] + - inputs: [[1, 2, 3, 4], -1] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.takeWhile.yaml b/yaml-files/List.takeWhile.yaml new file mode 100644 index 00000000..3689f28c --- /dev/null +++ b/yaml-files/List.takeWhile.yaml @@ -0,0 +1,43 @@ +module: List +name: takeWhile +docstring: Take elements from a list until [f] returns [false] +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => bool + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [2, 4, 6] + - inputs: [[2, 6, 7, 15, 10, 9, 8], Int.isEven] + output: [2, 6] + - inputs: [[1, 6, 7, 15, 10, 9, 8], Int.isEven] + output: [] + - inputs: [[2, 4, 6], Int.isEven] + output: [2, 4, 6] + - inputs: [[], Int.isEven] + output: [] + - inputs: [[1, 3, 5], Int.isEven] + output: [] +examples: + - inputs: [[2, 4, 6, 7, 8, 9], Int.isEven] + output: [2, 4, 6] + - inputs: [[2, 6, 7, 15, 10, 9, 8], Int.isEven] + output: [2, 6] + - inputs: [[1, 6, 7, 15, 10, 9, 8], Int.isEven] + output: [] + - inputs: [[2, 4, 6], Int.isEven] + output: [2, 4, 6] + - inputs: [[], Int.isEven] + output: [] + - inputs: [[1, 3, 5], Int.isEven] + output: [] +added: 0.1.0 diff --git a/yaml-files/List.toArray.yaml b/yaml-files/List.toArray.yaml new file mode 100644 index 00000000..a3af5feb --- /dev/null +++ b/yaml-files/List.toArray.yaml @@ -0,0 +1,31 @@ +module: List +name: toArray +docstring: Converts a list to an {!Array}. +parameters: + - name: a + type: list<'a> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [2, 4, 6, 8] + output: [2, 4, 6, 8] + - inputs: [] + output: [] + - inputs: >- + ['h', 'i'] + output: >- + ['h', 'i'] +examples: + - inputs: [2, 4, 6, 8] + output: [2, 4, 6, 8] + - inputs: [] + output: [] + - inputs: >- + ['h', 'i'] + output: >- + ['h', 'i'] +added: 0.1.0 diff --git a/yaml-files/List.uniqueBy.yaml b/yaml-files/List.uniqueBy.yaml new file mode 100644 index 00000000..47687021 --- /dev/null +++ b/yaml-files/List.uniqueBy.yaml @@ -0,0 +1,33 @@ +module: List +name: uniqueBy +docstring: >- + [List.uniqueBy(xs, ~f=fcn)] returns a new list containing only those elements from [xs] that have a unique value when [fcn] is applied to them. + The function [fcn] takes as its single parameter an item from the list and returns a [string]. If the function generates the same string for two or more list items, only the first of them is retained. +parameters: + - name: a + type: list<'a> + label: false + - name: f + type: >- + 'a => string + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3, 4, 3, 7, 7, 6], element => string_of_int(element)] + output: [1, 3, 4, 7, 6] + - inputs: [[1, 3, 4, 3, 7, 7, 6], element => string_of_int(mod(5, element))] + output: [1, 3, 4, 7] + - inputs: [["hello", "h", "e", "hello", "l", "l", "o"], element => element] + output: ["hello", "h", "e", "l", "o"] +examples: + - inputs: [[1, 3, 4, 3, 7, 7, 6], element => string_of_int(element)] + output: [1, 3, 4, 7, 6] + - inputs: [[1, 3, 4, 3, 7, 7, 6], element => string_of_int(mod(5, element))] + output: [1, 3, 4, 7] + - inputs: [["hello", "h", "e", "hello", "l", "l", "o"], element => element] + output: ["hello", "h", "e", "l", "o"] +added: 0.1.0 diff --git a/yaml-files/List.unzip.yaml b/yaml-files/List.unzip.yaml new file mode 100644 index 00000000..edbcd1c5 --- /dev/null +++ b/yaml-files/List.unzip.yaml @@ -0,0 +1,18 @@ +module: List +name: unzip +docstring: Decompose a list of {!Tuple2} into a {!Tuple2} of lists + - name: a + type: list<('a,'b)> + label: false +returnType: (list<'a>, list<'b>) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [(0, true), (17, false), (1337, true)] + output: ([0, 17, 1337], [true, false, true]) +examples: + - inputs: [(0, true), (17, false), (1337, true)] + output: ([0, 17, 1337], [true, false, true]) +added: 0.1.0 diff --git a/yaml-files/List.updateAt.yaml b/yaml-files/List.updateAt.yaml new file mode 100644 index 00000000..92a173fa --- /dev/null +++ b/yaml-files/List.updateAt.yaml @@ -0,0 +1,46 @@ +module: List +name: updateAt +docstring: Returns a new list with the value at [index] updated to be the result of applying [f]. If [index] is outside of the bounds of the list, returns the list as-is +parameters: + - name: a + type: list<'a> + label: false + - name: index + type: int + label: true + - name: f + type: >- + 'a => 'a + label: true +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 3], -1, x => x + 1] + output: [1, 3] + - inputs: [[], 0, x => x + 1] + output: [] + - inputs: [[], 2, x => x + 1] + output: [] + - inputs: [[1, 3], 1, x => x + 1] + output: [1, 4] + - inputs: [[1, 3], 0, x => x + 1] + output: [2, 3] + - inputs: [[1, 3], 4, x => x + 1] + output: [1, 3] +examples: + - inputs: [[1, 3], -1, x => x + 1] + output: [1, 3] + - inputs: [[], 0, x => x + 1] + output: [] + - inputs: [[], 2, x => x + 1] + output: [] + - inputs: [[1, 3], 1, x => x + 1] + output: [1, 4] + - inputs: [[1, 3], 0, x => x + 1] + output: [2, 3] + - inputs: [[1, 3], 4, x => x + 1] + output: [1, 3] +added: 0.1.0 diff --git a/yaml-files/List.zip.yaml b/yaml-files/List.zip.yaml new file mode 100644 index 00000000..3353f619 --- /dev/null +++ b/yaml-files/List.zip.yaml @@ -0,0 +1,26 @@ +module: List +name: zip +docstring: Combine two lists by merging each pair of elements into a {!Tuple2}. If one list is longer, the extra elements are dropped + - name: a + type: list<'a> + label: false + - name: b + type: list<'b> + label: false +returnType: list<('a,'b)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [[1, 2, 3, 4, 5], ["Dog", "Eagle", "Ferret"]] + output: [(1, "Dog"), (2, "Eagle"), (3, "Ferret")] + - inputs: [[1, 2, 3, 4, 5], []] + output: [] +examples: + - inputs: [[1, 2, 3, 4, 5], ["Dog", "Eagle", "Ferret"]] + output: [(1, "Dog"), (2, "Eagle"), (3, "Ferret")] + - inputs: [[1, 2, 3, 4, 5], []] + output: [] +added: 0.1.0 + diff --git a/yaml-files/Option.andThen.yaml b/yaml-files/Option.andThen.yaml new file mode 100644 index 00000000..cd69c7c2 --- /dev/null +++ b/yaml-files/Option.andThen.yaml @@ -0,0 +1,28 @@ +module: Option +name: andThen +docstring: Chain together many computations that may not return a value +parameters: + - name: a + type: option<'a> + label: false + - name: f + type: >- + 'a => option<'b> + label: true +returnType: option<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some([1,2,3]), List.head] + output: Some(1) + - inputs: [Some([]), List.head] + output: None +examples: + - inputs: [Some([1,2,3]), List.head] + output: Some(1) + - inputs: [Some([]), List.head] + output: None +added: 0.1.0 + diff --git a/yaml-files/Option.and_.yaml b/yaml-files/Option.and_.yaml new file mode 100644 index 00000000..9f51e118 --- /dev/null +++ b/yaml-files/Option.and_.yaml @@ -0,0 +1,34 @@ +module: Option +name: and_ +docstring: Returns [None] if is [None], otherwise return . +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(1), Some(15)] + output: Some(15) + - inputs: [None, Some(15)] + output: None + - inputs: [Some(1), None] + output: None + - inputs: [None, None] + output: None +examples: + - inputs: [Some(1), Some(15)] + output: Some(15) + - inputs: [None, Some(15)] + output: None + - inputs: [Some(1), None] + output: None + - inputs: [None, None] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.both.yaml b/yaml-files/Option.both.yaml new file mode 100644 index 00000000..379a5acf --- /dev/null +++ b/yaml-files/Option.both.yaml @@ -0,0 +1,34 @@ +module: Option +name: both +docstring: Transform and into an option of a {!Tuple2}. Returns None if either of the aguments is None. +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'b> + label: false +returnType: option<('a, 'b)> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(3004), Some("Ant")] + output: Some(3004, "Ant") + - inputs: [None, Some("Ant")] + output: None + - inputs: [Some(3004), None] + output: None + - inputs: [None, None] + output: None +examples: + - inputs: [Some(3004), Some("Ant")] + output: Some(3004, "Ant") + - inputs: [None, Some("Ant")] + output: None + - inputs: [Some(3004), None] + output: None + - inputs: [None, None] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.compare.yaml b/yaml-files/Option.compare.yaml new file mode 100644 index 00000000..938a1e99 --- /dev/null +++ b/yaml-files/Option.compare.yaml @@ -0,0 +1,33 @@ +module: Option +name: compare +docstring: Compare and using the provided [f] function +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'a> + label: false + - name: f + type: ('a, 'a) => int + label: true +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(1), Some(3), Int.compare] + output: -1 + - inputs: [Some(1), None, Int.compare] + output: 1 + - inputs: [None, None, Int.compare] + output: 0 +examples: + - inputs: [Some(1), Some(3), Int.compare] + output: -1 + - inputs: [Some(1), None, Int.compare] + output: 1 + - inputs: [None, None, Int.compare] + output: 0 +added: 0.1.0 diff --git a/yaml-files/Option.equal.yaml b/yaml-files/Option.equal.yaml new file mode 100644 index 00000000..8fabb2e6 --- /dev/null +++ b/yaml-files/Option.equal.yaml @@ -0,0 +1,37 @@ +module: Option +name: equal +docstring: Test and for equality using the provided function +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'a> + label: false + - name: c + type: ('a, 'a) => bool + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(1), Some(1), Int.equal] + output: true + - inputs: [Some(1), Some(3), Int.equal] + output: false + - inputs: [Some(1), None, Int.equal] + output: false + - inputs: [None, None, Int.equal] + output: true +examples: + - inputs: [Some(1), Some(1), Int.equal] + output: true + - inputs: [Some(1), Some(3), Int.equal] + output: false + - inputs: [Some(1), None, Int.equal] + output: false + - inputs: [None, None, Int.equal] + output: true +added: 0.1.0 diff --git a/yaml-files/Option.flatten.yaml b/yaml-files/Option.flatten.yaml new file mode 100644 index 00000000..1f1f4dd7 --- /dev/null +++ b/yaml-files/Option.flatten.yaml @@ -0,0 +1,27 @@ +module: Option +name: flatten +docstring: Flatten two optional layers into a single optional layer +parameters: + - name: a + type: option> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(Some(4)) + output: Some(4) + - inputs: Some(None) + output: None + - inputs: None + output: None +examples: + - inputs: Some(Some(4)) + output: Some(4) + - inputs: Some(None) + output: None + - inputs: None + output: None +added: 0.1.0 diff --git a/yaml-files/Option.isNone.yaml b/yaml-files/Option.isNone.yaml new file mode 100644 index 00000000..39d92ebe --- /dev/null +++ b/yaml-files/Option.isNone.yaml @@ -0,0 +1,23 @@ +module: Option +name: isNone +docstring: Check if is a [None] +parameters: + - name: a + type: option<'a> + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(3004) + output: false + - inputs: None + output: true +examples: + - inputs: Some(3004) + output: false + - inputs: None + output: true +added: 0.1.0 diff --git a/yaml-files/Option.isSome.yaml b/yaml-files/Option.isSome.yaml new file mode 100644 index 00000000..285a7988 --- /dev/null +++ b/yaml-files/Option.isSome.yaml @@ -0,0 +1,23 @@ +module: Option +name: isSome +docstring: Check if is a [Some]. +parameters: + - name: a + type: option<'a> + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(3004) + output: true + - inputs: None + output: false +examples: + - inputs: Some(3004) + output: true + - inputs: None + output: false +added: 0.1.0 diff --git a/yaml-files/Option.map.yaml b/yaml-files/Option.map.yaml new file mode 100644 index 00000000..5ddab444 --- /dev/null +++ b/yaml-files/Option.map.yaml @@ -0,0 +1,31 @@ +module: Option +name: map +docstring: Transform the value inside an option. Leaves [None] untouched. +parameters: + - name: a + type: option<'a> + label: false + - name: f + type: >- + 'a => 'b + label: true +returnType: option<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(9), x => x * x] + output: Some(81) + - inputs: [Some(9), Int.toString] + output: Some("9") + - inputs: [None, x => x * x] + output: None +examples: + - inputs: [Some(9), x => x * x] + output: Some(81) + - inputs: [Some(9), Int.toString] + output: Some("9") + - inputs: [None, x => x * x] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.map2.yaml b/yaml-files/Option.map2.yaml new file mode 100644 index 00000000..22b979ab --- /dev/null +++ b/yaml-files/Option.map2.yaml @@ -0,0 +1,33 @@ +module: Option +name: map2 +docstring: Combine and . If both options are [Some] returns, as [Some] the result of running [f] on both values. If either value is [None], returns [None] +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'b> + label: false + - name: f + type: ('a, 'b) => 'c + label: true +returnType: option<'c> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(3), Some(4), Int.add] + output: Some(7) + - inputs: [Some(3), None, Int.add] + output: None + - inputs: [None, Some(4), Int.add] + output: None +examples: + - inputs: [Some(3), Some(4), Int.add] + output: Some(7) + - inputs: [Some(3), None, Int.add] + output: None + - inputs: [None, Some(4), Int.add] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.orElse.yaml b/yaml-files/Option.orElse.yaml new file mode 100644 index 00000000..de6a79f9 --- /dev/null +++ b/yaml-files/Option.orElse.yaml @@ -0,0 +1,34 @@ +module: Option +name: orElse +docstring: Return the if it {!isSome}, otherwise return +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(1), Some(15)] + output: Some(15) + - inputs: [None, Some(15)] + output: Some(15) + - inputs: [Some(1), None] + output: Some(1) + - inputs: [None, None] + output: None +examples: + - inputs: [Some(1), Some(15)] + output: Some(15) + - inputs: [None, Some(15)] + output: Some(15) + - inputs: [Some(1), None] + output: Some(1) + - inputs: [None, None] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.or_.yaml b/yaml-files/Option.or_.yaml new file mode 100644 index 00000000..3b95fb62 --- /dev/null +++ b/yaml-files/Option.or_.yaml @@ -0,0 +1,34 @@ +module: Option +name: or_ +docstring: Return if it {!isSome}, otherwise return . +parameters: + - name: a + type: option<'a> + label: false + - name: b + type: option<'a> + label: false +returnType: option<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(1), Some(15)] + output: Some(1) + - inputs: [None, Some(15)] + output: Some(15) + - inputs: [Some(1), None] + output: Some(1) + - inputs: [None, None] + output: None +examples: + - inputs: [Some(1), Some(15)] + output: Some(1) + - inputs: [None, Some(15)] + output: Some(15) + - inputs: [Some(1), None] + output: Some(1) + - inputs: [None, None] + output: None +added: 0.1.0 diff --git a/yaml-files/Option.toArray.yaml b/yaml-files/Option.toArray.yaml new file mode 100644 index 00000000..0551d6db --- /dev/null +++ b/yaml-files/Option.toArray.yaml @@ -0,0 +1,23 @@ +module: Option +name: toArray +docstring: Convert to an {!Array} +parameters: + - name: a + type: option<'a> + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(3004) + output: [[3004]] + - inputs: None + output: [[]] +examples: + - inputs: Some(3004) + output: [[3004]] + - inputs: None + output: [[]] +added: 0.1.0 diff --git a/yaml-files/Option.toList.yaml b/yaml-files/Option.toList.yaml new file mode 100644 index 00000000..81b32ead --- /dev/null +++ b/yaml-files/Option.toList.yaml @@ -0,0 +1,23 @@ +module: Option +name: toList +docstring: Convert to a {!List} +parameters: + - name: a + type: option<'a> + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(3004) + output: [3004] + - inputs: None + output: [] +examples: + - inputs: Some(3004) + output: [3004] + - inputs: None + output: [] +added: 0.1.0 diff --git a/yaml-files/Option.unwrap.yaml b/yaml-files/Option.unwrap.yaml new file mode 100644 index 00000000..cb46469e --- /dev/null +++ b/yaml-files/Option.unwrap.yaml @@ -0,0 +1,26 @@ +module: Option +name: unwrap +docstring: Unwrap returning [default] if called with [None] +parameters: + - name: a + type: option<'a> + label: false + - name: default + type: \'a + label: true +returnType: \'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(42), 99] + output: 42 + - inputs: [None, 99] + output: 99 +examples: + - inputs: [Some(42), 99] + output: 42 + - inputs: [None, 99] + output: 99 +added: 0.1.0 diff --git a/yaml-files/String.fromArray.yaml b/yaml-files/String.fromArray.yaml new file mode 100644 index 00000000..01c2037c --- /dev/null +++ b/yaml-files/String.fromArray.yaml @@ -0,0 +1,31 @@ +module: String +name: fromArray +docstring: Create a string from an {!Array} of characters +parameters: + - name: a + type: array + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: "" + - inputs: >- + ['K', 'u', 'b', 'o'] + output: "Kubo" + - inputs: >- + [' ', '\n', '\t'] + output: " \n\t" +examples: + - inputs: [] + output: "" + - inputs: >- + ['K', 'u', 'b', 'o'] + output: "Kubo" + - inputs: >- + [' ', '\n', '\t'] + output: " \n\t" +added: 0.1.0 diff --git a/yaml-files/String.fromChar.yaml b/yaml-files/String.fromChar.yaml new file mode 100644 index 00000000..0b93413a --- /dev/null +++ b/yaml-files/String.fromChar.yaml @@ -0,0 +1,39 @@ +module: String +name: fromChar +docstring: Converts the to an equivalent string of length one +parameters: + - name: a + type: char + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: >- + 'a' + output: "a" + - inputs: >- + 'z' + output: "z" + - inputs: >- + ' ' + output: " " + - inputs: >- + '\n' + output: "\n" +examples: + - inputs: >- + 'a' + output: "a" + - inputs: >- + 'z' + output: "z" + - inputs: >- + ' ' + output: " " + - inputs: >- + '\n' + output: "\n" +added: 0.1.0 diff --git a/yaml-files/String.fromList.yaml b/yaml-files/String.fromList.yaml new file mode 100644 index 00000000..1487891b --- /dev/null +++ b/yaml-files/String.fromList.yaml @@ -0,0 +1,31 @@ +module: String +name: fromList +docstring: Create a string from a {!List} of characters +parameters: + - name: a + type: list + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [] + output: "" + - inputs: >- + ['K', 'u', 'b', 'o'] + output: "Kubo" + - inputs: >- + [' ', '\n', '\t'] + output: " \n\t" +examples: + - inputs: [] + output: "" + - inputs: >- + ['K', 'u', 'b', 'o'] + output: "Kubo" + - inputs: >- + [' ', '\n', '\t'] + output: " \n\t" +added: 0.1.0 diff --git a/yaml-files/String.indexOf.yaml b/yaml-files/String.indexOf.yaml new file mode 100644 index 00000000..85ccbece --- /dev/null +++ b/yaml-files/String.indexOf.yaml @@ -0,0 +1,34 @@ +module: String +name: indexOf +docstring: Returns the index of the first occurrence of [string] or None if string has no occurences of [string] +parameters: + - name: a + type: string + label: false + - name: b + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["hello", "h"] + output: Some(0) + - inputs: ["hellh", "h"] + output: Some(0) + - inputs: ["hellh", "ell"] + output: Some(1) + - inputs: ["hello", "xy"] + output: None +examples: + - inputs: ["hello", "h"] + output: Some(0) + - inputs: ["hellh", "h"] + output: Some(0) + - inputs: ["hellh", "ell"] + output: Some(1) + - inputs: ["hello", "xy"] + output: None +added: 0.1.0 diff --git a/yaml-files/String.indexOfRight.yaml b/yaml-files/String.indexOfRight.yaml new file mode 100644 index 00000000..719a4d60 --- /dev/null +++ b/yaml-files/String.indexOfRight.yaml @@ -0,0 +1,30 @@ +module: String +name: indexOfRight +docstring: Returns the index of the last occurrence of [string] or None if string has no occurences of [string] +parameters: + - name: a + type: string + label: false + - name: b + type: string + label: false +returnType: option +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["helloh", "oh"] + output: Some(4) + - inputs: ["ohelloh", "oh"] + output: Some(5) + - inputs: ["hello", "x"] + output: None +examples: + - inputs: ["helloh", "oh"] + output: Some(4) + - inputs: ["ohelloh", "oh"] + output: Some(5) + - inputs: ["hello", "x"] + output: None +added: 0.1.0 diff --git a/yaml-files/String.initialize.yaml b/yaml-files/String.initialize.yaml new file mode 100644 index 00000000..aa6a51f0 --- /dev/null +++ b/yaml-files/String.initialize.yaml @@ -0,0 +1,30 @@ +module: String +name: initialize +docstring: Create a string by providing a length and a function to choose characters. Returns an empty string if the length is negative +parameters: + - name: a + type: int + label: false + - name: f + type: int => char + label: true +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [0, Fun.constant('A')] + output: "" + - inputs: [-1, Fun.constant('A')] + output: exception + - inputs: [3, Fun.constant('A')] + output: "AAA" +examples: + - inputs: [0, Fun.constant('A')] + output: "" + - inputs: [-1, Fun.constant('A')] + output: exception + - inputs: [3, Fun.constant('A')] + output: "AAA" +added: 0.1.0 diff --git a/yaml-files/String.insertAt.yaml b/yaml-files/String.insertAt.yaml new file mode 100644 index 00000000..97c9098c --- /dev/null +++ b/yaml-files/String.insertAt.yaml @@ -0,0 +1,45 @@ +module: String +name: insertAt +docstring: Insert a string at [index] +parameters: + - name: a + type: string + label: false + - name: value + type: string + label: true + - name: index + type: int + label: true +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["abcde", "**", 2] + output: "ab**cde" + - inputs: ["abcde", "**", 0] + output: "**abcde" + - inputs: ["abcde", "**", 5] + output: "abcde**" + - inputs: ["abcde", "**", -2] + output: "abc**de" + - inputs: ["abcde", "**", -9] + output: "**abcde" + - inputs: ["abcde", "**", 9] + output: "abcde**" +examples: + - inputs: ["abcde", "**", 2] + output: "ab**cde" + - inputs: ["abcde", "**", 0] + output: "**abcde" + - inputs: ["abcde", "**", 5] + output: "abcde**" + - inputs: ["abcde", "**", -2] + output: "abc**de" + - inputs: ["abcde", "**", -9] + output: "**abcde" + - inputs: ["abcde", "**", 9] + output: "abcde**" +added: 0.1.0 diff --git a/yaml-files/String.isEmpty.yaml b/yaml-files/String.isEmpty.yaml new file mode 100644 index 00000000..f32eb835 --- /dev/null +++ b/yaml-files/String.isEmpty.yaml @@ -0,0 +1,31 @@ +module: String +name: isEmpty +docstring: Check if a string is empty +parameters: + - name: a + type: string + label: false +returnType: bool +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "" + output: true + - inputs: "abc" + output: false + - inputs: " " + output: false + - inputs: "\n" + output: false +examples: + - inputs: "" + output: true + - inputs: "abc" + output: false + - inputs: " " + output: false + - inputs: "\n" + output: false +added: 0.1.0 diff --git a/yaml-files/String.length.yaml b/yaml-files/String.length.yaml new file mode 100644 index 00000000..332cca61 --- /dev/null +++ b/yaml-files/String.length.yaml @@ -0,0 +1,23 @@ +module: String +name: length +docstring: Returns the length of the given string +parameters: + - name: a + type: string + label: false +returnType: int +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "" + output: 0 + - inputs: "123" + output: 3 +examples: + - inputs: "" + output: 0 + - inputs: "123" + output: 3 +added: 0.1.0 diff --git a/yaml-files/String.repeat.yaml b/yaml-files/String.repeat.yaml new file mode 100644 index 00000000..1166a8a4 --- /dev/null +++ b/yaml-files/String.repeat.yaml @@ -0,0 +1,30 @@ +module: String +name: repeat +docstring: Create a string by repeating a string [count] time +parameters: + - name: a + type: string + label: false + - name: count + type: int + label: true +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["bun", 0] + output: "" + - inputs: ["bun", -1] + output: exception + - inputs: ["bun", 3] + output: "bunbunbun" +examples: + - inputs: ["bun", 0] + output: "" + - inputs: ["bun", -1] + output: exception + - inputs: ["bun", 3] + output: "bunbunbun" +added: 0.1.0 diff --git a/yaml-files/String.reverse.yaml b/yaml-files/String.reverse.yaml new file mode 100644 index 00000000..6264e42a --- /dev/null +++ b/yaml-files/String.reverse.yaml @@ -0,0 +1,23 @@ +module: String +name: reverse +docstring: Reverse a string +parameters: + - name: a + type: string + label: false +returnType: string +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "" + output: "" + - inputs: "stressed" + output: "desserts" +examples: + - inputs: "" + output: "" + - inputs: "stressed" + output: "desserts" +added: 0.1.0 diff --git a/yaml-files/String.split.yaml b/yaml-files/String.split.yaml new file mode 100644 index 00000000..beff87ce --- /dev/null +++ b/yaml-files/String.split.yaml @@ -0,0 +1,31 @@ +module: String +name: split +docstring: Divide a string into a list of strings, splitting whenever [on] is encountered +parameters: + - name: a + type: string + label: false + - name: >- + on + type: string + label: true +returnType: list +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: ["abc", "b"] + output: ["a", "c"] + - inputs: ["ab", "a"] + output: ["", "b"] + - inputs: ["ab", "b"] + output: ["a", ""] +examples: + - inputs: ["abc", "b"] + output: ["a", "c"] + - inputs: ["ab", "a"] + output: ["", "b"] + - inputs: ["ab", "b"] + output: ["a", ""] +added: 0.1.0 diff --git a/yaml-files/String.toArray.yaml b/yaml-files/String.toArray.yaml new file mode 100644 index 00000000..3a39823e --- /dev/null +++ b/yaml-files/String.toArray.yaml @@ -0,0 +1,21 @@ +module: String +name: toArray +docstring: Returns an {!Array} of the individual characters in the given string +parameters: + - name: a + type: string + label: false +returnType: array +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "Standard" + output: >- + ['S', 't', 'a', 'n', 'd', 'a', 'r', 'd'] +examples: + - inputs: "Standard" + output: >- + ['S', 't', 'a', 'n', 'd', 'a', 'r', 'd'] +added: 0.1.0 diff --git a/yaml-files/String.toList.yaml b/yaml-files/String.toList.yaml new file mode 100644 index 00000000..bb188296 --- /dev/null +++ b/yaml-files/String.toList.yaml @@ -0,0 +1,21 @@ +module: String +name: toList +docstring: Returns a {!List} of the individual characters in the given string +parameters: + - name: a + type: string + label: false +returnType: list +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: "Standard" + output: >- + ['S', 't', 'a', 'n', 'd', 'a', 'r', 'd'] +examples: + - inputs: "Standard" + output: >- + ['S', 't', 'a', 'n', 'd', 'a', 'r', 'd'] +added: 0.1.0 diff --git a/yaml-files/Tuple2.first.yaml b/yaml-files/Tuple2.first.yaml new file mode 100644 index 00000000..7ca38a1e --- /dev/null +++ b/yaml-files/Tuple2.first.yaml @@ -0,0 +1,20 @@ +module: Tuple2 +name: first +docstring: Extract the first value from a tuple +parameters: + - name: a + type: ('a, 'b) + label: false +returnType: >- + 'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4) + output: 3 +examples: + - inputs: (3, 4) + output: 3 +added: 0.1.0 diff --git a/yaml-files/Tuple2.make.yaml b/yaml-files/Tuple2.make.yaml new file mode 100644 index 00000000..a88f0095 --- /dev/null +++ b/yaml-files/Tuple2.make.yaml @@ -0,0 +1,24 @@ +module: Tuple2 +name: make +docstring: Create a two-tuple with the given values +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'b + label: false +returnType: ('a, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3, 4] + output: (3,4) +examples: + - inputs: [3, 4] + output: (3,4) +added: 0.1.0 diff --git a/yaml-files/Tuple2.mapAll.yaml b/yaml-files/Tuple2.mapAll.yaml new file mode 100644 index 00000000..5e6eaca0 --- /dev/null +++ b/yaml-files/Tuple2.mapAll.yaml @@ -0,0 +1,23 @@ +module: Tuple2 +name: mapAll +docstring: Transform both of the values of a tuple using the same function +parameters: + - name: a + type: ('a, 'a) + label: false + - name: f + type: >- + 'a => 'b + label: true +returnType: ('b, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("was", \"stressed"), String.reverse] + output: ("saw", "desserts") +examples: + - inputs: [("was", \"stressed"), String.reverse] + output: ("saw", "desserts") +added: 0.1.0 diff --git a/yaml-files/Tuple2.mapEach.yaml b/yaml-files/Tuple2.mapEach.yaml new file mode 100644 index 00000000..afc381b2 --- /dev/null +++ b/yaml-files/Tuple2.mapEach.yaml @@ -0,0 +1,27 @@ +module: Tuple2 +name: mapEach +docstring: Transform both values of a tuple, using [f] for the first value and [g] for the second +parameters: + - name: a + type: ('a, 'b) + label: false + - name: f + type: >- + 'a => 'x + label: true + - name: g + type: >- + 'b => 'y + label: true +returnType: ('x, 'y) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16.0), String.reverse, Float.squareRoot] + output: ("desserts", 4.0) +examples: + - inputs: [("stressed", 16.0), String.reverse, Float.squareRoot] + output: ("desserts", 4.0) +added: 0.1.0 diff --git a/yaml-files/Tuple2.mapFirst.yaml b/yaml-files/Tuple2.mapFirst.yaml new file mode 100644 index 00000000..c2dc13e2 --- /dev/null +++ b/yaml-files/Tuple2.mapFirst.yaml @@ -0,0 +1,23 @@ +module: Tuple2 +name: mapFirst +docstring: Transform the {!first} value in a tuple +parameters: + - name: a + type: ('a, 'b) + label: false + - name: f + type: >- + 'a => 'x + label: true +returnType: ('x, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16), String.reverse] + output: ("desserts", 16) +examples: + - inputs: [("stressed", 16), String.reverse] + output: ("desserts", 16) +added: 0.1.0 diff --git a/yaml-files/Tuple2.mapSecond.yaml b/yaml-files/Tuple2.mapSecond.yaml new file mode 100644 index 00000000..ba4a75ca --- /dev/null +++ b/yaml-files/Tuple2.mapSecond.yaml @@ -0,0 +1,23 @@ +module: Tuple2 +name: mapSecond +docstring: Transform the {!second} value in a tuple +parameters: + - name: a + type: ('a, 'b) + label: false + - name: f + type: >- + 'b => 'c + label: true +returnType: ('a, 'c) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16.0), Float.squareRoot] + output: ("stressed", 4.0) +examples: + - inputs: [("stressed", 16.0), Float.squareRoot] + output: ("stressed", 4.0) +added: 0.1.0 diff --git a/yaml-files/Tuple2.second.yaml b/yaml-files/Tuple2.second.yaml new file mode 100644 index 00000000..c73a5c1e --- /dev/null +++ b/yaml-files/Tuple2.second.yaml @@ -0,0 +1,20 @@ +module: Tuple2 +name: second +docstring: Extract the second value from a tuple +parameters: + - name: a + type: ('a, 'b) + label: false +returnType: >- + 'b +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4) + output: 4 +examples: + - inputs: (3, 4) + output: 4 +added: 0.1.0 diff --git a/yaml-files/Tuple2.swap.yaml b/yaml-files/Tuple2.swap.yaml new file mode 100644 index 00000000..47194efa --- /dev/null +++ b/yaml-files/Tuple2.swap.yaml @@ -0,0 +1,19 @@ +module: Tuple2 +name: swap +docstring: Switches the first and second values of a tuple +parameters: + - name: a + type: ('a, 'b) + label: false +returnType: ('b, 'a) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4) + output: (4, 3) +examples: + - inputs: (3, 4) + output: (4, 3) +added: 0.1.0 diff --git a/yaml-files/Tuple2.toArray.yaml b/yaml-files/Tuple2.toArray.yaml new file mode 100644 index 00000000..58278962 --- /dev/null +++ b/yaml-files/Tuple2.toArray.yaml @@ -0,0 +1,19 @@ +module: Tuple2 +name: toArray +docstring: Turns a tuple into an {!Array} of length two +parameters: + - name: a + type: ('a, 'a) + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4) + output: [3, 4] +examples: + - inputs: (3, 4) + output: [3, 4] +added: 0.1.0 diff --git a/yaml-files/Tuple2.toList.yaml b/yaml-files/Tuple2.toList.yaml new file mode 100644 index 00000000..fa9ad4c0 --- /dev/null +++ b/yaml-files/Tuple2.toList.yaml @@ -0,0 +1,19 @@ +module: Tuple2 +name: toList +docstring: Turns a tuple into a list of length two +parameters: + - name: a + type: ('a, 'a) + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4) + output: [3, 4] +examples: + - inputs: (3, 4) + output: [3, 4] +added: 0.1.0 diff --git a/yaml-files/Tuple3.first.yaml b/yaml-files/Tuple3.first.yaml new file mode 100644 index 00000000..6e9e5712 --- /dev/null +++ b/yaml-files/Tuple3.first.yaml @@ -0,0 +1,20 @@ +module: Tuple3 +name: first +docstring: Extract the first value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: >- + 'a +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: 3 +examples: + - inputs: (3, 4, 5) + output: 3 +added: 0.1.0 diff --git a/yaml-files/Tuple3.initial.yaml b/yaml-files/Tuple3.initial.yaml new file mode 100644 index 00000000..7a723a25 --- /dev/null +++ b/yaml-files/Tuple3.initial.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: initial +docstring: Extract the first and second values of a {!Tuple3} as a {!Tuple2} +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: ('a, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: (3, 4) +examples: + - inputs: (3, 4, 5) + output: (3, 4) +added: 0.1.0 diff --git a/yaml-files/Tuple3.make.yaml b/yaml-files/Tuple3.make.yaml new file mode 100644 index 00000000..c59915ed --- /dev/null +++ b/yaml-files/Tuple3.make.yaml @@ -0,0 +1,28 @@ +module: Tuple3 +name: make +docstring: Create a {!Tuple3} +parameters: + - name: a + type: >- + 'a + label: false + - name: b + type: >- + 'b + label: false + - name: c + type: >- + 'c + label: false +returnType: ('a, 'b, 'c) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [3, 4, 5] + output: (3,4,5) +examples: + - inputs: [3, 4, 5] + output: (3,4,5) +added: 0.1.0 diff --git a/yaml-files/Tuple3.mapAll.yaml b/yaml-files/Tuple3.mapAll.yaml new file mode 100644 index 00000000..8d0aeea3 --- /dev/null +++ b/yaml-files/Tuple3.mapAll.yaml @@ -0,0 +1,23 @@ +module: Tuple3 +name: mapAll +docstring: Transform both of the values of a tuple using the same function +parameters: + - name: a + type: ('a, 'a, 'a) + label: false + - name: f + type: >- + 'a => 'b + label: true +returnType: ('b, 'b, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("was", \"stressed", \"now"), String.reverse] + output: ("saw", "desserts", "won") +examples: + - inputs: [("was", \"stressed", \"now"), String.reverse] + output: ("saw", "desserts", "won") +added: 0.1.0 diff --git a/yaml-files/Tuple3.mapEach.yaml b/yaml-files/Tuple3.mapEach.yaml new file mode 100644 index 00000000..b6ba1047 --- /dev/null +++ b/yaml-files/Tuple3.mapEach.yaml @@ -0,0 +1,31 @@ +module: Tuple3 +name: mapEach +docstring: Transform each value in a tuple by applying [f] to the {!first} value, [g] to the {!second} value and [h] to the {!third} value +parameters: + - name: a + type: ('a, 'b, 'c) + label: false + - name: f + type: >- + 'a => 'x + label: true + - name: g + type: >- + 'b => 'y + label: true + - name: h + type: >- + 'c => 'z + label: true +returnType: ('x, 'y, 'z) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16.0, false), String.reverse, Float.squareRoot, not] + output: ("desserts", 4.0, true) +examples: + - inputs: [("stressed", 16.0, false), String.reverse, Float.squareRoot, not] + output: ("desserts", 4.0, true) +added: 0.1.0 diff --git a/yaml-files/Tuple3.mapFirst.yaml b/yaml-files/Tuple3.mapFirst.yaml new file mode 100644 index 00000000..05ae08eb --- /dev/null +++ b/yaml-files/Tuple3.mapFirst.yaml @@ -0,0 +1,23 @@ +module: Tuple3 +name: mapFirst +docstring: Transform the {!first} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false + - name: f + type: >- + 'a => 'x + label: true +returnType: ('x, 'b, 'c) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16, false), String.reverse] + output: ("desserts", 16, false) +examples: + - inputs: [("stressed", 16, false), String.reverse] + output: ("desserts", 16, false) +added: 0.1.0 diff --git a/yaml-files/Tuple3.mapSecond.yaml b/yaml-files/Tuple3.mapSecond.yaml new file mode 100644 index 00000000..61177dcb --- /dev/null +++ b/yaml-files/Tuple3.mapSecond.yaml @@ -0,0 +1,23 @@ +module: Tuple3 +name: mapSecond +docstring: Transform the {!second} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false + - name: f + type: >- + 'b => 'y + label: true +returnType: ('a, 'y, 'c) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16.0, false), Float.squareRoot] + output: ("stressed", 4.0, false) +examples: + - inputs: [("stressed", 16.0, false), Float.squareRoot] + output: ("stressed", 4.0, false) +added: 0.1.0 diff --git a/yaml-files/Tuple3.mapThird.yaml b/yaml-files/Tuple3.mapThird.yaml new file mode 100644 index 00000000..5a2634e4 --- /dev/null +++ b/yaml-files/Tuple3.mapThird.yaml @@ -0,0 +1,23 @@ +module: Tuple3 +name: mapThird +docstring: Transform the {!third} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false + - name: f + type: >- + 'c => 'z + label: true +returnType: ('a, 'b, 'z) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [("stressed", 16, false), not] + output: ("stressed", 16, true) +examples: + - inputs: [("stressed", 16, false), not] + output: ("stressed", 16, true) +added: 0.1.0 diff --git a/yaml-files/Tuple3.rotateLeft.yaml b/yaml-files/Tuple3.rotateLeft.yaml new file mode 100644 index 00000000..629846b2 --- /dev/null +++ b/yaml-files/Tuple3.rotateLeft.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: rotateLeft +docstring: Move each value in the tuple one position to the left, moving the value in the first position into the last position +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: ('b, 'c, 'a) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: (4, 5, 3) +examples: + - inputs: (3, 4, 5) + output: (4, 5, 3) +added: 0.1.0 diff --git a/yaml-files/Tuple3.rotateRight.yaml b/yaml-files/Tuple3.rotateRight.yaml new file mode 100644 index 00000000..45007706 --- /dev/null +++ b/yaml-files/Tuple3.rotateRight.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: rotateRight +docstring: Move each value in the tuple one position to the right, moving the value in the last position into the first position +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: ('c, 'a, 'b) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: (5, 3, 4) +examples: + - inputs: (3, 4, 5) + output: (5, 3, 4) +added: 0.1.0 diff --git a/yaml-files/Tuple3.second.yaml b/yaml-files/Tuple3.second.yaml new file mode 100644 index 00000000..8cd26aae --- /dev/null +++ b/yaml-files/Tuple3.second.yaml @@ -0,0 +1,20 @@ +module: Tuple3 +name: second +docstring: Extract the second value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: >- + 'b +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: 4 +examples: + - inputs: (3, 4, 5) + output: 4 +added: 0.1.0 diff --git a/yaml-files/Tuple3.tail.yaml b/yaml-files/Tuple3.tail.yaml new file mode 100644 index 00000000..7157676d --- /dev/null +++ b/yaml-files/Tuple3.tail.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: tail +docstring: Extract the second and third values of a {!Tuple3} as a {!Tuple2} +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: ('b, 'c) +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: (4, 5) +examples: + - inputs: (3, 4, 5) + output: (4, 5) +added: 0.1.0 diff --git a/yaml-files/Tuple3.third.yaml b/yaml-files/Tuple3.third.yaml new file mode 100644 index 00000000..7ff92b3c --- /dev/null +++ b/yaml-files/Tuple3.third.yaml @@ -0,0 +1,20 @@ +module: Tuple3 +name: third +docstring: Extract the third value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + label: false +returnType: >- + 'c +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: 5 +examples: + - inputs: (3, 4, 5) + output: 5 +added: 0.1.0 diff --git a/yaml-files/Tuple3.toArray.yaml b/yaml-files/Tuple3.toArray.yaml new file mode 100644 index 00000000..ae585ff3 --- /dev/null +++ b/yaml-files/Tuple3.toArray.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: toArray +docstring: Turns a tuple into an {!Array} of length three +parameters: + - name: a + type: ('a, 'a, 'a) + label: false +returnType: array<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: [3, 4, 5] +examples: + - inputs: (3, 4, 5) + output: [3, 4, 5] +added: 0.1.0 diff --git a/yaml-files/Tuple3.toList.yaml b/yaml-files/Tuple3.toList.yaml new file mode 100644 index 00000000..31a2999c --- /dev/null +++ b/yaml-files/Tuple3.toList.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: toList +docstring: Turns a tuple into a list of length three +parameters: + - name: a + type: ('a, 'a, 'a) + label: false +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: (3, 4, 5) + output: [3, 4, 5] +examples: + - inputs: (3, 4, 5) + output: [3, 4, 5] +added: 0.1.0