From 12ec1e07a3754214fa554a99786fb5125c19427d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Oct 2022 15:46:34 +0200 Subject: [PATCH 01/31] Create yaml file with test cases for Int module + generate some tests --- bsconfig.json | 18 +++ json-files/Int.absolute.json | 45 +++++++ json-files/Int.add.json | 53 ++++++++ json-files/Int.clamp.json | 125 ++++++++++++++++++ json-files/Int.divide.json | 67 ++++++++++ json-files/Int.divideFloat.json | 95 +++++++++++++ json-files/Int.maximum.json | 67 ++++++++++ json-files/Int.power.json | 67 ++++++++++ json-files/Int.subtract.json | 39 ++++++ package-lock.json | 50 +++++++ package.json | 20 +++ src/generateTest.res | 56 ++++++++ test/fsharpTests/IntTest/absoluteTest.fs | 9 ++ test/fsharpTests/IntTest/addTest.fs | 6 + test/fsharpTests/IntTest/clampTest.fs | 18 +++ test/fsharpTests/IntTest/divideFloatTest.fs | 15 +++ test/fsharpTests/IntTest/divideTest.fs | 9 ++ test/fsharpTests/IntTest/maximumTest.fs | 9 ++ test/fsharpTests/IntTest/powerTest.fs | 9 ++ test/fsharpTests/IntTest/subtractTest.fs | 3 + test/ocamlTests/IntTest/absoluteTest.ml | 3 + test/ocamlTests/IntTest/addTest.ml | 2 + test/ocamlTests/IntTest/clampTest.ml | 6 + test/ocamlTests/IntTest/divideFloatTest.ml | 5 + test/ocamlTests/IntTest/divideTest.ml | 3 + test/ocamlTests/IntTest/maximumTest.ml | 3 + test/ocamlTests/IntTest/powerTest.ml | 3 + test/ocamlTests/IntTest/subtractTest.ml | 1 + test/rescriptTests/IntTest/absoluteTest.res | 3 + test/rescriptTests/IntTest/addTest.res | 2 + test/rescriptTests/IntTest/clampTest.res | 6 + .../rescriptTests/IntTest/divideFloatTest.res | 5 + test/rescriptTests/IntTest/divideTest.res | 3 + test/rescriptTests/IntTest/maximumTest.res | 3 + test/rescriptTests/IntTest/powerTest.res | 3 + test/rescriptTests/IntTest/subtractTest.res | 1 + yaml-files/Int.absolute.yaml | 26 ++++ yaml-files/Int.add.yaml | 24 ++++ yaml-files/Int.clamp.yaml | 42 ++++++ yaml-files/Int.divide.yaml | 28 ++++ yaml-files/Int.divideFloat.yaml | 36 +++++ yaml-files/Int.fromString.yaml | 66 +++++++++ yaml-files/Int.inRange.yaml | 42 ++++++ yaml-files/Int.isEven.yaml | 26 ++++ yaml-files/Int.isOdd.yaml | 26 ++++ yaml-files/Int.maximum.yaml | 28 ++++ yaml-files/Int.minimum..yaml | 28 ++++ yaml-files/Int.modulo.yaml | 52 ++++++++ yaml-files/Int.multiply.yaml | 24 ++++ yaml-files/Int.negate.yaml | 26 ++++ yaml-files/Int.power.yaml | 28 ++++ yaml-files/Int.remainder.yaml | 48 +++++++ yaml-files/Int.subtract.yaml | 20 +++ yaml-files/Int.toFloat.yaml | 26 ++++ yaml-files/Int.toString.yaml | 22 +++ 55 files changed, 1450 insertions(+) create mode 100644 bsconfig.json create mode 100644 json-files/Int.absolute.json create mode 100644 json-files/Int.add.json create mode 100644 json-files/Int.clamp.json create mode 100644 json-files/Int.divide.json create mode 100644 json-files/Int.divideFloat.json create mode 100644 json-files/Int.maximum.json create mode 100644 json-files/Int.power.json create mode 100644 json-files/Int.subtract.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/generateTest.res create mode 100644 test/fsharpTests/IntTest/absoluteTest.fs create mode 100644 test/fsharpTests/IntTest/addTest.fs create mode 100644 test/fsharpTests/IntTest/clampTest.fs create mode 100644 test/fsharpTests/IntTest/divideFloatTest.fs create mode 100644 test/fsharpTests/IntTest/divideTest.fs create mode 100644 test/fsharpTests/IntTest/maximumTest.fs create mode 100644 test/fsharpTests/IntTest/powerTest.fs create mode 100644 test/fsharpTests/IntTest/subtractTest.fs create mode 100644 test/ocamlTests/IntTest/absoluteTest.ml create mode 100644 test/ocamlTests/IntTest/addTest.ml create mode 100644 test/ocamlTests/IntTest/clampTest.ml create mode 100644 test/ocamlTests/IntTest/divideFloatTest.ml create mode 100644 test/ocamlTests/IntTest/divideTest.ml create mode 100644 test/ocamlTests/IntTest/maximumTest.ml create mode 100644 test/ocamlTests/IntTest/powerTest.ml create mode 100644 test/ocamlTests/IntTest/subtractTest.ml create mode 100644 test/rescriptTests/IntTest/absoluteTest.res create mode 100644 test/rescriptTests/IntTest/addTest.res create mode 100644 test/rescriptTests/IntTest/clampTest.res create mode 100644 test/rescriptTests/IntTest/divideFloatTest.res create mode 100644 test/rescriptTests/IntTest/divideTest.res create mode 100644 test/rescriptTests/IntTest/maximumTest.res create mode 100644 test/rescriptTests/IntTest/powerTest.res create mode 100644 test/rescriptTests/IntTest/subtractTest.res create mode 100644 yaml-files/Int.absolute.yaml create mode 100644 yaml-files/Int.add.yaml create mode 100644 yaml-files/Int.clamp.yaml create mode 100644 yaml-files/Int.divide.yaml create mode 100644 yaml-files/Int.divideFloat.yaml create mode 100644 yaml-files/Int.fromString.yaml create mode 100644 yaml-files/Int.inRange.yaml create mode 100644 yaml-files/Int.isEven.yaml create mode 100644 yaml-files/Int.isOdd.yaml create mode 100644 yaml-files/Int.maximum.yaml create mode 100644 yaml-files/Int.minimum..yaml create mode 100644 yaml-files/Int.modulo.yaml create mode 100644 yaml-files/Int.multiply.yaml create mode 100644 yaml-files/Int.negate.yaml create mode 100644 yaml-files/Int.power.yaml create mode 100644 yaml-files/Int.remainder.yaml create mode 100644 yaml-files/Int.subtract.yaml create mode 100644 yaml-files/Int.toFloat.yaml create mode 100644 yaml-files/Int.toString.yaml 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/json-files/Int.absolute.json b/json-files/Int.absolute.json new file mode 100644 index 00000000..3c9b7964 --- /dev/null +++ b/json-files/Int.absolute.json @@ -0,0 +1,45 @@ +{ + "module": "Int", + "name": "absolute", + "docstring": "Get the absolute value of ", + "parameters": [ + { + "name": "a", + "type": "int" + } + ], + "returnType": "int", + "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" +} \ No newline at end of file diff --git a/json-files/Int.add.json b/json-files/Int.add.json new file mode 100644 index 00000000..e02a853f --- /dev/null +++ b/json-files/Int.add.json @@ -0,0 +1,53 @@ +{ + "module": "Int", + "name": "add", + "docstring": "Add to , returning their sum", + "parameters": [ + { + "name": "a", + "type": "int" + }, + { + "name": "b", + "type": "int" + } + ], + "returnType": "int", + "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" +} \ No newline at end of file diff --git a/json-files/Int.clamp.json b/json-files/Int.clamp.json new file mode 100644 index 00000000..39c08edc --- /dev/null +++ b/json-files/Int.clamp.json @@ -0,0 +1,125 @@ +{ + "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" + }, + { + "name": "lower", + "type": "int" + }, + { + "name": "upper", + "type": "int" + } + ], + "returnType": "int", + "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, + -10, + -5 + ], + "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, + -10, + -5 + ], + "output": "exception" + } + ], + "added": "0.1.0" +} \ No newline at end of file diff --git a/json-files/Int.divide.json b/json-files/Int.divide.json new file mode 100644 index 00000000..9b9e0b07 --- /dev/null +++ b/json-files/Int.divide.json @@ -0,0 +1,67 @@ +{ + "module": "Int", + "name": "divide", + "docstring": "divide by , returning their quotient", + "parameters": [ + { + "name": "a", + "type": "int" + }, + { + "name": "by", + "type": "int" + } + ], + "returnType": "int", + "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" +} \ No newline at end of file diff --git a/json-files/Int.divideFloat.json b/json-files/Int.divideFloat.json new file mode 100644 index 00000000..804828d2 --- /dev/null +++ b/json-files/Int.divideFloat.json @@ -0,0 +1,95 @@ +{ + "module": "Int", + "name": "divideFloat", + "docstring": "divide by , returning their quotient", + "parameters": [ + { + "name": "a", + "type": "int" + }, + { + "name": "by", + "type": "int" + } + ], + "returnType": "float", + "constraints": [ + "no-ocaml", + "no-rescript" + ], + "tests": [ + { + "inputs": [ + 3, + 2 + ], + "output": 1.5 + }, + { + "inputs": [ + 27, + 5 + ], + "output": 5.4 + }, + { + "inputs": [ + 8, + 4 + ], + "output": 2 + }, + { + "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 + }, + { + "inputs": [ + 8, + 0 + ], + "output": "Float.infinity" + }, + { + "inputs": [ + -8, + 0 + ], + "output": "Float.negativeInfinity" + } + ], + "added": "0.1.0" +} \ No newline at end of file diff --git a/json-files/Int.maximum.json b/json-files/Int.maximum.json new file mode 100644 index 00000000..e15bc7cf --- /dev/null +++ b/json-files/Int.maximum.json @@ -0,0 +1,67 @@ +{ + "module": "Int", + "name": "maximum", + "docstring": "Compare and , returning the highest value", + "parameters": [ + { + "name": "a", + "type": "int" + }, + { + "name": "b", + "type": "int" + } + ], + "returnType": "int", + "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" +} \ No newline at end of file diff --git a/json-files/Int.power.json b/json-files/Int.power.json new file mode 100644 index 00000000..c3931f5a --- /dev/null +++ b/json-files/Int.power.json @@ -0,0 +1,67 @@ +{ + "module": "Int", + "name": "power", + "docstring": "Raise to the power of , returning the power", + "parameters": [ + { + "name": "base", + "type": "int" + }, + { + "name": "exponent", + "type": "int" + } + ], + "returnType": "int", + "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" +} \ No newline at end of file diff --git a/json-files/Int.subtract.json b/json-files/Int.subtract.json new file mode 100644 index 00000000..6e852d3b --- /dev/null +++ b/json-files/Int.subtract.json @@ -0,0 +1,39 @@ +{ + "module": "Int", + "name": "subtract", + "docstring": "Subtract from , returning their difference", + "parameters": [ + { + "name": "a", + "type": "int" + }, + { + "name": "b", + "type": "int" + } + ], + "returnType": "int", + "constraints": [ + "no-ocaml", + "no-rescript" + ], + "tests": [ + { + "inputs": [ + 4, + 3 + ], + "output": 1 + } + ], + "examples": [ + { + "inputs": [ + 4, + 3 + ], + "output": 1 + } + ], + "added": "0.1.0" +} \ No newline at end of file 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..00f46626 --- /dev/null +++ b/src/generateTest.res @@ -0,0 +1,56 @@ + +@module("fs") +external readFileSync: ( + ~name: string, + [#utf8], +) => string = "readFileSync" + +type tests = { + inputs: array, + output: int, +} + +type parameter ={ + name: string, + types: string, +} + +type data = { + name: string, + parameters:array, + tests: array, +} + +@scope("JSON") @val +external parseIntoMyData: string => data = "parse" + +let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) +let myData = parseIntoMyData(file) +let name = myData.name +let resultsR = [] +let resultsF = [] +let resultsO = [] + +for i in 0 to Belt.Array.length(myData.tests)-1{ + let test = myData.tests[i]; + let inputs = test.inputs + let output = test.output + let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)}) |> toEqual(${Belt.Int.toString(output)})) \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.Int ${Belt.Int.toString(output)}) ; \n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp = + `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)})\n` + resultsF->Belt.Array.push(resultFSharp) + +} + let finalresultR = Js.Array.joinWith("",resultsR) + let finalresultF = Js.Array.joinWith("",resultsF) + let finalresultO = Js.Array.joinWith("",resultsO) + Node.Fs.writeFileSync(`../test/rescriptTests/IntTest/${name}Test.res`, finalresultR, #utf8) + Node.Fs.writeFileSync(`../test/ocamlTests/IntTest/${name}Test.ml`, finalresultO, #utf8) + Node.Fs.writeFileSync(`../test/fsharpTests/IntTest/${name}Test.fs`, finalresultF, #utf8) + + + + diff --git a/test/fsharpTests/IntTest/absoluteTest.fs b/test/fsharpTests/IntTest/absoluteTest.fs new file mode 100644 index 00000000..06e8aa2a --- /dev/null +++ b/test/fsharpTests/IntTest/absoluteTest.fs @@ -0,0 +1,9 @@ +testCase "absolute(8)" <| fun _ -> + let expected = 8 + Expect.equal expected (absolute 8) +testCase "absolute(-7)" <| fun _ -> + let expected = 7 + Expect.equal expected (absolute -7) +testCase "absolute(0)" <| fun _ -> + let expected = 0 + Expect.equal expected (absolute 0) diff --git a/test/fsharpTests/IntTest/addTest.fs b/test/fsharpTests/IntTest/addTest.fs new file mode 100644 index 00000000..6084cf5c --- /dev/null +++ b/test/fsharpTests/IntTest/addTest.fs @@ -0,0 +1,6 @@ +testCase "add(1,2)" <| fun _ -> + let expected = 3 + Expect.equal expected (add 1 2) +testCase "add(1,1)" <| fun _ -> + let expected = 2 + Expect.equal expected (add 1 1) diff --git a/test/fsharpTests/IntTest/clampTest.fs b/test/fsharpTests/IntTest/clampTest.fs new file mode 100644 index 00000000..79f7c835 --- /dev/null +++ b/test/fsharpTests/IntTest/clampTest.fs @@ -0,0 +1,18 @@ +testCase "clamp(5,0,8)" <| fun _ -> + let expected = 5 + Expect.equal expected (clamp 5 0 8) +testCase "clamp(9,0,8)" <| fun _ -> + let expected = 8 + Expect.equal expected (clamp 9 0 8) +testCase "clamp(1,2,8)" <| fun _ -> + let expected = 2 + Expect.equal expected (clamp 1 2 8) +testCase "clamp(5,-10,-5)" <| fun _ -> + let expected = -5 + Expect.equal expected (clamp 5 -10 -5) +testCase "clamp(-15,-10,-5)" <| fun _ -> + let expected = -10 + Expect.equal expected (clamp -15 -10 -5) +testCase "clamp(3,-10,-5)" <| fun _ -> + let expected = exception + Expect.equal expected (clamp 3 -10 -5) diff --git a/test/fsharpTests/IntTest/divideFloatTest.fs b/test/fsharpTests/IntTest/divideFloatTest.fs new file mode 100644 index 00000000..35c5939c --- /dev/null +++ b/test/fsharpTests/IntTest/divideFloatTest.fs @@ -0,0 +1,15 @@ +testCase "divideFloat(3,2)" <| fun _ -> + let expected = 1.5 + Expect.equal expected (divideFloat 3 2) +testCase "divideFloat(27,5)" <| fun _ -> + let expected = 5.4 + Expect.equal expected (divideFloat 27 5) +testCase "divideFloat(8,4)" <| fun _ -> + let expected = 2 + Expect.equal expected (divideFloat 8 4) +testCase "divideFloat(8,0)" <| fun _ -> + let expected = Float.infinity + Expect.equal expected (divideFloat 8 0) +testCase "divideFloat(-8,0)" <| fun _ -> + let expected = Float.negativeInfinity + Expect.equal expected (divideFloat -8 0) diff --git a/test/fsharpTests/IntTest/divideTest.fs b/test/fsharpTests/IntTest/divideTest.fs new file mode 100644 index 00000000..0d2c19bb --- /dev/null +++ b/test/fsharpTests/IntTest/divideTest.fs @@ -0,0 +1,9 @@ +testCase "divide(3,2)" <| fun _ -> + let expected = 1 + Expect.equal expected (divide 3 2) +testCase "divide(3,0)" <| fun _ -> + let expected = exception + Expect.equal expected (divide 3 0) +testCase "divide(27,5)" <| fun _ -> + let expected = 5 + Expect.equal expected (divide 27 5) diff --git a/test/fsharpTests/IntTest/maximumTest.fs b/test/fsharpTests/IntTest/maximumTest.fs new file mode 100644 index 00000000..ffdcc6fd --- /dev/null +++ b/test/fsharpTests/IntTest/maximumTest.fs @@ -0,0 +1,9 @@ +testCase "maximum(8,18)" <| fun _ -> + let expected = 18 + Expect.equal expected (maximum 8 18) +testCase "maximum(5,0)" <| fun _ -> + let expected = 5 + Expect.equal expected (maximum 5 0) +testCase "maximum(-4,-1)" <| fun _ -> + let expected = -1 + Expect.equal expected (maximum -4 -1) diff --git a/test/fsharpTests/IntTest/powerTest.fs b/test/fsharpTests/IntTest/powerTest.fs new file mode 100644 index 00000000..b6a77a5f --- /dev/null +++ b/test/fsharpTests/IntTest/powerTest.fs @@ -0,0 +1,9 @@ +testCase "power(7,3)" <| fun _ -> + let expected = 343 + Expect.equal expected (power 7 3) +testCase "power(0,3)" <| fun _ -> + let expected = 0 + Expect.equal expected (power 0 3) +testCase "power(7,0)" <| fun _ -> + let expected = 1 + Expect.equal expected (power 7 0) diff --git a/test/fsharpTests/IntTest/subtractTest.fs b/test/fsharpTests/IntTest/subtractTest.fs new file mode 100644 index 00000000..76b7c4a0 --- /dev/null +++ b/test/fsharpTests/IntTest/subtractTest.fs @@ -0,0 +1,3 @@ +testCase "subtract(4,3)" <| fun _ -> + let expected = 1 + Expect.equal expected (subtract 4 3) diff --git a/test/ocamlTests/IntTest/absoluteTest.ml b/test/ocamlTests/IntTest/absoluteTest.ml new file mode 100644 index 00000000..5eaff87a --- /dev/null +++ b/test/ocamlTests/IntTest/absoluteTest.ml @@ -0,0 +1,3 @@ +test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.Int 8) ; +test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.Int 7) ; +test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.Int 0) ; diff --git a/test/ocamlTests/IntTest/addTest.ml b/test/ocamlTests/IntTest/addTest.ml new file mode 100644 index 00000000..3597e55f --- /dev/null +++ b/test/ocamlTests/IntTest/addTest.ml @@ -0,0 +1,2 @@ +test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.Int 3) ; +test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.Int 2) ; diff --git a/test/ocamlTests/IntTest/clampTest.ml b/test/ocamlTests/IntTest/clampTest.ml new file mode 100644 index 00000000..a6cc1f8e --- /dev/null +++ b/test/ocamlTests/IntTest/clampTest.ml @@ -0,0 +1,6 @@ +test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.Int 5) ; +test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.Int 8) ; +test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.Int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.Int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.Int -10) ; +test "clamp(3,-10,-5)" (fun () -> expect (clamp 3 -10 -5) |> toEqual Eq.Int exception) ; diff --git a/test/ocamlTests/IntTest/divideFloatTest.ml b/test/ocamlTests/IntTest/divideFloatTest.ml new file mode 100644 index 00000000..33808ad8 --- /dev/null +++ b/test/ocamlTests/IntTest/divideFloatTest.ml @@ -0,0 +1,5 @@ +test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.Int 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.Int 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.Int 2) ; +test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.Int Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.Int Float.negativeInfinity) ; diff --git a/test/ocamlTests/IntTest/divideTest.ml b/test/ocamlTests/IntTest/divideTest.ml new file mode 100644 index 00000000..0c664398 --- /dev/null +++ b/test/ocamlTests/IntTest/divideTest.ml @@ -0,0 +1,3 @@ +test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.Int 1) ; +test "divide(3,0)" (fun () -> expect (divide 3 0) |> toEqual Eq.Int exception) ; +test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.Int 5) ; diff --git a/test/ocamlTests/IntTest/maximumTest.ml b/test/ocamlTests/IntTest/maximumTest.ml new file mode 100644 index 00000000..f4afaf60 --- /dev/null +++ b/test/ocamlTests/IntTest/maximumTest.ml @@ -0,0 +1,3 @@ +test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.Int 18) ; +test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.Int 5) ; +test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.Int -1) ; diff --git a/test/ocamlTests/IntTest/powerTest.ml b/test/ocamlTests/IntTest/powerTest.ml new file mode 100644 index 00000000..c9e6576e --- /dev/null +++ b/test/ocamlTests/IntTest/powerTest.ml @@ -0,0 +1,3 @@ +test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.Int 343) ; +test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.Int 0) ; +test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.Int 1) ; diff --git a/test/ocamlTests/IntTest/subtractTest.ml b/test/ocamlTests/IntTest/subtractTest.ml new file mode 100644 index 00000000..90476d0b --- /dev/null +++ b/test/ocamlTests/IntTest/subtractTest.ml @@ -0,0 +1 @@ +test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.Int 1) ; diff --git a/test/rescriptTests/IntTest/absoluteTest.res b/test/rescriptTests/IntTest/absoluteTest.res new file mode 100644 index 00000000..25551cd3 --- /dev/null +++ b/test/rescriptTests/IntTest/absoluteTest.res @@ -0,0 +1,3 @@ +test ("absolute(8)", () => expect(8) |> toEqual(8)) +test ("absolute(-7)", () => expect(-7) |> toEqual(7)) +test ("absolute(0)", () => expect(0) |> toEqual(0)) diff --git a/test/rescriptTests/IntTest/addTest.res b/test/rescriptTests/IntTest/addTest.res new file mode 100644 index 00000000..757f30ba --- /dev/null +++ b/test/rescriptTests/IntTest/addTest.res @@ -0,0 +1,2 @@ +test ("add(1,2)", () => expect(1,2) |> toEqual(3)) +test ("add(1,1)", () => expect(1,1) |> toEqual(2)) diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res new file mode 100644 index 00000000..52eca30a --- /dev/null +++ b/test/rescriptTests/IntTest/clampTest.res @@ -0,0 +1,6 @@ +test ("clamp(5,0,8)", () => expect(5,0,8) |> toEqual(5)) +test ("clamp(9,0,8)", () => expect(9,0,8) |> toEqual(8)) +test ("clamp(1,2,8)", () => expect(1,2,8) |> toEqual(2)) +test ("clamp(5,-10,-5)", () => expect(5,-10,-5) |> toEqual(-5)) +test ("clamp(-15,-10,-5)", () => expect(-15,-10,-5) |> toEqual(-10)) +test ("clamp(3,-10,-5)", () => expect(3,-10,-5) |> toEqual(exception)) diff --git a/test/rescriptTests/IntTest/divideFloatTest.res b/test/rescriptTests/IntTest/divideFloatTest.res new file mode 100644 index 00000000..b3da3117 --- /dev/null +++ b/test/rescriptTests/IntTest/divideFloatTest.res @@ -0,0 +1,5 @@ +test ("divideFloat(3,2)", () => expect(3,2) |> toEqual(1.5)) +test ("divideFloat(27,5)", () => expect(27,5) |> toEqual(5.4)) +test ("divideFloat(8,4)", () => expect(8,4) |> toEqual(2)) +test ("divideFloat(8,0)", () => expect(8,0) |> toEqual(Float.infinity)) +test ("divideFloat(-8,0)", () => expect(-8,0) |> toEqual(Float.negativeInfinity)) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res new file mode 100644 index 00000000..99a0716b --- /dev/null +++ b/test/rescriptTests/IntTest/divideTest.res @@ -0,0 +1,3 @@ +test ("divide(3,2)", () => expect(3,2) |> toEqual(1)) +test ("divide(3,0)", () => expect(3,0) |> toEqual(exception)) +test ("divide(27,5)", () => expect(27,5) |> toEqual(5)) diff --git a/test/rescriptTests/IntTest/maximumTest.res b/test/rescriptTests/IntTest/maximumTest.res new file mode 100644 index 00000000..7e5d9ad6 --- /dev/null +++ b/test/rescriptTests/IntTest/maximumTest.res @@ -0,0 +1,3 @@ +test ("maximum(8,18)", () => expect(8,18) |> toEqual(18)) +test ("maximum(5,0)", () => expect(5,0) |> toEqual(5)) +test ("maximum(-4,-1)", () => expect(-4,-1) |> toEqual(-1)) diff --git a/test/rescriptTests/IntTest/powerTest.res b/test/rescriptTests/IntTest/powerTest.res new file mode 100644 index 00000000..ae6bde83 --- /dev/null +++ b/test/rescriptTests/IntTest/powerTest.res @@ -0,0 +1,3 @@ +test ("power(7,3)", () => expect(7,3) |> toEqual(343)) +test ("power(0,3)", () => expect(0,3) |> toEqual(0)) +test ("power(7,0)", () => expect(7,0) |> toEqual(1)) diff --git a/test/rescriptTests/IntTest/subtractTest.res b/test/rescriptTests/IntTest/subtractTest.res new file mode 100644 index 00000000..c20e50ec --- /dev/null +++ b/test/rescriptTests/IntTest/subtractTest.res @@ -0,0 +1 @@ +test ("subtract(4,3)", () => expect(4,3) |> toEqual(1)) diff --git a/yaml-files/Int.absolute.yaml b/yaml-files/Int.absolute.yaml new file mode 100644 index 00000000..96a75912 --- /dev/null +++ b/yaml-files/Int.absolute.yaml @@ -0,0 +1,26 @@ +module: Int +name: absolute +docstring: Get the absolute value of +parameters: + - name: a + type: int +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..707e9055 --- /dev/null +++ b/yaml-files/Int.add.yaml @@ -0,0 +1,24 @@ +module: Int +name: add +docstring: Add to , returning their sum +parameters: + - name: a + type: int + - name: b + type: int +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..5b1e2fe0 --- /dev/null +++ b/yaml-files/Int.clamp.yaml @@ -0,0 +1,42 @@ +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 + - name: lower + type: int + - name: upper + type: int +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, -10, -5] + 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, -10, -5] + 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..b544a72d --- /dev/null +++ b/yaml-files/Int.divide.yaml @@ -0,0 +1,28 @@ +module: Int +name: divide +docstring: divide by , returning their quotient +parameters: + - name: a + type: int + - name: by + type: int +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..ca01dbb1 --- /dev/null +++ b/yaml-files/Int.divideFloat.yaml @@ -0,0 +1,36 @@ +module: Int +name: divideFloat +docstring: divide by , returning their quotient +parameters: + - name: a + type: int + - name: by + type: int +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..a833e8aa --- /dev/null +++ b/yaml-files/Int.fromString.yaml @@ -0,0 +1,66 @@ +module: Int +name: fromString +docstring: Attempt to parse to an int +parameters: + - name: a + type: string +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..7dbe19e9 --- /dev/null +++ b/yaml-files/Int.inRange.yaml @@ -0,0 +1,42 @@ +module: Int +name: inRange +docstring: Checks if is between and up to, but not including, +parameters: + - name: a + type: int + - name: lower + type: int + - name: upper + type: int +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..f5e29fad --- /dev/null +++ b/yaml-files/Int.isEven.yaml @@ -0,0 +1,26 @@ +module: Int +name: isEven +docstring: Calculate mod 2, returning true if the remainder equals to 0, and false otherwise +parameters: + - name: a + type: int +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..83f7af44 --- /dev/null +++ b/yaml-files/Int.isOdd.yaml @@ -0,0 +1,26 @@ +module: Int +name: isOdd +docstring: Calculate mod 2, returning false if the remainder equals to 0, and true otherwise +parameters: + - name: a + type: int +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..ab13d1bc --- /dev/null +++ b/yaml-files/Int.maximum.yaml @@ -0,0 +1,28 @@ +module: Int +name: maximum +docstring: Compare and , returning the highest value +parameters: + - name: a + type: int + - name: b + type: int +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..264131d6 --- /dev/null +++ b/yaml-files/Int.minimum..yaml @@ -0,0 +1,28 @@ +module: Int +name: minimum +docstring: Compare and , returning the lowest value +parameters: + - name: a + type: int + - name: b + type: int +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..f00e5347 --- /dev/null +++ b/yaml-files/Int.modulo.yaml @@ -0,0 +1,52 @@ +module: Int +name: modulo +docstring: Perform modular arithmetic +parameters: + - name: a + type: int + - name: by + type: int +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..cf3386be --- /dev/null +++ b/yaml-files/Int.multiply.yaml @@ -0,0 +1,24 @@ +module: Int +name: multiply +docstring: Multiply by , returning their product +parameters: + - name: a + type: int + - name: b + type: int +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..43109d0d --- /dev/null +++ b/yaml-files/Int.negate.yaml @@ -0,0 +1,26 @@ +module: Int +name: negate +docstring: Flips the 'sign' of +parameters: + - name: a + type: int +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..a30f2484 --- /dev/null +++ b/yaml-files/Int.power.yaml @@ -0,0 +1,28 @@ +module: Int +name: power +docstring: Raise to the power of , returning the power +parameters: + - name: base + type: int + - name: exponent + type: int +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..d981a724 --- /dev/null +++ b/yaml-files/Int.remainder.yaml @@ -0,0 +1,48 @@ +module: Int +name: remainder +docstring: divide by , returning their remainder +parameters: + - name: a + type: int + - name: by + type: int +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..a7578fe3 --- /dev/null +++ b/yaml-files/Int.subtract.yaml @@ -0,0 +1,20 @@ +module: Int +name: subtract +docstring: Subtract from , returning their difference +parameters: + - name: a + type: int + - name: b + type: int +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..aded128b --- /dev/null +++ b/yaml-files/Int.toFloat.yaml @@ -0,0 +1,26 @@ +module: Int +name: toFloat +docstring: Convert into a [float] representation +parameters: + - name: a + type: int +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..5de7334d --- /dev/null +++ b/yaml-files/Int.toString.yaml @@ -0,0 +1,22 @@ +module: Int +name: toString +docstring: Convert into a [string] representation +parameters: + - name: a + type: int +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 From 4827da77195528262ff6182b162edccbcb9c49b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Oct 2022 18:45:59 +0200 Subject: [PATCH 02/31] Fix Rescript and FSharp tests --- src/generateTest.res | 6 +++--- test/fsharpTests/IntTest/absoluteTest.fs | 6 +++--- test/fsharpTests/IntTest/addTest.fs | 4 ++-- test/fsharpTests/IntTest/clampTest.fs | 12 ++++++------ test/fsharpTests/IntTest/divideFloatTest.fs | 10 +++++----- test/fsharpTests/IntTest/divideTest.fs | 6 +++--- test/fsharpTests/IntTest/maximumTest.fs | 6 +++--- test/fsharpTests/IntTest/powerTest.fs | 6 +++--- test/fsharpTests/IntTest/subtractTest.fs | 2 +- test/rescriptTests/IntTest/absoluteTest.res | 6 +++--- test/rescriptTests/IntTest/addTest.res | 4 ++-- test/rescriptTests/IntTest/clampTest.res | 12 ++++++------ test/rescriptTests/IntTest/divideFloatTest.res | 10 +++++----- test/rescriptTests/IntTest/divideTest.res | 6 +++--- test/rescriptTests/IntTest/maximumTest.res | 6 +++--- test/rescriptTests/IntTest/powerTest.res | 6 +++--- test/rescriptTests/IntTest/subtractTest.res | 2 +- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/generateTest.res b/src/generateTest.res index 00f46626..3c316710 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -24,7 +24,7 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) +let file = readFileSync(~name="../json-files/Int.power.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let resultsR = [] @@ -35,12 +35,12 @@ for i in 0 to Belt.Array.length(myData.tests)-1{ let test = myData.tests[i]; let inputs = test.inputs let output = test.output - let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)}) |> toEqual(${Belt.Int.toString(output)})) \n` + let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)})) \n` resultsR->Belt.Array.push(resultRescript) let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.Int ${Belt.Int.toString(output)}) ; \n` resultsO->Belt.Array.push(resultOcaml) let resultFSharp = - `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)})\n` + `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) "message" \n` resultsF->Belt.Array.push(resultFSharp) } diff --git a/test/fsharpTests/IntTest/absoluteTest.fs b/test/fsharpTests/IntTest/absoluteTest.fs index 06e8aa2a..6635ce75 100644 --- a/test/fsharpTests/IntTest/absoluteTest.fs +++ b/test/fsharpTests/IntTest/absoluteTest.fs @@ -1,9 +1,9 @@ testCase "absolute(8)" <| fun _ -> let expected = 8 - Expect.equal expected (absolute 8) + Expect.equal expected (absolute 8) "message" testCase "absolute(-7)" <| fun _ -> let expected = 7 - Expect.equal expected (absolute -7) + Expect.equal expected (absolute -7) "message" testCase "absolute(0)" <| fun _ -> let expected = 0 - Expect.equal expected (absolute 0) + Expect.equal expected (absolute 0) "message" diff --git a/test/fsharpTests/IntTest/addTest.fs b/test/fsharpTests/IntTest/addTest.fs index 6084cf5c..01714230 100644 --- a/test/fsharpTests/IntTest/addTest.fs +++ b/test/fsharpTests/IntTest/addTest.fs @@ -1,6 +1,6 @@ testCase "add(1,2)" <| fun _ -> let expected = 3 - Expect.equal expected (add 1 2) + Expect.equal expected (add 1 2) "message" testCase "add(1,1)" <| fun _ -> let expected = 2 - Expect.equal expected (add 1 1) + Expect.equal expected (add 1 1) "message" diff --git a/test/fsharpTests/IntTest/clampTest.fs b/test/fsharpTests/IntTest/clampTest.fs index 79f7c835..df920f21 100644 --- a/test/fsharpTests/IntTest/clampTest.fs +++ b/test/fsharpTests/IntTest/clampTest.fs @@ -1,18 +1,18 @@ testCase "clamp(5,0,8)" <| fun _ -> let expected = 5 - Expect.equal expected (clamp 5 0 8) + Expect.equal expected (clamp 5 0 8) "message" testCase "clamp(9,0,8)" <| fun _ -> let expected = 8 - Expect.equal expected (clamp 9 0 8) + Expect.equal expected (clamp 9 0 8) "message" testCase "clamp(1,2,8)" <| fun _ -> let expected = 2 - Expect.equal expected (clamp 1 2 8) + Expect.equal expected (clamp 1 2 8) "message" testCase "clamp(5,-10,-5)" <| fun _ -> let expected = -5 - Expect.equal expected (clamp 5 -10 -5) + Expect.equal expected (clamp 5 -10 -5) "message" testCase "clamp(-15,-10,-5)" <| fun _ -> let expected = -10 - Expect.equal expected (clamp -15 -10 -5) + Expect.equal expected (clamp -15 -10 -5) "message" testCase "clamp(3,-10,-5)" <| fun _ -> let expected = exception - Expect.equal expected (clamp 3 -10 -5) + Expect.equal expected (clamp 3 -10 -5) "message" diff --git a/test/fsharpTests/IntTest/divideFloatTest.fs b/test/fsharpTests/IntTest/divideFloatTest.fs index 35c5939c..520e2f1e 100644 --- a/test/fsharpTests/IntTest/divideFloatTest.fs +++ b/test/fsharpTests/IntTest/divideFloatTest.fs @@ -1,15 +1,15 @@ testCase "divideFloat(3,2)" <| fun _ -> let expected = 1.5 - Expect.equal expected (divideFloat 3 2) + Expect.equal expected (divideFloat 3 2) "message" testCase "divideFloat(27,5)" <| fun _ -> let expected = 5.4 - Expect.equal expected (divideFloat 27 5) + Expect.equal expected (divideFloat 27 5) "message" testCase "divideFloat(8,4)" <| fun _ -> let expected = 2 - Expect.equal expected (divideFloat 8 4) + Expect.equal expected (divideFloat 8 4) "message" testCase "divideFloat(8,0)" <| fun _ -> let expected = Float.infinity - Expect.equal expected (divideFloat 8 0) + Expect.equal expected (divideFloat 8 0) "message" testCase "divideFloat(-8,0)" <| fun _ -> let expected = Float.negativeInfinity - Expect.equal expected (divideFloat -8 0) + Expect.equal expected (divideFloat -8 0) "message" diff --git a/test/fsharpTests/IntTest/divideTest.fs b/test/fsharpTests/IntTest/divideTest.fs index 0d2c19bb..fb304c36 100644 --- a/test/fsharpTests/IntTest/divideTest.fs +++ b/test/fsharpTests/IntTest/divideTest.fs @@ -1,9 +1,9 @@ testCase "divide(3,2)" <| fun _ -> let expected = 1 - Expect.equal expected (divide 3 2) + Expect.equal expected (divide 3 2) "message" testCase "divide(3,0)" <| fun _ -> let expected = exception - Expect.equal expected (divide 3 0) + Expect.equal expected (divide 3 0) "message" testCase "divide(27,5)" <| fun _ -> let expected = 5 - Expect.equal expected (divide 27 5) + Expect.equal expected (divide 27 5) "message" diff --git a/test/fsharpTests/IntTest/maximumTest.fs b/test/fsharpTests/IntTest/maximumTest.fs index ffdcc6fd..97dd7c85 100644 --- a/test/fsharpTests/IntTest/maximumTest.fs +++ b/test/fsharpTests/IntTest/maximumTest.fs @@ -1,9 +1,9 @@ testCase "maximum(8,18)" <| fun _ -> let expected = 18 - Expect.equal expected (maximum 8 18) + Expect.equal expected (maximum 8 18) "message" testCase "maximum(5,0)" <| fun _ -> let expected = 5 - Expect.equal expected (maximum 5 0) + Expect.equal expected (maximum 5 0) "message" testCase "maximum(-4,-1)" <| fun _ -> let expected = -1 - Expect.equal expected (maximum -4 -1) + Expect.equal expected (maximum -4 -1) "message" diff --git a/test/fsharpTests/IntTest/powerTest.fs b/test/fsharpTests/IntTest/powerTest.fs index b6a77a5f..5d68dfaf 100644 --- a/test/fsharpTests/IntTest/powerTest.fs +++ b/test/fsharpTests/IntTest/powerTest.fs @@ -1,9 +1,9 @@ testCase "power(7,3)" <| fun _ -> let expected = 343 - Expect.equal expected (power 7 3) + Expect.equal expected (power 7 3) "message" testCase "power(0,3)" <| fun _ -> let expected = 0 - Expect.equal expected (power 0 3) + Expect.equal expected (power 0 3) "message" testCase "power(7,0)" <| fun _ -> let expected = 1 - Expect.equal expected (power 7 0) + Expect.equal expected (power 7 0) "message" diff --git a/test/fsharpTests/IntTest/subtractTest.fs b/test/fsharpTests/IntTest/subtractTest.fs index 76b7c4a0..810c671f 100644 --- a/test/fsharpTests/IntTest/subtractTest.fs +++ b/test/fsharpTests/IntTest/subtractTest.fs @@ -1,3 +1,3 @@ testCase "subtract(4,3)" <| fun _ -> let expected = 1 - Expect.equal expected (subtract 4 3) + Expect.equal expected (subtract 4 3) "message" diff --git a/test/rescriptTests/IntTest/absoluteTest.res b/test/rescriptTests/IntTest/absoluteTest.res index 25551cd3..0455ef5f 100644 --- a/test/rescriptTests/IntTest/absoluteTest.res +++ b/test/rescriptTests/IntTest/absoluteTest.res @@ -1,3 +1,3 @@ -test ("absolute(8)", () => expect(8) |> toEqual(8)) -test ("absolute(-7)", () => expect(-7) |> toEqual(7)) -test ("absolute(0)", () => expect(0) |> toEqual(0)) +test ("absolute(8)", () => expect(absolute(8)) |> toEqual(Eq.int, 8)) +test ("absolute(-7)", () => expect(absolute(-7)) |> toEqual(Eq.int, 7)) +test ("absolute(0)", () => expect(absolute(0)) |> toEqual(Eq.int, 0)) diff --git a/test/rescriptTests/IntTest/addTest.res b/test/rescriptTests/IntTest/addTest.res index 757f30ba..1694989d 100644 --- a/test/rescriptTests/IntTest/addTest.res +++ b/test/rescriptTests/IntTest/addTest.res @@ -1,2 +1,2 @@ -test ("add(1,2)", () => expect(1,2) |> toEqual(3)) -test ("add(1,1)", () => expect(1,1) |> toEqual(2)) +test ("add(1,2)", () => expect(add(1,2)) |> toEqual(Eq.int, 3)) +test ("add(1,1)", () => expect(add(1,1)) |> toEqual(Eq.int, 2)) diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res index 52eca30a..a650d44f 100644 --- a/test/rescriptTests/IntTest/clampTest.res +++ b/test/rescriptTests/IntTest/clampTest.res @@ -1,6 +1,6 @@ -test ("clamp(5,0,8)", () => expect(5,0,8) |> toEqual(5)) -test ("clamp(9,0,8)", () => expect(9,0,8) |> toEqual(8)) -test ("clamp(1,2,8)", () => expect(1,2,8) |> toEqual(2)) -test ("clamp(5,-10,-5)", () => expect(5,-10,-5) |> toEqual(-5)) -test ("clamp(-15,-10,-5)", () => expect(-15,-10,-5) |> toEqual(-10)) -test ("clamp(3,-10,-5)", () => expect(3,-10,-5) |> toEqual(exception)) +test ("clamp(5,0,8)", () => expect(clamp(5,0,8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,0,8)", () => expect(clamp(9,0,8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,2,8)", () => expect(clamp(1,2,8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,-10,-5)", () => expect(clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,-10,-5)", () => expect(clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,-10,-5)", () => expect(clamp(3,-10,-5)) |> toEqual(Eq.int, exception)) diff --git a/test/rescriptTests/IntTest/divideFloatTest.res b/test/rescriptTests/IntTest/divideFloatTest.res index b3da3117..605edfc2 100644 --- a/test/rescriptTests/IntTest/divideFloatTest.res +++ b/test/rescriptTests/IntTest/divideFloatTest.res @@ -1,5 +1,5 @@ -test ("divideFloat(3,2)", () => expect(3,2) |> toEqual(1.5)) -test ("divideFloat(27,5)", () => expect(27,5) |> toEqual(5.4)) -test ("divideFloat(8,4)", () => expect(8,4) |> toEqual(2)) -test ("divideFloat(8,0)", () => expect(8,0) |> toEqual(Float.infinity)) -test ("divideFloat(-8,0)", () => expect(-8,0) |> toEqual(Float.negativeInfinity)) +test ("divideFloat(3,2)", () => expect(divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) +test ("divideFloat(27,5)", () => expect(divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) +test ("divideFloat(8,4)", () => expect(divideFloat(8,4)) |> toEqual(Eq.int, 2)) +test ("divideFloat(8,0)", () => expect(divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) +test ("divideFloat(-8,0)", () => expect(divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res index 99a0716b..e382e4e3 100644 --- a/test/rescriptTests/IntTest/divideTest.res +++ b/test/rescriptTests/IntTest/divideTest.res @@ -1,3 +1,3 @@ -test ("divide(3,2)", () => expect(3,2) |> toEqual(1)) -test ("divide(3,0)", () => expect(3,0) |> toEqual(exception)) -test ("divide(27,5)", () => expect(27,5) |> toEqual(5)) +test ("divide(3,2)", () => expect(divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(divide(3,0)) |> toEqual(Eq.int, exception)) +test ("divide(27,5)", () => expect(divide(27,5)) |> toEqual(Eq.int, 5)) diff --git a/test/rescriptTests/IntTest/maximumTest.res b/test/rescriptTests/IntTest/maximumTest.res index 7e5d9ad6..4fd950b0 100644 --- a/test/rescriptTests/IntTest/maximumTest.res +++ b/test/rescriptTests/IntTest/maximumTest.res @@ -1,3 +1,3 @@ -test ("maximum(8,18)", () => expect(8,18) |> toEqual(18)) -test ("maximum(5,0)", () => expect(5,0) |> toEqual(5)) -test ("maximum(-4,-1)", () => expect(-4,-1) |> toEqual(-1)) +test ("maximum(8,18)", () => expect(maximum(8,18)) |> toEqual(Eq.int, 18)) +test ("maximum(5,0)", () => expect(maximum(5,0)) |> toEqual(Eq.int, 5)) +test ("maximum(-4,-1)", () => expect(maximum(-4,-1)) |> toEqual(Eq.int, -1)) diff --git a/test/rescriptTests/IntTest/powerTest.res b/test/rescriptTests/IntTest/powerTest.res index ae6bde83..78703d79 100644 --- a/test/rescriptTests/IntTest/powerTest.res +++ b/test/rescriptTests/IntTest/powerTest.res @@ -1,3 +1,3 @@ -test ("power(7,3)", () => expect(7,3) |> toEqual(343)) -test ("power(0,3)", () => expect(0,3) |> toEqual(0)) -test ("power(7,0)", () => expect(7,0) |> toEqual(1)) +test ("power(7,3)", () => expect(power(7,3)) |> toEqual(Eq.int, 343)) +test ("power(0,3)", () => expect(power(0,3)) |> toEqual(Eq.int, 0)) +test ("power(7,0)", () => expect(power(7,0)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/subtractTest.res b/test/rescriptTests/IntTest/subtractTest.res index c20e50ec..c25d51fc 100644 --- a/test/rescriptTests/IntTest/subtractTest.res +++ b/test/rescriptTests/IntTest/subtractTest.res @@ -1 +1 @@ -test ("subtract(4,3)", () => expect(4,3) |> toEqual(1)) +test ("subtract(4,3)", () => expect(subtract(4,3)) |> toEqual(Eq.int, 1)) From 4d06bb6d183ae7406e260c4b0b6dcd8c4e3fac22 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Oct 2022 19:53:45 +0200 Subject: [PATCH 03/31] Handle exceptions in Rescript and Ocaml --- src/generateTest.res | 6 +++--- test/ocamlTests/IntTest/absoluteTest.ml | 6 +++--- test/ocamlTests/IntTest/addTest.ml | 4 ++-- test/ocamlTests/IntTest/clampTest.ml | 12 ++++++------ test/ocamlTests/IntTest/divideFloatTest.ml | 10 +++++----- test/ocamlTests/IntTest/divideTest.ml | 6 +++--- test/ocamlTests/IntTest/maximumTest.ml | 6 +++--- test/ocamlTests/IntTest/powerTest.ml | 6 +++--- test/ocamlTests/IntTest/subtractTest.ml | 2 +- test/rescriptTests/IntTest/clampTest.res | 2 +- test/rescriptTests/IntTest/divideTest.res | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/generateTest.res b/src/generateTest.res index 3c316710..2f266185 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -24,7 +24,7 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Int.power.json", #utf8) +let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let resultsR = [] @@ -35,9 +35,9 @@ for i in 0 to Belt.Array.length(myData.tests)-1{ let test = myData.tests[i]; let inputs = test.inputs let output = test.output - let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)})) \n` + let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toThrow)`} \n` resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.Int ${Belt.Int.toString(output)}) ; \n` + let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toThrow); `}\n` resultsO->Belt.Array.push(resultOcaml) let resultFSharp = `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) "message" \n` diff --git a/test/ocamlTests/IntTest/absoluteTest.ml b/test/ocamlTests/IntTest/absoluteTest.ml index 5eaff87a..813d8093 100644 --- a/test/ocamlTests/IntTest/absoluteTest.ml +++ b/test/ocamlTests/IntTest/absoluteTest.ml @@ -1,3 +1,3 @@ -test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.Int 8) ; -test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.Int 7) ; -test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.Int 0) ; +test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.int 8) ; +test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.int 7) ; +test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.int 0) ; diff --git a/test/ocamlTests/IntTest/addTest.ml b/test/ocamlTests/IntTest/addTest.ml index 3597e55f..0a1259c1 100644 --- a/test/ocamlTests/IntTest/addTest.ml +++ b/test/ocamlTests/IntTest/addTest.ml @@ -1,2 +1,2 @@ -test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.Int 3) ; -test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.Int 2) ; +test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.int 3) ; +test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.int 2) ; diff --git a/test/ocamlTests/IntTest/clampTest.ml b/test/ocamlTests/IntTest/clampTest.ml index a6cc1f8e..7d9021f3 100644 --- a/test/ocamlTests/IntTest/clampTest.ml +++ b/test/ocamlTests/IntTest/clampTest.ml @@ -1,6 +1,6 @@ -test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.Int 5) ; -test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.Int 8) ; -test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.Int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.Int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.Int -10) ; -test "clamp(3,-10,-5)" (fun () -> expect (clamp 3 -10 -5) |> toEqual Eq.Int exception) ; +test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.int 5) ; +test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.int 8) ; +test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.int -10) ; +test "clamp(3,-10,-5)" (fun () -> expect (fun () -> clamp 3 -10 -5) |> toThrow); diff --git a/test/ocamlTests/IntTest/divideFloatTest.ml b/test/ocamlTests/IntTest/divideFloatTest.ml index 33808ad8..61da21ff 100644 --- a/test/ocamlTests/IntTest/divideFloatTest.ml +++ b/test/ocamlTests/IntTest/divideFloatTest.ml @@ -1,5 +1,5 @@ -test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.Int 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.Int 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.Int 2) ; -test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.Int Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.Int Float.negativeInfinity) ; +test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.int 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.int 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.int 2) ; +test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; diff --git a/test/ocamlTests/IntTest/divideTest.ml b/test/ocamlTests/IntTest/divideTest.ml index 0c664398..031b776b 100644 --- a/test/ocamlTests/IntTest/divideTest.ml +++ b/test/ocamlTests/IntTest/divideTest.ml @@ -1,3 +1,3 @@ -test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.Int 1) ; -test "divide(3,0)" (fun () -> expect (divide 3 0) |> toEqual Eq.Int exception) ; -test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.Int 5) ; +test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.int 5) ; diff --git a/test/ocamlTests/IntTest/maximumTest.ml b/test/ocamlTests/IntTest/maximumTest.ml index f4afaf60..c40a7673 100644 --- a/test/ocamlTests/IntTest/maximumTest.ml +++ b/test/ocamlTests/IntTest/maximumTest.ml @@ -1,3 +1,3 @@ -test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.Int 18) ; -test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.Int 5) ; -test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.Int -1) ; +test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.int 18) ; +test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.int 5) ; +test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.int -1) ; diff --git a/test/ocamlTests/IntTest/powerTest.ml b/test/ocamlTests/IntTest/powerTest.ml index c9e6576e..afb83d33 100644 --- a/test/ocamlTests/IntTest/powerTest.ml +++ b/test/ocamlTests/IntTest/powerTest.ml @@ -1,3 +1,3 @@ -test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.Int 343) ; -test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.Int 0) ; -test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.Int 1) ; +test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.int 343) ; +test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.int 0) ; +test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/subtractTest.ml b/test/ocamlTests/IntTest/subtractTest.ml index 90476d0b..5288570e 100644 --- a/test/ocamlTests/IntTest/subtractTest.ml +++ b/test/ocamlTests/IntTest/subtractTest.ml @@ -1 +1 @@ -test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.Int 1) ; +test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res index a650d44f..27dc51ee 100644 --- a/test/rescriptTests/IntTest/clampTest.res +++ b/test/rescriptTests/IntTest/clampTest.res @@ -3,4 +3,4 @@ test ("clamp(9,0,8)", () => expect(clamp(9,0,8)) |> toEqual(Eq.int, 8)) test ("clamp(1,2,8)", () => expect(clamp(1,2,8)) |> toEqual(Eq.int, 2)) test ("clamp(5,-10,-5)", () => expect(clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) test ("clamp(-15,-10,-5)", () => expect(clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,-10,-5)", () => expect(clamp(3,-10,-5)) |> toEqual(Eq.int, exception)) +test ("clamp(3,-10,-5)", () => expect(() => clamp(3,-10,-5)) |> toThrow) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res index e382e4e3..012e7bf2 100644 --- a/test/rescriptTests/IntTest/divideTest.res +++ b/test/rescriptTests/IntTest/divideTest.res @@ -1,3 +1,3 @@ test ("divide(3,2)", () => expect(divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(divide(3,0)) |> toEqual(Eq.int, exception)) +test ("divide(3,0)", () => expect(() => divide(3,0)) |> toThrow) test ("divide(27,5)", () => expect(divide(27,5)) |> toEqual(Eq.int, 5)) From 1153343bb904d7d3c95ff9e31a0b792f8ed82335 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Oct 2022 00:34:45 +0200 Subject: [PATCH 04/31] Handle exceptions in FSharp + generate all int tests in one file --- .gitignore | 4 +- json-files/Int.clamp.json | 8 +- src/generateTest.res | 15 +-- test/fsharpTests/IntTest.fs | 102 ++++++++++++++++++ test/fsharpTests/IntTest/absoluteTest.fs | 9 -- test/fsharpTests/IntTest/addTest.fs | 6 -- test/fsharpTests/IntTest/clampTest.fs | 18 ---- test/fsharpTests/IntTest/divideFloatTest.fs | 15 --- test/fsharpTests/IntTest/divideTest.fs | 9 -- test/fsharpTests/IntTest/maximumTest.fs | 9 -- test/fsharpTests/IntTest/powerTest.fs | 9 -- test/fsharpTests/IntTest/subtractTest.fs | 3 - test/ocamlTests/IntTest.ml | 26 +++++ test/ocamlTests/IntTest/absoluteTest.ml | 3 - test/ocamlTests/IntTest/addTest.ml | 2 - test/ocamlTests/IntTest/clampTest.ml | 6 -- test/ocamlTests/IntTest/divideFloatTest.ml | 5 - test/ocamlTests/IntTest/divideTest.ml | 3 - test/ocamlTests/IntTest/maximumTest.ml | 3 - test/ocamlTests/IntTest/powerTest.ml | 3 - test/ocamlTests/IntTest/subtractTest.ml | 1 - test/rescriptTests/IntTest.res | 26 +++++ test/rescriptTests/IntTest/absoluteTest.res | 3 - test/rescriptTests/IntTest/addTest.res | 2 - test/rescriptTests/IntTest/clampTest.res | 6 -- .../rescriptTests/IntTest/divideFloatTest.res | 5 - test/rescriptTests/IntTest/divideTest.res | 3 - test/rescriptTests/IntTest/maximumTest.res | 3 - test/rescriptTests/IntTest/powerTest.res | 3 - test/rescriptTests/IntTest/subtractTest.res | 1 - yaml-files/Int.clamp.yaml | 4 +- 31 files changed, 170 insertions(+), 145 deletions(-) create mode 100644 test/fsharpTests/IntTest.fs delete mode 100644 test/fsharpTests/IntTest/absoluteTest.fs delete mode 100644 test/fsharpTests/IntTest/addTest.fs delete mode 100644 test/fsharpTests/IntTest/clampTest.fs delete mode 100644 test/fsharpTests/IntTest/divideFloatTest.fs delete mode 100644 test/fsharpTests/IntTest/divideTest.fs delete mode 100644 test/fsharpTests/IntTest/maximumTest.fs delete mode 100644 test/fsharpTests/IntTest/powerTest.fs delete mode 100644 test/fsharpTests/IntTest/subtractTest.fs create mode 100644 test/ocamlTests/IntTest.ml delete mode 100644 test/ocamlTests/IntTest/absoluteTest.ml delete mode 100644 test/ocamlTests/IntTest/addTest.ml delete mode 100644 test/ocamlTests/IntTest/clampTest.ml delete mode 100644 test/ocamlTests/IntTest/divideFloatTest.ml delete mode 100644 test/ocamlTests/IntTest/divideTest.ml delete mode 100644 test/ocamlTests/IntTest/maximumTest.ml delete mode 100644 test/ocamlTests/IntTest/powerTest.ml delete mode 100644 test/ocamlTests/IntTest/subtractTest.ml create mode 100644 test/rescriptTests/IntTest.res delete mode 100644 test/rescriptTests/IntTest/absoluteTest.res delete mode 100644 test/rescriptTests/IntTest/addTest.res delete mode 100644 test/rescriptTests/IntTest/clampTest.res delete mode 100644 test/rescriptTests/IntTest/divideFloatTest.res delete mode 100644 test/rescriptTests/IntTest/divideTest.res delete mode 100644 test/rescriptTests/IntTest/maximumTest.res delete mode 100644 test/rescriptTests/IntTest/powerTest.res delete mode 100644 test/rescriptTests/IntTest/subtractTest.res 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/json-files/Int.clamp.json b/json-files/Int.clamp.json index 39c08edc..a5c30bd6 100644 --- a/json-files/Int.clamp.json +++ b/json-files/Int.clamp.json @@ -65,8 +65,8 @@ { "inputs": [ 3, - -10, - -5 + 7, + 1 ], "output": "exception" } @@ -115,8 +115,8 @@ { "inputs": [ 3, - -10, - -5 + 7, + 1 ], "output": "exception" } diff --git a/src/generateTest.res b/src/generateTest.res index 2f266185..c504b20e 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -16,6 +16,7 @@ type parameter ={ } type data = { + \"module": string, name: string, parameters:array, tests: array, @@ -27,6 +28,7 @@ external parseIntoMyData: string => data = "parse" let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name +let \"module" = myData.\"module" let resultsR = [] let resultsF = [] let resultsO = [] @@ -35,21 +37,22 @@ for i in 0 to Belt.Array.length(myData.tests)-1{ let test = myData.tests[i]; let inputs = test.inputs let output = test.output - let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toThrow)`} \n` + let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Belt.Int.toString(output)!="exception"? `${\"module"}.${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${\"module"}.${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toThrow)`} \n` resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toThrow); `}\n` + let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toThrow); `}\n` resultsO->Belt.Array.push(resultOcaml) let resultFSharp = - `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) "message" \n` + `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" \n<| fun _ -> \n ${Belt.Int.toString(output)!="exception"? `let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) "error"` : `Expect.equal (${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> failwith "error"`}\n` resultsF->Belt.Array.push(resultFSharp) } let finalresultR = Js.Array.joinWith("",resultsR) let finalresultF = Js.Array.joinWith("",resultsF) let finalresultO = Js.Array.joinWith("",resultsO) - Node.Fs.writeFileSync(`../test/rescriptTests/IntTest/${name}Test.res`, finalresultR, #utf8) - Node.Fs.writeFileSync(`../test/ocamlTests/IntTest/${name}Test.ml`, finalresultO, #utf8) - Node.Fs.writeFileSync(`../test/fsharpTests/IntTest/${name}Test.fs`, finalresultF, #utf8) + %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") + %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") + %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") + diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs new file mode 100644 index 00000000..7f08cf45 --- /dev/null +++ b/test/fsharpTests/IntTest.fs @@ -0,0 +1,102 @@ +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,0,8)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.clamp 5 0 8) "error" +testCase "clamp(9,0,8)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.clamp 9 0 8) "error" +testCase "clamp(1,2,8)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.clamp 1 2 8) "error" +testCase "clamp(5,-10,-5)" +<| fun _ -> + let expected = -5 + Expect.equal expected (Int.clamp 5 -10 -5) "error" +testCase "clamp(-15,-10,-5)" +<| fun _ -> + let expected = -10 + Expect.equal expected (Int.clamp -15 -10 -5) "error" +testCase "clamp(3,7,1)" +<| fun _ -> + Expect.equal (Int.clamp 3 7 1) |> failwith "error" +testCase "divide(3,2)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.divide 3 2) "error" +testCase "divide(3,0)" +<| fun _ -> + Expect.equal (Int.divide 3 0) |> failwith "error" +testCase "divide(27,5)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.divide 27 5) "error" +testCase "divideFloat(3,2)" +<| fun _ -> + let expected = 1.5 + Expect.equal expected (Int.divideFloat 3 2) "error" +testCase "divideFloat(27,5)" +<| fun _ -> + let expected = 5.4 + Expect.equal expected (Int.divideFloat 27 5) "error" +testCase "divideFloat(8,4)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.divideFloat 8 4) "error" +testCase "divideFloat(8,0)" +<| fun _ -> + let expected = Float.infinity + Expect.equal expected (Int.divideFloat 8 0) "error" +testCase "divideFloat(-8,0)" +<| fun _ -> + let expected = Float.negativeInfinity + Expect.equal expected (Int.divideFloat -8 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 "power(7,3)" +<| fun _ -> + let expected = 343 + Expect.equal expected (Int.power 7 3) "error" +testCase "power(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.power 0 3) "error" +testCase "power(7,0)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.power 7 0) "error" +testCase "subtract(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.subtract 4 3) "error" diff --git a/test/fsharpTests/IntTest/absoluteTest.fs b/test/fsharpTests/IntTest/absoluteTest.fs deleted file mode 100644 index 6635ce75..00000000 --- a/test/fsharpTests/IntTest/absoluteTest.fs +++ /dev/null @@ -1,9 +0,0 @@ -testCase "absolute(8)" <| fun _ -> - let expected = 8 - Expect.equal expected (absolute 8) "message" -testCase "absolute(-7)" <| fun _ -> - let expected = 7 - Expect.equal expected (absolute -7) "message" -testCase "absolute(0)" <| fun _ -> - let expected = 0 - Expect.equal expected (absolute 0) "message" diff --git a/test/fsharpTests/IntTest/addTest.fs b/test/fsharpTests/IntTest/addTest.fs deleted file mode 100644 index 01714230..00000000 --- a/test/fsharpTests/IntTest/addTest.fs +++ /dev/null @@ -1,6 +0,0 @@ -testCase "add(1,2)" <| fun _ -> - let expected = 3 - Expect.equal expected (add 1 2) "message" -testCase "add(1,1)" <| fun _ -> - let expected = 2 - Expect.equal expected (add 1 1) "message" diff --git a/test/fsharpTests/IntTest/clampTest.fs b/test/fsharpTests/IntTest/clampTest.fs deleted file mode 100644 index df920f21..00000000 --- a/test/fsharpTests/IntTest/clampTest.fs +++ /dev/null @@ -1,18 +0,0 @@ -testCase "clamp(5,0,8)" <| fun _ -> - let expected = 5 - Expect.equal expected (clamp 5 0 8) "message" -testCase "clamp(9,0,8)" <| fun _ -> - let expected = 8 - Expect.equal expected (clamp 9 0 8) "message" -testCase "clamp(1,2,8)" <| fun _ -> - let expected = 2 - Expect.equal expected (clamp 1 2 8) "message" -testCase "clamp(5,-10,-5)" <| fun _ -> - let expected = -5 - Expect.equal expected (clamp 5 -10 -5) "message" -testCase "clamp(-15,-10,-5)" <| fun _ -> - let expected = -10 - Expect.equal expected (clamp -15 -10 -5) "message" -testCase "clamp(3,-10,-5)" <| fun _ -> - let expected = exception - Expect.equal expected (clamp 3 -10 -5) "message" diff --git a/test/fsharpTests/IntTest/divideFloatTest.fs b/test/fsharpTests/IntTest/divideFloatTest.fs deleted file mode 100644 index 520e2f1e..00000000 --- a/test/fsharpTests/IntTest/divideFloatTest.fs +++ /dev/null @@ -1,15 +0,0 @@ -testCase "divideFloat(3,2)" <| fun _ -> - let expected = 1.5 - Expect.equal expected (divideFloat 3 2) "message" -testCase "divideFloat(27,5)" <| fun _ -> - let expected = 5.4 - Expect.equal expected (divideFloat 27 5) "message" -testCase "divideFloat(8,4)" <| fun _ -> - let expected = 2 - Expect.equal expected (divideFloat 8 4) "message" -testCase "divideFloat(8,0)" <| fun _ -> - let expected = Float.infinity - Expect.equal expected (divideFloat 8 0) "message" -testCase "divideFloat(-8,0)" <| fun _ -> - let expected = Float.negativeInfinity - Expect.equal expected (divideFloat -8 0) "message" diff --git a/test/fsharpTests/IntTest/divideTest.fs b/test/fsharpTests/IntTest/divideTest.fs deleted file mode 100644 index fb304c36..00000000 --- a/test/fsharpTests/IntTest/divideTest.fs +++ /dev/null @@ -1,9 +0,0 @@ -testCase "divide(3,2)" <| fun _ -> - let expected = 1 - Expect.equal expected (divide 3 2) "message" -testCase "divide(3,0)" <| fun _ -> - let expected = exception - Expect.equal expected (divide 3 0) "message" -testCase "divide(27,5)" <| fun _ -> - let expected = 5 - Expect.equal expected (divide 27 5) "message" diff --git a/test/fsharpTests/IntTest/maximumTest.fs b/test/fsharpTests/IntTest/maximumTest.fs deleted file mode 100644 index 97dd7c85..00000000 --- a/test/fsharpTests/IntTest/maximumTest.fs +++ /dev/null @@ -1,9 +0,0 @@ -testCase "maximum(8,18)" <| fun _ -> - let expected = 18 - Expect.equal expected (maximum 8 18) "message" -testCase "maximum(5,0)" <| fun _ -> - let expected = 5 - Expect.equal expected (maximum 5 0) "message" -testCase "maximum(-4,-1)" <| fun _ -> - let expected = -1 - Expect.equal expected (maximum -4 -1) "message" diff --git a/test/fsharpTests/IntTest/powerTest.fs b/test/fsharpTests/IntTest/powerTest.fs deleted file mode 100644 index 5d68dfaf..00000000 --- a/test/fsharpTests/IntTest/powerTest.fs +++ /dev/null @@ -1,9 +0,0 @@ -testCase "power(7,3)" <| fun _ -> - let expected = 343 - Expect.equal expected (power 7 3) "message" -testCase "power(0,3)" <| fun _ -> - let expected = 0 - Expect.equal expected (power 0 3) "message" -testCase "power(7,0)" <| fun _ -> - let expected = 1 - Expect.equal expected (power 7 0) "message" diff --git a/test/fsharpTests/IntTest/subtractTest.fs b/test/fsharpTests/IntTest/subtractTest.fs deleted file mode 100644 index 810c671f..00000000 --- a/test/fsharpTests/IntTest/subtractTest.fs +++ /dev/null @@ -1,3 +0,0 @@ -testCase "subtract(4,3)" <| fun _ -> - let expected = 1 - Expect.equal expected (subtract 4 3) "message" diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml new file mode 100644 index 00000000..60a45173 --- /dev/null +++ b/test/ocamlTests/IntTest.ml @@ -0,0 +1,26 @@ +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,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; +test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; +test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; +test "clamp(3,7,1)" (fun () -> expect (fun () -> Int.clamp 3 7 1) |> toThrow); +test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> Int.divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; +test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.int 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.int 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.int 2) ; +test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; +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 "power(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; +test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; +test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; +test "subtract(4,3)" (fun () -> expect (Int.subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/absoluteTest.ml b/test/ocamlTests/IntTest/absoluteTest.ml deleted file mode 100644 index 813d8093..00000000 --- a/test/ocamlTests/IntTest/absoluteTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.int 8) ; -test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.int 7) ; -test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.int 0) ; diff --git a/test/ocamlTests/IntTest/addTest.ml b/test/ocamlTests/IntTest/addTest.ml deleted file mode 100644 index 0a1259c1..00000000 --- a/test/ocamlTests/IntTest/addTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.int 3) ; -test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.int 2) ; diff --git a/test/ocamlTests/IntTest/clampTest.ml b/test/ocamlTests/IntTest/clampTest.ml deleted file mode 100644 index 7d9021f3..00000000 --- a/test/ocamlTests/IntTest/clampTest.ml +++ /dev/null @@ -1,6 +0,0 @@ -test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.int 5) ; -test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.int 8) ; -test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.int -10) ; -test "clamp(3,-10,-5)" (fun () -> expect (fun () -> clamp 3 -10 -5) |> toThrow); diff --git a/test/ocamlTests/IntTest/divideFloatTest.ml b/test/ocamlTests/IntTest/divideFloatTest.ml deleted file mode 100644 index 61da21ff..00000000 --- a/test/ocamlTests/IntTest/divideFloatTest.ml +++ /dev/null @@ -1,5 +0,0 @@ -test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.int 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.int 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.int 2) ; -test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; diff --git a/test/ocamlTests/IntTest/divideTest.ml b/test/ocamlTests/IntTest/divideTest.ml deleted file mode 100644 index 031b776b..00000000 --- a/test/ocamlTests/IntTest/divideTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.int 5) ; diff --git a/test/ocamlTests/IntTest/maximumTest.ml b/test/ocamlTests/IntTest/maximumTest.ml deleted file mode 100644 index c40a7673..00000000 --- a/test/ocamlTests/IntTest/maximumTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.int 18) ; -test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.int 5) ; -test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.int -1) ; diff --git a/test/ocamlTests/IntTest/powerTest.ml b/test/ocamlTests/IntTest/powerTest.ml deleted file mode 100644 index afb83d33..00000000 --- a/test/ocamlTests/IntTest/powerTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.int 343) ; -test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.int 0) ; -test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/subtractTest.ml b/test/ocamlTests/IntTest/subtractTest.ml deleted file mode 100644 index 5288570e..00000000 --- a/test/ocamlTests/IntTest/subtractTest.ml +++ /dev/null @@ -1 +0,0 @@ -test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res new file mode 100644 index 00000000..e91709c8 --- /dev/null +++ b/test/rescriptTests/IntTest.res @@ -0,0 +1,26 @@ +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,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) +test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) +test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) +test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) +test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) +test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.int, 2)) +test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) +test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) +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 ("power(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) +test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) +test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) +test ("subtract(4,3)", () => expect(Int.subtract(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/absoluteTest.res b/test/rescriptTests/IntTest/absoluteTest.res deleted file mode 100644 index 0455ef5f..00000000 --- a/test/rescriptTests/IntTest/absoluteTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("absolute(8)", () => expect(absolute(8)) |> toEqual(Eq.int, 8)) -test ("absolute(-7)", () => expect(absolute(-7)) |> toEqual(Eq.int, 7)) -test ("absolute(0)", () => expect(absolute(0)) |> toEqual(Eq.int, 0)) diff --git a/test/rescriptTests/IntTest/addTest.res b/test/rescriptTests/IntTest/addTest.res deleted file mode 100644 index 1694989d..00000000 --- a/test/rescriptTests/IntTest/addTest.res +++ /dev/null @@ -1,2 +0,0 @@ -test ("add(1,2)", () => expect(add(1,2)) |> toEqual(Eq.int, 3)) -test ("add(1,1)", () => expect(add(1,1)) |> toEqual(Eq.int, 2)) diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res deleted file mode 100644 index 27dc51ee..00000000 --- a/test/rescriptTests/IntTest/clampTest.res +++ /dev/null @@ -1,6 +0,0 @@ -test ("clamp(5,0,8)", () => expect(clamp(5,0,8)) |> toEqual(Eq.int, 5)) -test ("clamp(9,0,8)", () => expect(clamp(9,0,8)) |> toEqual(Eq.int, 8)) -test ("clamp(1,2,8)", () => expect(clamp(1,2,8)) |> toEqual(Eq.int, 2)) -test ("clamp(5,-10,-5)", () => expect(clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) -test ("clamp(-15,-10,-5)", () => expect(clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,-10,-5)", () => expect(() => clamp(3,-10,-5)) |> toThrow) diff --git a/test/rescriptTests/IntTest/divideFloatTest.res b/test/rescriptTests/IntTest/divideFloatTest.res deleted file mode 100644 index 605edfc2..00000000 --- a/test/rescriptTests/IntTest/divideFloatTest.res +++ /dev/null @@ -1,5 +0,0 @@ -test ("divideFloat(3,2)", () => expect(divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) -test ("divideFloat(27,5)", () => expect(divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) -test ("divideFloat(8,4)", () => expect(divideFloat(8,4)) |> toEqual(Eq.int, 2)) -test ("divideFloat(8,0)", () => expect(divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) -test ("divideFloat(-8,0)", () => expect(divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res deleted file mode 100644 index 012e7bf2..00000000 --- a/test/rescriptTests/IntTest/divideTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("divide(3,2)", () => expect(divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(divide(27,5)) |> toEqual(Eq.int, 5)) diff --git a/test/rescriptTests/IntTest/maximumTest.res b/test/rescriptTests/IntTest/maximumTest.res deleted file mode 100644 index 4fd950b0..00000000 --- a/test/rescriptTests/IntTest/maximumTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("maximum(8,18)", () => expect(maximum(8,18)) |> toEqual(Eq.int, 18)) -test ("maximum(5,0)", () => expect(maximum(5,0)) |> toEqual(Eq.int, 5)) -test ("maximum(-4,-1)", () => expect(maximum(-4,-1)) |> toEqual(Eq.int, -1)) diff --git a/test/rescriptTests/IntTest/powerTest.res b/test/rescriptTests/IntTest/powerTest.res deleted file mode 100644 index 78703d79..00000000 --- a/test/rescriptTests/IntTest/powerTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("power(7,3)", () => expect(power(7,3)) |> toEqual(Eq.int, 343)) -test ("power(0,3)", () => expect(power(0,3)) |> toEqual(Eq.int, 0)) -test ("power(7,0)", () => expect(power(7,0)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/subtractTest.res b/test/rescriptTests/IntTest/subtractTest.res deleted file mode 100644 index c25d51fc..00000000 --- a/test/rescriptTests/IntTest/subtractTest.res +++ /dev/null @@ -1 +0,0 @@ -test ("subtract(4,3)", () => expect(subtract(4,3)) |> toEqual(Eq.int, 1)) diff --git a/yaml-files/Int.clamp.yaml b/yaml-files/Int.clamp.yaml index 5b1e2fe0..dcedb445 100644 --- a/yaml-files/Int.clamp.yaml +++ b/yaml-files/Int.clamp.yaml @@ -24,7 +24,7 @@ tests: output: -5 - inputs: [-15, -10, -5] output: -10 - - inputs: [3, -10, -5] + - inputs: [3, 7, 1] output: exception examples: - inputs: [5, 0, 8] @@ -37,6 +37,6 @@ examples: output: -5 - inputs: [-15, -10, -5] output: -10 - - inputs: [3, -10, -5] + - inputs: [3, 7, 1] output: exception added: 0.1.0 From 412bff07edf276ea11fccb716a2cf360b09f8f10 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Oct 2022 00:40:13 +0200 Subject: [PATCH 05/31] Remove json folder --- json-files/Int.absolute.json | 45 ------------ json-files/Int.add.json | 53 -------------- json-files/Int.clamp.json | 125 -------------------------------- json-files/Int.divide.json | 67 ----------------- json-files/Int.divideFloat.json | 95 ------------------------ json-files/Int.maximum.json | 67 ----------------- json-files/Int.power.json | 67 ----------------- json-files/Int.subtract.json | 39 ---------- 8 files changed, 558 deletions(-) delete mode 100644 json-files/Int.absolute.json delete mode 100644 json-files/Int.add.json delete mode 100644 json-files/Int.clamp.json delete mode 100644 json-files/Int.divide.json delete mode 100644 json-files/Int.divideFloat.json delete mode 100644 json-files/Int.maximum.json delete mode 100644 json-files/Int.power.json delete mode 100644 json-files/Int.subtract.json diff --git a/json-files/Int.absolute.json b/json-files/Int.absolute.json deleted file mode 100644 index 3c9b7964..00000000 --- a/json-files/Int.absolute.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "module": "Int", - "name": "absolute", - "docstring": "Get the absolute value of ", - "parameters": [ - { - "name": "a", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.add.json b/json-files/Int.add.json deleted file mode 100644 index e02a853f..00000000 --- a/json-files/Int.add.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "module": "Int", - "name": "add", - "docstring": "Add to , returning their sum", - "parameters": [ - { - "name": "a", - "type": "int" - }, - { - "name": "b", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.clamp.json b/json-files/Int.clamp.json deleted file mode 100644 index a5c30bd6..00000000 --- a/json-files/Int.clamp.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "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" - }, - { - "name": "lower", - "type": "int" - }, - { - "name": "upper", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.divide.json b/json-files/Int.divide.json deleted file mode 100644 index 9b9e0b07..00000000 --- a/json-files/Int.divide.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "module": "Int", - "name": "divide", - "docstring": "divide by , returning their quotient", - "parameters": [ - { - "name": "a", - "type": "int" - }, - { - "name": "by", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.divideFloat.json b/json-files/Int.divideFloat.json deleted file mode 100644 index 804828d2..00000000 --- a/json-files/Int.divideFloat.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "module": "Int", - "name": "divideFloat", - "docstring": "divide by , returning their quotient", - "parameters": [ - { - "name": "a", - "type": "int" - }, - { - "name": "by", - "type": "int" - } - ], - "returnType": "float", - "constraints": [ - "no-ocaml", - "no-rescript" - ], - "tests": [ - { - "inputs": [ - 3, - 2 - ], - "output": 1.5 - }, - { - "inputs": [ - 27, - 5 - ], - "output": 5.4 - }, - { - "inputs": [ - 8, - 4 - ], - "output": 2 - }, - { - "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 - }, - { - "inputs": [ - 8, - 0 - ], - "output": "Float.infinity" - }, - { - "inputs": [ - -8, - 0 - ], - "output": "Float.negativeInfinity" - } - ], - "added": "0.1.0" -} \ No newline at end of file diff --git a/json-files/Int.maximum.json b/json-files/Int.maximum.json deleted file mode 100644 index e15bc7cf..00000000 --- a/json-files/Int.maximum.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "module": "Int", - "name": "maximum", - "docstring": "Compare and , returning the highest value", - "parameters": [ - { - "name": "a", - "type": "int" - }, - { - "name": "b", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.power.json b/json-files/Int.power.json deleted file mode 100644 index c3931f5a..00000000 --- a/json-files/Int.power.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "module": "Int", - "name": "power", - "docstring": "Raise to the power of , returning the power", - "parameters": [ - { - "name": "base", - "type": "int" - }, - { - "name": "exponent", - "type": "int" - } - ], - "returnType": "int", - "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" -} \ No newline at end of file diff --git a/json-files/Int.subtract.json b/json-files/Int.subtract.json deleted file mode 100644 index 6e852d3b..00000000 --- a/json-files/Int.subtract.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "module": "Int", - "name": "subtract", - "docstring": "Subtract from , returning their difference", - "parameters": [ - { - "name": "a", - "type": "int" - }, - { - "name": "b", - "type": "int" - } - ], - "returnType": "int", - "constraints": [ - "no-ocaml", - "no-rescript" - ], - "tests": [ - { - "inputs": [ - 4, - 3 - ], - "output": 1 - } - ], - "examples": [ - { - "inputs": [ - 4, - 3 - ], - "output": 1 - } - ], - "added": "0.1.0" -} \ No newline at end of file From a03e16ae09bfc95951e2d25527071175a9b98466 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Oct 2022 23:51:13 +0200 Subject: [PATCH 06/31] Use a new method to generate tests --- src/generateTest.res | 2 +- src/newMethod.res | 119 +++++++++++++++++++++++++ test/fsharpTests/IntTest.fs | 154 ++++++++++++++++++++++++--------- test/ocamlTests/IntTest.ml | 65 ++++++++------ test/rescriptTests/IntTest.res | 65 ++++++++------ 5 files changed, 309 insertions(+), 96 deletions(-) create mode 100644 src/newMethod.res diff --git a/src/generateTest.res b/src/generateTest.res index c504b20e..b42ef5de 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -12,7 +12,7 @@ type tests = { type parameter ={ name: string, - types: string, + \"type": string, } type data = { diff --git a/src/newMethod.res b/src/newMethod.res new file mode 100644 index 00000000..3ac77438 --- /dev/null +++ b/src/newMethod.res @@ -0,0 +1,119 @@ +@module("fs") +external readFileSync: ( + ~name: string, + [#utf8], +) => string = "readFileSync" + +type tests = { + inputs: array, + output: int, +} + +type parameter ={ + name: string, + \"type": string, +} + +type data = { + \"module": string, + name: string, + parameters:array, + tests: array, +} + +@scope("JSON") @val +external parseIntoMyData: string => data = "parse" + +let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) +let myData = parseIntoMyData(file) +let name = myData.name +let \"module" = myData.\"module" +let resultsR = [] +let resultsF = [] +let resultsO = [] +let inparr =[] +let inparr2 =[] +let length =Belt.Array.length(myData.parameters) + +let generate =Belt.Array.map(myData.tests, (test =>{ + let output= test.output + if (length==1){ + //param length == 1 type string + if (myData.parameters[0].\"type"=="string"){ + let newInput= `"${Js.Array.toString(test.inputs)}"` + let newInputR= Js.Array.toString(test.inputs) + let resultRescript = `test ("${name}(${newInputR})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp = `testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` + resultsF->Belt.Array.push(resultFSharp) + + }else{ + //param length == 1 type array + if (Js.Array.isArray(test.inputs)){ + let newInput= `[${Js.Array.toString(test.inputs)}]` + let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` + resultsF->Belt.Array.push(resultFSharp) + + } + //param length == 1 type int + else{ + let newInput= Js.Array.toString(test.inputs) + let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` + resultsF->Belt.Array.push(resultFSharp) + }} + } + //param length > 1 type + else{ + //param length > 1 type string + for i in 0 to length-1{ + if (myData.parameters[i].\"type"=="string"){ + let newInput= `"${Belt.Int.toString(test.inputs[i])}"` + inparr->Belt.Array.push(newInput) + } + //param length > 1 type array + if (Js.Array.isArray(test.inputs[i])){ + let newInput= `[${Belt.Int.toString(test.inputs[i])}]` + inparr2->Belt.Array.push(newInput) + let newInput=Js_array.joinWith(",", inparr2) + let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` + resultsF->Belt.Array.push(resultFSharp) + } + //param length > 1 type int + } + let newInput = Js_array.joinWith(",", test.inputs) + let newInputOF = Js_array.joinWith(" ", test.inputs) + let resultRescript = `test ("${name}(${newInputOF})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInputOF}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInputOF}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + // let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInputOF})\n` + let resultFSharp = + `testCase "${name}(${newInput})" \n<| fun _ -> \n ${Belt.Int.toString(output)!="exception"? `let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${\"module"}.${name} ${newInputOF}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF}) |> failwith "error"`}\n` + resultsF->Belt.Array.push(resultFSharp) +} + +})) + + let finalresultR = Js.Array.joinWith("",resultsR) + let finalresultF = Js.Array.joinWith("",resultsF) + let finalresultO = Js.Array.joinWith("",resultsO) + %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") + %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") + %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") + // Node.Fs.writeFileSync(`../rescriptTests/${name}Test.res`, finalresultR, #utf8) + // Node.Fs.writeFileSync(`../ocamlTests/${name}Test.ml`, finalresultO, #utf8) + // Node.Fs.writeFileSync(`../fsharpTests/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs index 7f08cf45..e7c68a59 100644 --- a/test/fsharpTests/IntTest.fs +++ b/test/fsharpTests/IntTest.fs @@ -1,77 +1,145 @@ -testCase "absolute(8)" -<| fun _ -> +testCase "absolute(8)" +<| fun _ -> let expected = 8 - Expect.equal expected (Int.absolute 8) "error" -testCase "absolute(-7)" -<| fun _ -> + Expect.equal expected (absolute 8) + +testCase "absolute(-7)" +<| fun _ -> let expected = 7 - Expect.equal expected (Int.absolute -7) "error" -testCase "absolute(0)" -<| fun _ -> + Expect.equal expected (absolute -7) + +testCase "absolute(0)" +<| fun _ -> let expected = 0 - Expect.equal expected (Int.absolute 0) "error" -testCase "add(1,2)" -<| fun _ -> + Expect.equal expected (absolute 0) + +testCase "add(1,2)" +<| fun _ -> let expected = 3 Expect.equal expected (Int.add 1 2) "error" -testCase "add(1,1)" -<| fun _ -> + +testCase "add(1,1)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.add 1 1) "error" -testCase "clamp(5,0,8)" -<| fun _ -> + +testCase "clamp(5,0,8)" +<| fun _ -> let expected = 5 Expect.equal expected (Int.clamp 5 0 8) "error" -testCase "clamp(9,0,8)" -<| fun _ -> + +testCase "clamp(9,0,8)" +<| fun _ -> let expected = 8 Expect.equal expected (Int.clamp 9 0 8) "error" -testCase "clamp(1,2,8)" -<| fun _ -> + +testCase "clamp(1,2,8)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.clamp 1 2 8) "error" -testCase "clamp(5,-10,-5)" -<| fun _ -> + +testCase "clamp(5,-10,-5)" +<| fun _ -> let expected = -5 Expect.equal expected (Int.clamp 5 -10 -5) "error" -testCase "clamp(-15,-10,-5)" -<| fun _ -> + +testCase "clamp(-15,-10,-5)" +<| fun _ -> let expected = -10 Expect.equal expected (Int.clamp -15 -10 -5) "error" -testCase "clamp(3,7,1)" -<| fun _ -> - Expect.equal (Int.clamp 3 7 1) |> failwith "error" -testCase "divide(3,2)" -<| fun _ -> + +testCase "clamp(3,7,1)" +<| fun _ -> Expect.equal (Int.clamp 3 7 1) |> failwith "error" + +testCase "divide(3,2)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.divide 3 2) "error" -testCase "divide(3,0)" -<| fun _ -> - Expect.equal (Int.divide 3 0) |> failwith "error" -testCase "divide(27,5)" -<| fun _ -> + +testCase "divide(3,0)" +<| fun _ -> Expect.equal (Int.divide 3 0) |> failwith "error" + +testCase "divide(27,5)" +<| fun _ -> let expected = 5 Expect.equal expected (Int.divide 27 5) "error" -testCase "divideFloat(3,2)" -<| fun _ -> + +testCase "divideFloat(3,2)" +<| fun _ -> let expected = 1.5 Expect.equal expected (Int.divideFloat 3 2) "error" -testCase "divideFloat(27,5)" -<| fun _ -> + +testCase "divideFloat(27,5)" +<| fun _ -> let expected = 5.4 Expect.equal expected (Int.divideFloat 27 5) "error" -testCase "divideFloat(8,4)" -<| fun _ -> + +testCase "divideFloat(8,4)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.divideFloat 8 4) "error" -testCase "divideFloat(8,0)" -<| fun _ -> + +testCase "divideFloat(8,0)" +<| fun _ -> let expected = Float.infinity Expect.equal expected (Int.divideFloat 8 0) "error" -testCase "divideFloat(-8,0)" -<| fun _ -> + +testCase "divideFloat(-8,0)" +<| fun _ -> let expected = Float.negativeInfinity Expect.equal expected (Int.divideFloat -8 0) "error" +testCase "fromString("0")" + <| fun _ -> + let expected = Some(0) + Expect.equal expected (fromString "0") +testCase "fromString("-0")" + <| fun _ -> + let expected = Some(-0) + Expect.equal expected (fromString "-0") +testCase "fromString("42")" + <| fun _ -> + let expected = Some(42) + Expect.equal expected (fromString "42") +testCase "fromString("123_456")" + <| fun _ -> + let expected = Some(123_456) + Expect.equal expected (fromString "123_456") +testCase "fromString("-42")" + <| fun _ -> + let expected = Some(-42) + Expect.equal expected (fromString "-42") +testCase "fromString("0XFF")" + <| fun _ -> + let expected = Some(255) + Expect.equal expected (fromString "0XFF") +testCase "fromString("0X000A")" + <| fun _ -> + let expected = Some(10) + Expect.equal expected (fromString "0X000A") +testCase "fromString("Infinity")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString "Infinity") +testCase "fromString("-Infinity")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString "-Infinity") +testCase "fromString("NaN")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString "NaN") +testCase "fromString("abc")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString "abc") +testCase "fromString("--4")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString "--4") +testCase "fromString(" ")" + <| fun _ -> + let expected = None + Expect.equal expected (fromString " ") testCase "maximum(8,18)" <| fun _ -> let expected = 18 diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml index 60a45173..836f5880 100644 --- a/test/ocamlTests/IntTest.ml +++ b/test/ocamlTests/IntTest.ml @@ -1,26 +1,39 @@ -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,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; -test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; -test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; -test "clamp(3,7,1)" (fun () -> expect (fun () -> Int.clamp 3 7 1) |> toThrow); -test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> Int.divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; -test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.int 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.int 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.int 2) ; -test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; -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 "power(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; -test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; -test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; -test "subtract(4,3)" (fun () -> expect (Int.subtract 4 3) |> toEqual Eq.int 1) ; +test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.int 8) ; +test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.int 7) ; +test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.int 0) ; +test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.int 3) ; +test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.int 2) ; +test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.int 5) ; +test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.int 8) ; +test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.int -10) ; +test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); +test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.int 5) ; +test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.int 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.int 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.int 2) ; +test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; +test "fromString("0")" (fun () -> expect (fromString "0") |> toEqual Eq.int Some(0)) ; +test "fromString("-0")" (fun () -> expect (fromString "-0") |> toEqual Eq.int Some(-0)) ; +test "fromString("42")" (fun () -> expect (fromString "42") |> toEqual Eq.int Some(42)) ; +test "fromString("123_456")" (fun () -> expect (fromString "123_456") |> toEqual Eq.int Some(123_456)) ; +test "fromString("-42")" (fun () -> expect (fromString "-42") |> toEqual Eq.int Some(-42)) ; +test "fromString("0XFF")" (fun () -> expect (fromString "0XFF") |> toEqual Eq.int Some(255)) ; +test "fromString("0X000A")" (fun () -> expect (fromString "0X000A") |> toEqual Eq.int Some(10)) ; +test "fromString("Infinity")" (fun () -> expect (fromString "Infinity") |> toEqual Eq.int None) ; +test "fromString("-Infinity")" (fun () -> expect (fromString "-Infinity") |> toEqual Eq.int None) ; +test "fromString("NaN")" (fun () -> expect (fromString "NaN") |> toEqual Eq.int None) ; +test "fromString("abc")" (fun () -> expect (fromString "abc") |> toEqual Eq.int None) ; +test "fromString("--4")" (fun () -> expect (fromString "--4") |> toEqual Eq.int None) ; +test "fromString(" ")" (fun () -> expect (fromString " ") |> toEqual Eq.int None) ; +test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.int 18) ; +test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.int 5) ; +test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.int -1) ; +test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.int 343) ; +test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.int 0) ; +test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.int 1) ; +test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res index e91709c8..6dc5d430 100644 --- a/test/rescriptTests/IntTest.res +++ b/test/rescriptTests/IntTest.res @@ -1,26 +1,39 @@ -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,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) -test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) -test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) -test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) -test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) -test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) -test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) -test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) -test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.int, 2)) -test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) -test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) -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 ("power(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) -test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) -test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) -test ("subtract(4,3)", () => expect(Int.subtract(4,3)) |> toEqual(Eq.int, 1)) +test ("absolute(8)", () => expect(absolute(8)) |> toEqual(Eq.int, 8)) +test ("absolute(-7)", () => expect(absolute(-7)) |> toEqual(Eq.int, 7)) +test ("absolute(0)", () => expect(absolute(0)) |> toEqual(Eq.int, 0)) +test ("add(1,2)", () => expect(add(1,2)) |> toEqual(Eq.int, 3)) +test ("add(1,1)", () => expect(add(1,1)) |> toEqual(Eq.int, 2)) +test ("clamp(5,0,8)", () => expect(clamp(5,0,8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,0,8)", () => expect(clamp(9,0,8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,2,8)", () => expect(clamp(1,2,8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,-10,-5)", () => expect(clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,-10,-5)", () => expect(clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,7,1)", () => expect(() => clamp(3,7,1)) |> toThrow) +test ("divide(3,2)", () => expect(divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(() => divide(3,0)) |> toThrow) +test ("divide(27,5)", () => expect(divide(27,5)) |> toEqual(Eq.int, 5)) +test ("divideFloat(3,2)", () => expect(divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) +test ("divideFloat(27,5)", () => expect(divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) +test ("divideFloat(8,4)", () => expect(divideFloat(8,4)) |> toEqual(Eq.int, 2)) +test ("divideFloat(8,0)", () => expect(divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) +test ("divideFloat(-8,0)", () => expect(divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) +test ("fromString(0)", () => expect(fromString("0")) |> toEqual(Eq.int, Some(0))) +test ("fromString(-0)", () => expect(fromString("-0")) |> toEqual(Eq.int, Some(-0))) +test ("fromString(42)", () => expect(fromString("42")) |> toEqual(Eq.int, Some(42))) +test ("fromString(123_456)", () => expect(fromString("123_456")) |> toEqual(Eq.int, Some(123_456))) +test ("fromString(-42)", () => expect(fromString("-42")) |> toEqual(Eq.int, Some(-42))) +test ("fromString(0XFF)", () => expect(fromString("0XFF")) |> toEqual(Eq.int, Some(255))) +test ("fromString(0X000A)", () => expect(fromString("0X000A")) |> toEqual(Eq.int, Some(10))) +test ("fromString(Infinity)", () => expect(fromString("Infinity")) |> toEqual(Eq.int, None)) +test ("fromString(-Infinity)", () => expect(fromString("-Infinity")) |> toEqual(Eq.int, None)) +test ("fromString(NaN)", () => expect(fromString("NaN")) |> toEqual(Eq.int, None)) +test ("fromString(abc)", () => expect(fromString("abc")) |> toEqual(Eq.int, None)) +test ("fromString(--4)", () => expect(fromString("--4")) |> toEqual(Eq.int, None)) +test ("fromString( )", () => expect(fromString(" ")) |> toEqual(Eq.int, None)) +test ("maximum(8 18)", () => expect(maximum(8,18)) |> toEqual(Eq.int, 18)) +test ("maximum(5 0)", () => expect(maximum(5,0)) |> toEqual(Eq.int, 5)) +test ("maximum(-4 -1)", () => expect(maximum(-4,-1)) |> toEqual(Eq.int, -1)) +test ("power(7 3)", () => expect(power(7,3)) |> toEqual(Eq.int, 343)) +test ("power(0 3)", () => expect(power(0,3)) |> toEqual(Eq.int, 0)) +test ("power(7 0)", () => expect(power(7,0)) |> toEqual(Eq.int, 1)) +test ("subtract(4 3)", () => expect(subtract(4,3)) |> toEqual(Eq.int, 1)) From 3b0cf6e9a5c2ff8206742fb0942aaceaf0891378 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Oct 2022 15:14:21 +0200 Subject: [PATCH 07/31] Clean up code, add remaining Int tests and Bool tests --- src/newMethod.res | 92 ++++------ test/fsharpTests/BoolTest/compareTest.fs | 16 ++ test/fsharpTests/BoolTest/equalTest.fs | 12 ++ test/fsharpTests/BoolTest/fromIntTest.fs | 28 +++ test/fsharpTests/BoolTest/fromStringTest.fs | 16 ++ test/fsharpTests/BoolTest/toIntTest.fs | 8 + test/fsharpTests/BoolTest/toStringTest.fs | 8 + test/fsharpTests/BoolTest/xorTest.fs | 16 ++ test/fsharpTests/IntTest.fs | 170 ------------------ test/fsharpTests/IntTest/absoluteTest.fs | 12 ++ test/fsharpTests/IntTest/addTest.fs | 8 + test/fsharpTests/IntTest/clampTest.fs | 23 +++ test/fsharpTests/IntTest/divideFloatTest.fs | 20 +++ test/fsharpTests/IntTest/divideTest.fs | 11 ++ test/fsharpTests/IntTest/fromStringTest.fs | 52 ++++++ test/fsharpTests/IntTest/inRangeTest.fs | 23 +++ test/fsharpTests/IntTest/isEvenTest.fs | 12 ++ test/fsharpTests/IntTest/isOddTest.fs | 12 ++ test/fsharpTests/IntTest/maximumTest.fs | 12 ++ test/fsharpTests/IntTest/minimumTest.fs | 12 ++ test/fsharpTests/IntTest/moduloTest.fs | 36 ++++ test/fsharpTests/IntTest/multiplyTest.fs | 4 + test/fsharpTests/IntTest/negateTest.fs | 12 ++ test/fsharpTests/IntTest/powerTest.fs | 12 ++ test/fsharpTests/IntTest/remainderTest.fs | 32 ++++ test/fsharpTests/IntTest/subtractTest.fs | 4 + test/fsharpTests/IntTest/toFloatTest.fs | 12 ++ test/ocamlTests/BoolTest/compareTest.ml | 4 + test/ocamlTests/BoolTest/equalTest.ml | 3 + test/ocamlTests/BoolTest/fromIntTest.ml | 7 + test/ocamlTests/BoolTest/fromStringTest.ml | 4 + test/ocamlTests/BoolTest/toIntTest.ml | 2 + test/ocamlTests/BoolTest/toStringTest.ml | 2 + test/ocamlTests/BoolTest/xorTest.ml | 4 + test/ocamlTests/IntTest.ml | 39 ---- test/ocamlTests/IntTest/absoluteTest.ml | 3 + test/ocamlTests/IntTest/addTest.ml | 2 + test/ocamlTests/IntTest/clampTest.ml | 6 + test/ocamlTests/IntTest/divideFloatTest.ml | 5 + test/ocamlTests/IntTest/divideTest.ml | 3 + test/ocamlTests/IntTest/fromStringTest.ml | 13 ++ test/ocamlTests/IntTest/inRangeTest.ml | 6 + test/ocamlTests/IntTest/isEvenTest.ml | 3 + test/ocamlTests/IntTest/isOddTest.ml | 3 + test/ocamlTests/IntTest/maximumTest.ml | 3 + test/ocamlTests/IntTest/minimumTest.ml | 3 + test/ocamlTests/IntTest/moduloTest.ml | 9 + test/ocamlTests/IntTest/multiplyTest.ml | 1 + test/ocamlTests/IntTest/negateTest.ml | 3 + test/ocamlTests/IntTest/powerTest.ml | 3 + test/ocamlTests/IntTest/remainderTest.ml | 8 + test/ocamlTests/IntTest/subtractTest.ml | 1 + test/ocamlTests/IntTest/toFloatTest.ml | 3 + test/rescriptTests/BoolTest/compareTest.res | 4 + test/rescriptTests/BoolTest/equalTest.res | 3 + test/rescriptTests/BoolTest/fromIntTest.res | 14 ++ .../rescriptTests/BoolTest/fromStringTest.res | 8 + test/rescriptTests/BoolTest/toIntTest.res | 2 + test/rescriptTests/BoolTest/toStringTest.res | 2 + test/rescriptTests/BoolTest/xorTest.res | 4 + test/rescriptTests/IntTest.res | 39 ---- test/rescriptTests/IntTest/absoluteTest.res | 3 + test/rescriptTests/IntTest/addTest.res | 2 + test/rescriptTests/IntTest/clampTest.res | 6 + .../rescriptTests/IntTest/divideFloatTest.res | 5 + test/rescriptTests/IntTest/divideTest.res | 3 + test/rescriptTests/IntTest/fromStringTest.res | 26 +++ test/rescriptTests/IntTest/inRangeTest.res | 6 + test/rescriptTests/IntTest/isEvenTest.res | 3 + test/rescriptTests/IntTest/isOddTest.res | 3 + test/rescriptTests/IntTest/maximumTest.res | 3 + test/rescriptTests/IntTest/minimumTest.res | 3 + test/rescriptTests/IntTest/moduloTest.res | 9 + test/rescriptTests/IntTest/multiplyTest.res | 1 + test/rescriptTests/IntTest/negateTest.res | 3 + test/rescriptTests/IntTest/powerTest.res | 3 + test/rescriptTests/IntTest/remainderTest.res | 8 + test/rescriptTests/IntTest/subtractTest.res | 1 + test/rescriptTests/IntTest/toFloatTest.res | 3 + yaml-files/Bool.compare.yaml | 32 ++++ yaml-files/Bool.equal.yaml | 28 +++ yaml-files/Bool.fromInt.yaml | 42 +++++ yaml-files/Bool.fromString.yaml | 30 ++++ yaml-files/Bool.toInt.yaml | 22 +++ yaml-files/Bool.toString.yaml | 22 +++ yaml-files/Bool.xor.yaml | 32 ++++ 86 files changed, 890 insertions(+), 303 deletions(-) create mode 100644 test/fsharpTests/BoolTest/compareTest.fs create mode 100644 test/fsharpTests/BoolTest/equalTest.fs create mode 100644 test/fsharpTests/BoolTest/fromIntTest.fs create mode 100644 test/fsharpTests/BoolTest/fromStringTest.fs create mode 100644 test/fsharpTests/BoolTest/toIntTest.fs create mode 100644 test/fsharpTests/BoolTest/toStringTest.fs create mode 100644 test/fsharpTests/BoolTest/xorTest.fs delete mode 100644 test/fsharpTests/IntTest.fs create mode 100644 test/fsharpTests/IntTest/absoluteTest.fs create mode 100644 test/fsharpTests/IntTest/addTest.fs create mode 100644 test/fsharpTests/IntTest/clampTest.fs create mode 100644 test/fsharpTests/IntTest/divideFloatTest.fs create mode 100644 test/fsharpTests/IntTest/divideTest.fs create mode 100644 test/fsharpTests/IntTest/fromStringTest.fs create mode 100644 test/fsharpTests/IntTest/inRangeTest.fs create mode 100644 test/fsharpTests/IntTest/isEvenTest.fs create mode 100644 test/fsharpTests/IntTest/isOddTest.fs create mode 100644 test/fsharpTests/IntTest/maximumTest.fs create mode 100644 test/fsharpTests/IntTest/minimumTest.fs create mode 100644 test/fsharpTests/IntTest/moduloTest.fs create mode 100644 test/fsharpTests/IntTest/multiplyTest.fs create mode 100644 test/fsharpTests/IntTest/negateTest.fs create mode 100644 test/fsharpTests/IntTest/powerTest.fs create mode 100644 test/fsharpTests/IntTest/remainderTest.fs create mode 100644 test/fsharpTests/IntTest/subtractTest.fs create mode 100644 test/fsharpTests/IntTest/toFloatTest.fs create mode 100644 test/ocamlTests/BoolTest/compareTest.ml create mode 100644 test/ocamlTests/BoolTest/equalTest.ml create mode 100644 test/ocamlTests/BoolTest/fromIntTest.ml create mode 100644 test/ocamlTests/BoolTest/fromStringTest.ml create mode 100644 test/ocamlTests/BoolTest/toIntTest.ml create mode 100644 test/ocamlTests/BoolTest/toStringTest.ml create mode 100644 test/ocamlTests/BoolTest/xorTest.ml delete mode 100644 test/ocamlTests/IntTest.ml create mode 100644 test/ocamlTests/IntTest/absoluteTest.ml create mode 100644 test/ocamlTests/IntTest/addTest.ml create mode 100644 test/ocamlTests/IntTest/clampTest.ml create mode 100644 test/ocamlTests/IntTest/divideFloatTest.ml create mode 100644 test/ocamlTests/IntTest/divideTest.ml create mode 100644 test/ocamlTests/IntTest/fromStringTest.ml create mode 100644 test/ocamlTests/IntTest/inRangeTest.ml create mode 100644 test/ocamlTests/IntTest/isEvenTest.ml create mode 100644 test/ocamlTests/IntTest/isOddTest.ml create mode 100644 test/ocamlTests/IntTest/maximumTest.ml create mode 100644 test/ocamlTests/IntTest/minimumTest.ml create mode 100644 test/ocamlTests/IntTest/moduloTest.ml create mode 100644 test/ocamlTests/IntTest/multiplyTest.ml create mode 100644 test/ocamlTests/IntTest/negateTest.ml create mode 100644 test/ocamlTests/IntTest/powerTest.ml create mode 100644 test/ocamlTests/IntTest/remainderTest.ml create mode 100644 test/ocamlTests/IntTest/subtractTest.ml create mode 100644 test/ocamlTests/IntTest/toFloatTest.ml create mode 100644 test/rescriptTests/BoolTest/compareTest.res create mode 100644 test/rescriptTests/BoolTest/equalTest.res create mode 100644 test/rescriptTests/BoolTest/fromIntTest.res create mode 100644 test/rescriptTests/BoolTest/fromStringTest.res create mode 100644 test/rescriptTests/BoolTest/toIntTest.res create mode 100644 test/rescriptTests/BoolTest/toStringTest.res create mode 100644 test/rescriptTests/BoolTest/xorTest.res delete mode 100644 test/rescriptTests/IntTest.res create mode 100644 test/rescriptTests/IntTest/absoluteTest.res create mode 100644 test/rescriptTests/IntTest/addTest.res create mode 100644 test/rescriptTests/IntTest/clampTest.res create mode 100644 test/rescriptTests/IntTest/divideFloatTest.res create mode 100644 test/rescriptTests/IntTest/divideTest.res create mode 100644 test/rescriptTests/IntTest/fromStringTest.res create mode 100644 test/rescriptTests/IntTest/inRangeTest.res create mode 100644 test/rescriptTests/IntTest/isEvenTest.res create mode 100644 test/rescriptTests/IntTest/isOddTest.res create mode 100644 test/rescriptTests/IntTest/maximumTest.res create mode 100644 test/rescriptTests/IntTest/minimumTest.res create mode 100644 test/rescriptTests/IntTest/moduloTest.res create mode 100644 test/rescriptTests/IntTest/multiplyTest.res create mode 100644 test/rescriptTests/IntTest/negateTest.res create mode 100644 test/rescriptTests/IntTest/powerTest.res create mode 100644 test/rescriptTests/IntTest/remainderTest.res create mode 100644 test/rescriptTests/IntTest/subtractTest.res create mode 100644 test/rescriptTests/IntTest/toFloatTest.res create mode 100644 yaml-files/Bool.compare.yaml create mode 100644 yaml-files/Bool.equal.yaml create mode 100644 yaml-files/Bool.fromInt.yaml create mode 100644 yaml-files/Bool.fromString.yaml create mode 100644 yaml-files/Bool.toInt.yaml create mode 100644 yaml-files/Bool.toString.yaml create mode 100644 yaml-files/Bool.xor.yaml diff --git a/src/newMethod.res b/src/newMethod.res index 3ac77438..554bf9e3 100644 --- a/src/newMethod.res +++ b/src/newMethod.res @@ -19,101 +19,83 @@ type data = { name: string, parameters:array, tests: array, + returnType: int } @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) +let file = readFileSync(~name="../json-files/Bool.toString.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name +let returnType = myData.returnType let \"module" = myData.\"module" let resultsR = [] let resultsF = [] let resultsO = [] let inparr =[] -let inparr2 =[] +let newInput=ref("") +let newInputR=ref("") +let newInputOF=ref("") +let output=ref(0) let length =Belt.Array.length(myData.parameters) let generate =Belt.Array.map(myData.tests, (test =>{ - let output= test.output + output:= test.output if (length==1){ //param length == 1 type string if (myData.parameters[0].\"type"=="string"){ - let newInput= `"${Js.Array.toString(test.inputs)}"` - let newInputR= Js.Array.toString(test.inputs) - let resultRescript = `test ("${name}(${newInputR})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - let resultFSharp = `testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` - resultsF->Belt.Array.push(resultFSharp) + newInput:= `"${Js.Array.toString(test.inputs)}"` + newInputR:= Js.Array.toString(test.inputs) + newInputOF:= `"${Js.Array.toString(test.inputs)}"` }else{ //param length == 1 type array if (Js.Array.isArray(test.inputs)){ - let newInput= `[${Js.Array.toString(test.inputs)}]` - let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` - resultsF->Belt.Array.push(resultFSharp) + newInput:= `[${Js.Array.toString(test.inputs)}]` } //param length == 1 type int else{ - let newInput= Js.Array.toString(test.inputs) - let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` - resultsF->Belt.Array.push(resultFSharp) + newInput:= Js.Array.toString(test.inputs) + newInputR:= Js.Array.toString(test.inputs) + newInputOF:= Js.Array.toString(test.inputs) }} } //param length > 1 type else{ - //param length > 1 type string + for i in 0 to length-1{ - if (myData.parameters[i].\"type"=="string"){ - let newInput= `"${Belt.Int.toString(test.inputs[i])}"` - inparr->Belt.Array.push(newInput) - } //param length > 1 type array if (Js.Array.isArray(test.inputs[i])){ - let newInput= `[${Belt.Int.toString(test.inputs[i])}]` - inparr2->Belt.Array.push(newInput) - let newInput=Js_array.joinWith(",", inparr2) - let resultRescript = `test ("${name}(${newInput})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInput}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInput}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInput})\n` - resultsF->Belt.Array.push(resultFSharp) + newInput:= `[${Belt.Int.toString(test.inputs[i])}]` + inparr->Belt.Array.push(newInput) + newInput:=Js_array.joinWith(",", inparr) } //param length > 1 type int } - let newInput = Js_array.joinWith(",", test.inputs) - let newInputOF = Js_array.joinWith(" ", test.inputs) - let resultRescript = `test ("${name}(${newInputOF})", () => expect(${Belt.Int.toString(output)!="exception"? `${name}(${newInput})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${name}(${newInput})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${name} ${newInputOF}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${name} ${newInputOF}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - // let resultFSharp =`testCase "${name}(${newInput})"\n <| fun _ -> \n let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${name} ${newInputOF})\n` - let resultFSharp = - `testCase "${name}(${newInput})" \n<| fun _ -> \n ${Belt.Int.toString(output)!="exception"? `let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${\"module"}.${name} ${newInputOF}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF}) |> failwith "error"`}\n` - resultsF->Belt.Array.push(resultFSharp) + newInput := Js_array.joinWith(",", test.inputs) + newInputOF := Js_array.joinWith(" ", test.inputs) + newInputR := Js_array.joinWith(",", test.inputs) + } + let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${Belt.Int.toString(output.contents)!="exception"? `${\"module"}.${name}(${newInput.contents})) |> toEqual(${Js.String.includes("Some", Belt.Int.toString(output.contents)) || Js.String.includes("None", Belt.Int.toString(output.contents)) ? `{open Eq\n${Js.String.slice(~from=0, ~to_=6, Belt.Int.toString(returnType))}(${Js.String.replace(">", "" ,Js.String.sliceToEnd(~from=7, Belt.Int.toString(returnType)))})}`: `Eq.${Belt.Int.toString(returnType)}`}, ${Belt.Int.toString(output.contents)}))` : `() => ${\"module"}.${name}(${newInput.contents})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${Belt.Int.toString(output.contents)!="exception"? `${\"module"}.${name} ${newInputOF.contents}) |> toEqual ${Js.String.includes("Some", Belt.Int.toString(output.contents)) || Js.String.includes("None", Belt.Int.toString(output.contents)) ? `(let open Eq in ${Js.String.slice(~from=0, ~to_=6, Belt.Int.toString(returnType))} ${Js.String.replace(">", "" ,Js.String.sliceToEnd(~from=7, Belt.Int.toString(returnType)))})`: `Eq.${Belt.Int.toString(returnType)}`} ${Belt.Int.toString(output.contents) == "exception"? "|> toThrow":Belt.Int.toString(output.contents)}) ; `:`fun () -> ${name} ${newInputOF.contents}) |> toThrow); `}\n` + resultsO->Belt.Array.push(resultOcaml) + let resultFSharp = + `testCase "${name}(${newInput.contents})" \n<| fun _ -> \n ${Belt.Int.toString(output.contents)!="exception"? `let expected = ${Belt.Int.toString(output.contents)}\n Expect.equal expected (${\"module"}.${name} ${newInputOF.contents}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` + resultsF->Belt.Array.push(resultFSharp) + })) let finalresultR = Js.Array.joinWith("",resultsR) let finalresultF = Js.Array.joinWith("",resultsF) let finalresultO = Js.Array.joinWith("",resultsO) - %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") - %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") - %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") - // Node.Fs.writeFileSync(`../rescriptTests/${name}Test.res`, finalresultR, #utf8) - // Node.Fs.writeFileSync(`../ocamlTests/${name}Test.ml`, finalresultO, #utf8) - // Node.Fs.writeFileSync(`../fsharpTests/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file + // %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") + // %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") + // %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") + Node.Fs.writeFileSync(`../test/rescriptTests/Bool/${name}Test.res`, finalresultR, #utf8) + Node.Fs.writeFileSync(`../test/ocamlTests/Bool/${name}Test.ml`, finalresultO, #utf8) + Node.Fs.writeFileSync(`../test/fsharpTests/Bool/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file diff --git a/test/fsharpTests/BoolTest/compareTest.fs b/test/fsharpTests/BoolTest/compareTest.fs new file mode 100644 index 00000000..1652bbba --- /dev/null +++ b/test/fsharpTests/BoolTest/compareTest.fs @@ -0,0 +1,16 @@ +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" diff --git a/test/fsharpTests/BoolTest/equalTest.fs b/test/fsharpTests/BoolTest/equalTest.fs new file mode 100644 index 00000000..b4f53fc3 --- /dev/null +++ b/test/fsharpTests/BoolTest/equalTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/BoolTest/fromIntTest.fs b/test/fsharpTests/BoolTest/fromIntTest.fs new file mode 100644 index 00000000..61d11273 --- /dev/null +++ b/test/fsharpTests/BoolTest/fromIntTest.fs @@ -0,0 +1,28 @@ +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" diff --git a/test/fsharpTests/BoolTest/fromStringTest.fs b/test/fsharpTests/BoolTest/fromStringTest.fs new file mode 100644 index 00000000..44dcdb72 --- /dev/null +++ b/test/fsharpTests/BoolTest/fromStringTest.fs @@ -0,0 +1,16 @@ +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" diff --git a/test/fsharpTests/BoolTest/toIntTest.fs b/test/fsharpTests/BoolTest/toIntTest.fs new file mode 100644 index 00000000..766d7956 --- /dev/null +++ b/test/fsharpTests/BoolTest/toIntTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/fsharpTests/BoolTest/toStringTest.fs b/test/fsharpTests/BoolTest/toStringTest.fs new file mode 100644 index 00000000..b4e3746f --- /dev/null +++ b/test/fsharpTests/BoolTest/toStringTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/fsharpTests/BoolTest/xorTest.fs b/test/fsharpTests/BoolTest/xorTest.fs new file mode 100644 index 00000000..1d7856f9 --- /dev/null +++ b/test/fsharpTests/BoolTest/xorTest.fs @@ -0,0 +1,16 @@ +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" diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs deleted file mode 100644 index e7c68a59..00000000 --- a/test/fsharpTests/IntTest.fs +++ /dev/null @@ -1,170 +0,0 @@ -testCase "absolute(8)" -<| fun _ -> - let expected = 8 - Expect.equal expected (absolute 8) - -testCase "absolute(-7)" -<| fun _ -> - let expected = 7 - Expect.equal expected (absolute -7) - -testCase "absolute(0)" -<| fun _ -> - let expected = 0 - Expect.equal expected (absolute 0) - -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,0,8)" -<| fun _ -> - let expected = 5 - Expect.equal expected (Int.clamp 5 0 8) "error" - -testCase "clamp(9,0,8)" -<| fun _ -> - let expected = 8 - Expect.equal expected (Int.clamp 9 0 8) "error" - -testCase "clamp(1,2,8)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.clamp 1 2 8) "error" - -testCase "clamp(5,-10,-5)" -<| fun _ -> - let expected = -5 - Expect.equal expected (Int.clamp 5 -10 -5) "error" - -testCase "clamp(-15,-10,-5)" -<| fun _ -> - let expected = -10 - Expect.equal expected (Int.clamp -15 -10 -5) "error" - -testCase "clamp(3,7,1)" -<| fun _ -> Expect.equal (Int.clamp 3 7 1) |> failwith "error" - -testCase "divide(3,2)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.divide 3 2) "error" - -testCase "divide(3,0)" -<| fun _ -> Expect.equal (Int.divide 3 0) |> failwith "error" - -testCase "divide(27,5)" -<| fun _ -> - let expected = 5 - Expect.equal expected (Int.divide 27 5) "error" - -testCase "divideFloat(3,2)" -<| fun _ -> - let expected = 1.5 - Expect.equal expected (Int.divideFloat 3 2) "error" - -testCase "divideFloat(27,5)" -<| fun _ -> - let expected = 5.4 - Expect.equal expected (Int.divideFloat 27 5) "error" - -testCase "divideFloat(8,4)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.divideFloat 8 4) "error" - -testCase "divideFloat(8,0)" -<| fun _ -> - let expected = Float.infinity - Expect.equal expected (Int.divideFloat 8 0) "error" - -testCase "divideFloat(-8,0)" -<| fun _ -> - let expected = Float.negativeInfinity - Expect.equal expected (Int.divideFloat -8 0) "error" -testCase "fromString("0")" - <| fun _ -> - let expected = Some(0) - Expect.equal expected (fromString "0") -testCase "fromString("-0")" - <| fun _ -> - let expected = Some(-0) - Expect.equal expected (fromString "-0") -testCase "fromString("42")" - <| fun _ -> - let expected = Some(42) - Expect.equal expected (fromString "42") -testCase "fromString("123_456")" - <| fun _ -> - let expected = Some(123_456) - Expect.equal expected (fromString "123_456") -testCase "fromString("-42")" - <| fun _ -> - let expected = Some(-42) - Expect.equal expected (fromString "-42") -testCase "fromString("0XFF")" - <| fun _ -> - let expected = Some(255) - Expect.equal expected (fromString "0XFF") -testCase "fromString("0X000A")" - <| fun _ -> - let expected = Some(10) - Expect.equal expected (fromString "0X000A") -testCase "fromString("Infinity")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString "Infinity") -testCase "fromString("-Infinity")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString "-Infinity") -testCase "fromString("NaN")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString "NaN") -testCase "fromString("abc")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString "abc") -testCase "fromString("--4")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString "--4") -testCase "fromString(" ")" - <| fun _ -> - let expected = None - Expect.equal expected (fromString " ") -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 "power(7,3)" -<| fun _ -> - let expected = 343 - Expect.equal expected (Int.power 7 3) "error" -testCase "power(0,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.power 0 3) "error" -testCase "power(7,0)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.power 7 0) "error" -testCase "subtract(4,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.subtract 4 3) "error" diff --git a/test/fsharpTests/IntTest/absoluteTest.fs b/test/fsharpTests/IntTest/absoluteTest.fs new file mode 100644 index 00000000..550d5297 --- /dev/null +++ b/test/fsharpTests/IntTest/absoluteTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/addTest.fs b/test/fsharpTests/IntTest/addTest.fs new file mode 100644 index 00000000..65f200bc --- /dev/null +++ b/test/fsharpTests/IntTest/addTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/fsharpTests/IntTest/clampTest.fs b/test/fsharpTests/IntTest/clampTest.fs new file mode 100644 index 00000000..a1b8e1be --- /dev/null +++ b/test/fsharpTests/IntTest/clampTest.fs @@ -0,0 +1,23 @@ +testCase "clamp(5,0,8)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.clamp 5 0 8) "error" +testCase "clamp(9,0,8)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.clamp 9 0 8) "error" +testCase "clamp(1,2,8)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.clamp 1 2 8) "error" +testCase "clamp(5,-10,-5)" +<| fun _ -> + let expected = -5 + Expect.equal expected (Int.clamp 5 -10 -5) "error" +testCase "clamp(-15,-10,-5)" +<| fun _ -> + let expected = -10 + Expect.equal expected (Int.clamp -15 -10 -5) "error" +testCase "clamp(3,7,1)" +<| fun _ -> + Expect.equal (Int.clamp 3 7 1) |> failwith "error" diff --git a/test/fsharpTests/IntTest/divideFloatTest.fs b/test/fsharpTests/IntTest/divideFloatTest.fs new file mode 100644 index 00000000..7ffac9b2 --- /dev/null +++ b/test/fsharpTests/IntTest/divideFloatTest.fs @@ -0,0 +1,20 @@ +testCase "divideFloat(3,2)" +<| fun _ -> + let expected = 1.5 + Expect.equal expected (Int.divideFloat 3 2) "error" +testCase "divideFloat(27,5)" +<| fun _ -> + let expected = 5.4 + Expect.equal expected (Int.divideFloat 27 5) "error" +testCase "divideFloat(8,4)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.divideFloat 8 4) "error" +testCase "divideFloat(8,0)" +<| fun _ -> + let expected = Float.infinity + Expect.equal expected (Int.divideFloat 8 0) "error" +testCase "divideFloat(-8,0)" +<| fun _ -> + let expected = Float.negativeInfinity + Expect.equal expected (Int.divideFloat -8 0) "error" diff --git a/test/fsharpTests/IntTest/divideTest.fs b/test/fsharpTests/IntTest/divideTest.fs new file mode 100644 index 00000000..5600256e --- /dev/null +++ b/test/fsharpTests/IntTest/divideTest.fs @@ -0,0 +1,11 @@ +testCase "divide(3,2)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.divide 3 2) "error" +testCase "divide(3,0)" +<| fun _ -> + Expect.equal (Int.divide 3 0) |> failwith "error" +testCase "divide(27,5)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.divide 27 5) "error" diff --git a/test/fsharpTests/IntTest/fromStringTest.fs b/test/fsharpTests/IntTest/fromStringTest.fs new file mode 100644 index 00000000..8806c092 --- /dev/null +++ b/test/fsharpTests/IntTest/fromStringTest.fs @@ -0,0 +1,52 @@ +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" diff --git a/test/fsharpTests/IntTest/inRangeTest.fs b/test/fsharpTests/IntTest/inRangeTest.fs new file mode 100644 index 00000000..ad25f7c5 --- /dev/null +++ b/test/fsharpTests/IntTest/inRangeTest.fs @@ -0,0 +1,23 @@ +testCase "inRange(3,2,4)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange 3 2 4) "error" +testCase "inRange(8,2,4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 8 2 4) "error" +testCase "inRange(1,2,4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 1 2 4) "error" +testCase "inRange(2,1,2)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 2 1 2) "error" +testCase "inRange(-6,-7,-5)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange -6 -7 -5) "error" +testCase "inRange(3,7,1)" +<| fun _ -> + Expect.equal (Int.inRange 3 7 1) |> failwith "error" diff --git a/test/fsharpTests/IntTest/isEvenTest.fs b/test/fsharpTests/IntTest/isEvenTest.fs new file mode 100644 index 00000000..e37bc618 --- /dev/null +++ b/test/fsharpTests/IntTest/isEvenTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/isOddTest.fs b/test/fsharpTests/IntTest/isOddTest.fs new file mode 100644 index 00000000..aafb3d80 --- /dev/null +++ b/test/fsharpTests/IntTest/isOddTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/maximumTest.fs b/test/fsharpTests/IntTest/maximumTest.fs new file mode 100644 index 00000000..9a1e4d3f --- /dev/null +++ b/test/fsharpTests/IntTest/maximumTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/minimumTest.fs b/test/fsharpTests/IntTest/minimumTest.fs new file mode 100644 index 00000000..d7a579ab --- /dev/null +++ b/test/fsharpTests/IntTest/minimumTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/moduloTest.fs b/test/fsharpTests/IntTest/moduloTest.fs new file mode 100644 index 00000000..18efe51c --- /dev/null +++ b/test/fsharpTests/IntTest/moduloTest.fs @@ -0,0 +1,36 @@ +testCase "modulo(-4,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -4 3) "error" +testCase "modulo(-3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo -3 3) "error" +testCase "modulo(-2,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo -2 3) "error" +testCase "modulo(-1,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -1 3) "error" +testCase "modulo(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 0 3) "error" +testCase "modulo(1,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 1 3) "error" +testCase "modulo(2,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo 2 3) "error" +testCase "modulo(3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 3 3) "error" +testCase "modulo(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 4 3) "error" diff --git a/test/fsharpTests/IntTest/multiplyTest.fs b/test/fsharpTests/IntTest/multiplyTest.fs new file mode 100644 index 00000000..1d996419 --- /dev/null +++ b/test/fsharpTests/IntTest/multiplyTest.fs @@ -0,0 +1,4 @@ +testCase "multiply(2,7)" +<| fun _ -> + let expected = 14 + Expect.equal expected (Int.multiply 2 7) "error" diff --git a/test/fsharpTests/IntTest/negateTest.fs b/test/fsharpTests/IntTest/negateTest.fs new file mode 100644 index 00000000..819b6fed --- /dev/null +++ b/test/fsharpTests/IntTest/negateTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/IntTest/powerTest.fs b/test/fsharpTests/IntTest/powerTest.fs new file mode 100644 index 00000000..63c8d031 --- /dev/null +++ b/test/fsharpTests/IntTest/powerTest.fs @@ -0,0 +1,12 @@ +testCase "power(7,3)" +<| fun _ -> + let expected = 343 + Expect.equal expected (Int.power 7 3) "error" +testCase "power(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.power 0 3) "error" +testCase "power(7,0)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.power 7 0) "error" diff --git a/test/fsharpTests/IntTest/remainderTest.fs b/test/fsharpTests/IntTest/remainderTest.fs new file mode 100644 index 00000000..1bc443d3 --- /dev/null +++ b/test/fsharpTests/IntTest/remainderTest.fs @@ -0,0 +1,32 @@ +testCase "remainder(-4,3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -4 3) "error" +testCase "remainder(-2,3)" +<| fun _ -> + let expected = -2 + Expect.equal expected (Int.remainder -2 3) "error" +testCase "remainder(-1,3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -1 3) "error" +testCase "remainder(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 0 3) "error" +testCase "remainder(1,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 1 3) "error" +testCase "remainder(2,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.remainder 2 3) "error" +testCase "remainder(3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 3 3) "error" +testCase "remainder(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 4 3) "error" diff --git a/test/fsharpTests/IntTest/subtractTest.fs b/test/fsharpTests/IntTest/subtractTest.fs new file mode 100644 index 00000000..5932c51e --- /dev/null +++ b/test/fsharpTests/IntTest/subtractTest.fs @@ -0,0 +1,4 @@ +testCase "subtract(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.subtract 4 3) "error" diff --git a/test/fsharpTests/IntTest/toFloatTest.fs b/test/fsharpTests/IntTest/toFloatTest.fs new file mode 100644 index 00000000..acf151dc --- /dev/null +++ b/test/fsharpTests/IntTest/toFloatTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/ocamlTests/BoolTest/compareTest.ml b/test/ocamlTests/BoolTest/compareTest.ml new file mode 100644 index 00000000..88b7bde8 --- /dev/null +++ b/test/ocamlTests/BoolTest/compareTest.ml @@ -0,0 +1,4 @@ +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) ; diff --git a/test/ocamlTests/BoolTest/equalTest.ml b/test/ocamlTests/BoolTest/equalTest.ml new file mode 100644 index 00000000..39bc0f4f --- /dev/null +++ b/test/ocamlTests/BoolTest/equalTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/BoolTest/fromIntTest.ml b/test/ocamlTests/BoolTest/fromIntTest.ml new file mode 100644 index 00000000..fd267959 --- /dev/null +++ b/test/ocamlTests/BoolTest/fromIntTest.ml @@ -0,0 +1,7 @@ +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) ; diff --git a/test/ocamlTests/BoolTest/fromStringTest.ml b/test/ocamlTests/BoolTest/fromStringTest.ml new file mode 100644 index 00000000..b90c6bf1 --- /dev/null +++ b/test/ocamlTests/BoolTest/fromStringTest.ml @@ -0,0 +1,4 @@ +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) ; diff --git a/test/ocamlTests/BoolTest/toIntTest.ml b/test/ocamlTests/BoolTest/toIntTest.ml new file mode 100644 index 00000000..bf8da42e --- /dev/null +++ b/test/ocamlTests/BoolTest/toIntTest.ml @@ -0,0 +1,2 @@ +test "toInt(true)" (fun () -> expect (Bool.toInt true) |> toEqual Eq.int 1) ; +test "toInt(false)" (fun () -> expect (Bool.toInt false) |> toEqual Eq.int 0) ; diff --git a/test/ocamlTests/BoolTest/toStringTest.ml b/test/ocamlTests/BoolTest/toStringTest.ml new file mode 100644 index 00000000..c94d7514 --- /dev/null +++ b/test/ocamlTests/BoolTest/toStringTest.ml @@ -0,0 +1,2 @@ +test "toString(true)" (fun () -> expect (Bool.toString true) |> toEqual Eq.string true) ; +test "toString(false)" (fun () -> expect (Bool.toString false) |> toEqual Eq.string false) ; diff --git a/test/ocamlTests/BoolTest/xorTest.ml b/test/ocamlTests/BoolTest/xorTest.ml new file mode 100644 index 00000000..64945658 --- /dev/null +++ b/test/ocamlTests/BoolTest/xorTest.ml @@ -0,0 +1,4 @@ +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) ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml deleted file mode 100644 index 836f5880..00000000 --- a/test/ocamlTests/IntTest.ml +++ /dev/null @@ -1,39 +0,0 @@ -test "absolute(8)" (fun () -> expect (absolute 8) |> toEqual Eq.int 8) ; -test "absolute(-7)" (fun () -> expect (absolute -7) |> toEqual Eq.int 7) ; -test "absolute(0)" (fun () -> expect (absolute 0) |> toEqual Eq.int 0) ; -test "add(1,2)" (fun () -> expect (add 1 2) |> toEqual Eq.int 3) ; -test "add(1,1)" (fun () -> expect (add 1 1) |> toEqual Eq.int 2) ; -test "clamp(5,0,8)" (fun () -> expect (clamp 5 0 8) |> toEqual Eq.int 5) ; -test "clamp(9,0,8)" (fun () -> expect (clamp 9 0 8) |> toEqual Eq.int 8) ; -test "clamp(1,2,8)" (fun () -> expect (clamp 1 2 8) |> toEqual Eq.int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (clamp 5 -10 -5) |> toEqual Eq.int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (clamp -15 -10 -5) |> toEqual Eq.int -10) ; -test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); -test "divide(3,2)" (fun () -> expect (divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (divide 27 5) |> toEqual Eq.int 5) ; -test "divideFloat(3,2)" (fun () -> expect (divideFloat 3 2) |> toEqual Eq.int 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (divideFloat 27 5) |> toEqual Eq.int 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (divideFloat 8 4) |> toEqual Eq.int 2) ; -test "divideFloat(8,0)" (fun () -> expect (divideFloat 8 0) |> toEqual Eq.int Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (divideFloat -8 0) |> toEqual Eq.int Float.negativeInfinity) ; -test "fromString("0")" (fun () -> expect (fromString "0") |> toEqual Eq.int Some(0)) ; -test "fromString("-0")" (fun () -> expect (fromString "-0") |> toEqual Eq.int Some(-0)) ; -test "fromString("42")" (fun () -> expect (fromString "42") |> toEqual Eq.int Some(42)) ; -test "fromString("123_456")" (fun () -> expect (fromString "123_456") |> toEqual Eq.int Some(123_456)) ; -test "fromString("-42")" (fun () -> expect (fromString "-42") |> toEqual Eq.int Some(-42)) ; -test "fromString("0XFF")" (fun () -> expect (fromString "0XFF") |> toEqual Eq.int Some(255)) ; -test "fromString("0X000A")" (fun () -> expect (fromString "0X000A") |> toEqual Eq.int Some(10)) ; -test "fromString("Infinity")" (fun () -> expect (fromString "Infinity") |> toEqual Eq.int None) ; -test "fromString("-Infinity")" (fun () -> expect (fromString "-Infinity") |> toEqual Eq.int None) ; -test "fromString("NaN")" (fun () -> expect (fromString "NaN") |> toEqual Eq.int None) ; -test "fromString("abc")" (fun () -> expect (fromString "abc") |> toEqual Eq.int None) ; -test "fromString("--4")" (fun () -> expect (fromString "--4") |> toEqual Eq.int None) ; -test "fromString(" ")" (fun () -> expect (fromString " ") |> toEqual Eq.int None) ; -test "maximum(8,18)" (fun () -> expect (maximum 8 18) |> toEqual Eq.int 18) ; -test "maximum(5,0)" (fun () -> expect (maximum 5 0) |> toEqual Eq.int 5) ; -test "maximum(-4,-1)" (fun () -> expect (maximum -4 -1) |> toEqual Eq.int -1) ; -test "power(7,3)" (fun () -> expect (power 7 3) |> toEqual Eq.int 343) ; -test "power(0,3)" (fun () -> expect (power 0 3) |> toEqual Eq.int 0) ; -test "power(7,0)" (fun () -> expect (power 7 0) |> toEqual Eq.int 1) ; -test "subtract(4,3)" (fun () -> expect (subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/absoluteTest.ml b/test/ocamlTests/IntTest/absoluteTest.ml new file mode 100644 index 00000000..e468c983 --- /dev/null +++ b/test/ocamlTests/IntTest/absoluteTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/addTest.ml b/test/ocamlTests/IntTest/addTest.ml new file mode 100644 index 00000000..94b28e0c --- /dev/null +++ b/test/ocamlTests/IntTest/addTest.ml @@ -0,0 +1,2 @@ +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) ; diff --git a/test/ocamlTests/IntTest/clampTest.ml b/test/ocamlTests/IntTest/clampTest.ml new file mode 100644 index 00000000..74bbe095 --- /dev/null +++ b/test/ocamlTests/IntTest/clampTest.ml @@ -0,0 +1,6 @@ +test "clamp(5,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; +test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; +test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; +test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); diff --git a/test/ocamlTests/IntTest/divideFloatTest.ml b/test/ocamlTests/IntTest/divideFloatTest.ml new file mode 100644 index 00000000..e0f39b67 --- /dev/null +++ b/test/ocamlTests/IntTest/divideFloatTest.ml @@ -0,0 +1,5 @@ +test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.float 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.float 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.float 2) ; +test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.float Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.float Float.negativeInfinity) ; diff --git a/test/ocamlTests/IntTest/divideTest.ml b/test/ocamlTests/IntTest/divideTest.ml new file mode 100644 index 00000000..dae7917d --- /dev/null +++ b/test/ocamlTests/IntTest/divideTest.ml @@ -0,0 +1,3 @@ +test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; diff --git a/test/ocamlTests/IntTest/fromStringTest.ml b/test/ocamlTests/IntTest/fromStringTest.ml new file mode 100644 index 00000000..b7829f58 --- /dev/null +++ b/test/ocamlTests/IntTest/fromStringTest.ml @@ -0,0 +1,13 @@ +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) ; diff --git a/test/ocamlTests/IntTest/inRangeTest.ml b/test/ocamlTests/IntTest/inRangeTest.ml new file mode 100644 index 00000000..29b35d23 --- /dev/null +++ b/test/ocamlTests/IntTest/inRangeTest.ml @@ -0,0 +1,6 @@ +test "inRange(3,2,4)" (fun () -> expect (Int.inRange 3 2 4) |> toEqual Eq.bool true) ; +test "inRange(8,2,4)" (fun () -> expect (Int.inRange 8 2 4) |> toEqual Eq.bool false) ; +test "inRange(1,2,4)" (fun () -> expect (Int.inRange 1 2 4) |> toEqual Eq.bool false) ; +test "inRange(2,1,2)" (fun () -> expect (Int.inRange 2 1 2) |> toEqual Eq.bool false) ; +test "inRange(-6,-7,-5)" (fun () -> expect (Int.inRange -6 -7 -5) |> toEqual Eq.bool true) ; +test "inRange(3,7,1)" (fun () -> expect (fun () -> inRange 3 7 1) |> toThrow); diff --git a/test/ocamlTests/IntTest/isEvenTest.ml b/test/ocamlTests/IntTest/isEvenTest.ml new file mode 100644 index 00000000..db5c9de2 --- /dev/null +++ b/test/ocamlTests/IntTest/isEvenTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/isOddTest.ml b/test/ocamlTests/IntTest/isOddTest.ml new file mode 100644 index 00000000..85977b04 --- /dev/null +++ b/test/ocamlTests/IntTest/isOddTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/maximumTest.ml b/test/ocamlTests/IntTest/maximumTest.ml new file mode 100644 index 00000000..3679da05 --- /dev/null +++ b/test/ocamlTests/IntTest/maximumTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/minimumTest.ml b/test/ocamlTests/IntTest/minimumTest.ml new file mode 100644 index 00000000..f453371b --- /dev/null +++ b/test/ocamlTests/IntTest/minimumTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/moduloTest.ml b/test/ocamlTests/IntTest/moduloTest.ml new file mode 100644 index 00000000..11b1b2ee --- /dev/null +++ b/test/ocamlTests/IntTest/moduloTest.ml @@ -0,0 +1,9 @@ +test "modulo(-4,3)" (fun () -> expect (Int.modulo -4 3) |> toEqual Eq.int 2) ; +test "modulo(-3,3)" (fun () -> expect (Int.modulo -3 3) |> toEqual Eq.int 0) ; +test "modulo(-2,3)" (fun () -> expect (Int.modulo -2 3) |> toEqual Eq.int 1) ; +test "modulo(-1,3)" (fun () -> expect (Int.modulo -1 3) |> toEqual Eq.int 2) ; +test "modulo(0,3)" (fun () -> expect (Int.modulo 0 3) |> toEqual Eq.int 0) ; +test "modulo(1,3)" (fun () -> expect (Int.modulo 1 3) |> toEqual Eq.int 1) ; +test "modulo(2,3)" (fun () -> expect (Int.modulo 2 3) |> toEqual Eq.int 2) ; +test "modulo(3,3)" (fun () -> expect (Int.modulo 3 3) |> toEqual Eq.int 0) ; +test "modulo(4,3)" (fun () -> expect (Int.modulo 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/multiplyTest.ml b/test/ocamlTests/IntTest/multiplyTest.ml new file mode 100644 index 00000000..87543b72 --- /dev/null +++ b/test/ocamlTests/IntTest/multiplyTest.ml @@ -0,0 +1 @@ +test "multiply(2,7)" (fun () -> expect (Int.multiply 2 7) |> toEqual Eq.int 14) ; diff --git a/test/ocamlTests/IntTest/negateTest.ml b/test/ocamlTests/IntTest/negateTest.ml new file mode 100644 index 00000000..c955b79e --- /dev/null +++ b/test/ocamlTests/IntTest/negateTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/IntTest/powerTest.ml b/test/ocamlTests/IntTest/powerTest.ml new file mode 100644 index 00000000..c771ca1a --- /dev/null +++ b/test/ocamlTests/IntTest/powerTest.ml @@ -0,0 +1,3 @@ +test "power(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; +test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; +test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/remainderTest.ml b/test/ocamlTests/IntTest/remainderTest.ml new file mode 100644 index 00000000..52def45c --- /dev/null +++ b/test/ocamlTests/IntTest/remainderTest.ml @@ -0,0 +1,8 @@ +test "remainder(-4,3)" (fun () -> expect (Int.remainder -4 3) |> toEqual Eq.int -1) ; +test "remainder(-2,3)" (fun () -> expect (Int.remainder -2 3) |> toEqual Eq.int -2) ; +test "remainder(-1,3)" (fun () -> expect (Int.remainder -1 3) |> toEqual Eq.int -1) ; +test "remainder(0,3)" (fun () -> expect (Int.remainder 0 3) |> toEqual Eq.int 0) ; +test "remainder(1,3)" (fun () -> expect (Int.remainder 1 3) |> toEqual Eq.int 1) ; +test "remainder(2,3)" (fun () -> expect (Int.remainder 2 3) |> toEqual Eq.int 2) ; +test "remainder(3,3)" (fun () -> expect (Int.remainder 3 3) |> toEqual Eq.int 0) ; +test "remainder(4,3)" (fun () -> expect (Int.remainder 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/subtractTest.ml b/test/ocamlTests/IntTest/subtractTest.ml new file mode 100644 index 00000000..f3a7d695 --- /dev/null +++ b/test/ocamlTests/IntTest/subtractTest.ml @@ -0,0 +1 @@ +test "subtract(4,3)" (fun () -> expect (Int.subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/toFloatTest.ml b/test/ocamlTests/IntTest/toFloatTest.ml new file mode 100644 index 00000000..0336688f --- /dev/null +++ b/test/ocamlTests/IntTest/toFloatTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/rescriptTests/BoolTest/compareTest.res b/test/rescriptTests/BoolTest/compareTest.res new file mode 100644 index 00000000..7d6b2259 --- /dev/null +++ b/test/rescriptTests/BoolTest/compareTest.res @@ -0,0 +1,4 @@ +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)) diff --git a/test/rescriptTests/BoolTest/equalTest.res b/test/rescriptTests/BoolTest/equalTest.res new file mode 100644 index 00000000..e16f0d9b --- /dev/null +++ b/test/rescriptTests/BoolTest/equalTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/BoolTest/fromIntTest.res b/test/rescriptTests/BoolTest/fromIntTest.res new file mode 100644 index 00000000..6d49a5e4 --- /dev/null +++ b/test/rescriptTests/BoolTest/fromIntTest.res @@ -0,0 +1,14 @@ +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)) diff --git a/test/rescriptTests/BoolTest/fromStringTest.res b/test/rescriptTests/BoolTest/fromStringTest.res new file mode 100644 index 00000000..5ad7ba15 --- /dev/null +++ b/test/rescriptTests/BoolTest/fromStringTest.res @@ -0,0 +1,8 @@ +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)) diff --git a/test/rescriptTests/BoolTest/toIntTest.res b/test/rescriptTests/BoolTest/toIntTest.res new file mode 100644 index 00000000..7203c693 --- /dev/null +++ b/test/rescriptTests/BoolTest/toIntTest.res @@ -0,0 +1,2 @@ +test ("toInt(true)", () => expect(Bool.toInt(true)) |> toEqual(Eq.int, 1)) +test ("toInt(false)", () => expect(Bool.toInt(false)) |> toEqual(Eq.int, 0)) diff --git a/test/rescriptTests/BoolTest/toStringTest.res b/test/rescriptTests/BoolTest/toStringTest.res new file mode 100644 index 00000000..cdf37b1b --- /dev/null +++ b/test/rescriptTests/BoolTest/toStringTest.res @@ -0,0 +1,2 @@ +test ("toString(true)", () => expect(Bool.toString(true)) |> toEqual(Eq.string, true)) +test ("toString(false)", () => expect(Bool.toString(false)) |> toEqual(Eq.string, false)) diff --git a/test/rescriptTests/BoolTest/xorTest.res b/test/rescriptTests/BoolTest/xorTest.res new file mode 100644 index 00000000..8950ff26 --- /dev/null +++ b/test/rescriptTests/BoolTest/xorTest.res @@ -0,0 +1,4 @@ +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)) diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res deleted file mode 100644 index 6dc5d430..00000000 --- a/test/rescriptTests/IntTest.res +++ /dev/null @@ -1,39 +0,0 @@ -test ("absolute(8)", () => expect(absolute(8)) |> toEqual(Eq.int, 8)) -test ("absolute(-7)", () => expect(absolute(-7)) |> toEqual(Eq.int, 7)) -test ("absolute(0)", () => expect(absolute(0)) |> toEqual(Eq.int, 0)) -test ("add(1,2)", () => expect(add(1,2)) |> toEqual(Eq.int, 3)) -test ("add(1,1)", () => expect(add(1,1)) |> toEqual(Eq.int, 2)) -test ("clamp(5,0,8)", () => expect(clamp(5,0,8)) |> toEqual(Eq.int, 5)) -test ("clamp(9,0,8)", () => expect(clamp(9,0,8)) |> toEqual(Eq.int, 8)) -test ("clamp(1,2,8)", () => expect(clamp(1,2,8)) |> toEqual(Eq.int, 2)) -test ("clamp(5,-10,-5)", () => expect(clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) -test ("clamp(-15,-10,-5)", () => expect(clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,7,1)", () => expect(() => clamp(3,7,1)) |> toThrow) -test ("divide(3,2)", () => expect(divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(divide(27,5)) |> toEqual(Eq.int, 5)) -test ("divideFloat(3,2)", () => expect(divideFloat(3,2)) |> toEqual(Eq.int, 1.5)) -test ("divideFloat(27,5)", () => expect(divideFloat(27,5)) |> toEqual(Eq.int, 5.4)) -test ("divideFloat(8,4)", () => expect(divideFloat(8,4)) |> toEqual(Eq.int, 2)) -test ("divideFloat(8,0)", () => expect(divideFloat(8,0)) |> toEqual(Eq.int, Float.infinity)) -test ("divideFloat(-8,0)", () => expect(divideFloat(-8,0)) |> toEqual(Eq.int, Float.negativeInfinity)) -test ("fromString(0)", () => expect(fromString("0")) |> toEqual(Eq.int, Some(0))) -test ("fromString(-0)", () => expect(fromString("-0")) |> toEqual(Eq.int, Some(-0))) -test ("fromString(42)", () => expect(fromString("42")) |> toEqual(Eq.int, Some(42))) -test ("fromString(123_456)", () => expect(fromString("123_456")) |> toEqual(Eq.int, Some(123_456))) -test ("fromString(-42)", () => expect(fromString("-42")) |> toEqual(Eq.int, Some(-42))) -test ("fromString(0XFF)", () => expect(fromString("0XFF")) |> toEqual(Eq.int, Some(255))) -test ("fromString(0X000A)", () => expect(fromString("0X000A")) |> toEqual(Eq.int, Some(10))) -test ("fromString(Infinity)", () => expect(fromString("Infinity")) |> toEqual(Eq.int, None)) -test ("fromString(-Infinity)", () => expect(fromString("-Infinity")) |> toEqual(Eq.int, None)) -test ("fromString(NaN)", () => expect(fromString("NaN")) |> toEqual(Eq.int, None)) -test ("fromString(abc)", () => expect(fromString("abc")) |> toEqual(Eq.int, None)) -test ("fromString(--4)", () => expect(fromString("--4")) |> toEqual(Eq.int, None)) -test ("fromString( )", () => expect(fromString(" ")) |> toEqual(Eq.int, None)) -test ("maximum(8 18)", () => expect(maximum(8,18)) |> toEqual(Eq.int, 18)) -test ("maximum(5 0)", () => expect(maximum(5,0)) |> toEqual(Eq.int, 5)) -test ("maximum(-4 -1)", () => expect(maximum(-4,-1)) |> toEqual(Eq.int, -1)) -test ("power(7 3)", () => expect(power(7,3)) |> toEqual(Eq.int, 343)) -test ("power(0 3)", () => expect(power(0,3)) |> toEqual(Eq.int, 0)) -test ("power(7 0)", () => expect(power(7,0)) |> toEqual(Eq.int, 1)) -test ("subtract(4 3)", () => expect(subtract(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/absoluteTest.res b/test/rescriptTests/IntTest/absoluteTest.res new file mode 100644 index 00000000..51be18ea --- /dev/null +++ b/test/rescriptTests/IntTest/absoluteTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/addTest.res b/test/rescriptTests/IntTest/addTest.res new file mode 100644 index 00000000..11abb562 --- /dev/null +++ b/test/rescriptTests/IntTest/addTest.res @@ -0,0 +1,2 @@ +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)) diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res new file mode 100644 index 00000000..d434277d --- /dev/null +++ b/test/rescriptTests/IntTest/clampTest.res @@ -0,0 +1,6 @@ +test ("clamp(5,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) diff --git a/test/rescriptTests/IntTest/divideFloatTest.res b/test/rescriptTests/IntTest/divideFloatTest.res new file mode 100644 index 00000000..a280a9e7 --- /dev/null +++ b/test/rescriptTests/IntTest/divideFloatTest.res @@ -0,0 +1,5 @@ +test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.float, 1.5)) +test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.float, 5.4)) +test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.float, 2)) +test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.float, Float.infinity)) +test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.float, Float.negativeInfinity)) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res new file mode 100644 index 00000000..1d8af7b8 --- /dev/null +++ b/test/rescriptTests/IntTest/divideTest.res @@ -0,0 +1,3 @@ +test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) +test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) diff --git a/test/rescriptTests/IntTest/fromStringTest.res b/test/rescriptTests/IntTest/fromStringTest.res new file mode 100644 index 00000000..3eca2907 --- /dev/null +++ b/test/rescriptTests/IntTest/fromStringTest.res @@ -0,0 +1,26 @@ +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)) diff --git a/test/rescriptTests/IntTest/inRangeTest.res b/test/rescriptTests/IntTest/inRangeTest.res new file mode 100644 index 00000000..f79a5ae1 --- /dev/null +++ b/test/rescriptTests/IntTest/inRangeTest.res @@ -0,0 +1,6 @@ +test ("inRange(3,2,4)", () => expect(Int.inRange(3,2,4)) |> toEqual(Eq.bool, true)) +test ("inRange(8,2,4)", () => expect(Int.inRange(8,2,4)) |> toEqual(Eq.bool, false)) +test ("inRange(1,2,4)", () => expect(Int.inRange(1,2,4)) |> toEqual(Eq.bool, false)) +test ("inRange(2,1,2)", () => expect(Int.inRange(2,1,2)) |> toEqual(Eq.bool, false)) +test ("inRange(-6,-7,-5)", () => expect(Int.inRange(-6,-7,-5)) |> toEqual(Eq.bool, true)) +test ("inRange(3,7,1)", () => expect(() => Int.inRange(3,7,1)) |> toThrow) diff --git a/test/rescriptTests/IntTest/isEvenTest.res b/test/rescriptTests/IntTest/isEvenTest.res new file mode 100644 index 00000000..a5e272d5 --- /dev/null +++ b/test/rescriptTests/IntTest/isEvenTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/isOddTest.res b/test/rescriptTests/IntTest/isOddTest.res new file mode 100644 index 00000000..d06425d6 --- /dev/null +++ b/test/rescriptTests/IntTest/isOddTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/maximumTest.res b/test/rescriptTests/IntTest/maximumTest.res new file mode 100644 index 00000000..61f46c30 --- /dev/null +++ b/test/rescriptTests/IntTest/maximumTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/minimumTest.res b/test/rescriptTests/IntTest/minimumTest.res new file mode 100644 index 00000000..acdd501d --- /dev/null +++ b/test/rescriptTests/IntTest/minimumTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/moduloTest.res b/test/rescriptTests/IntTest/moduloTest.res new file mode 100644 index 00000000..ca0a9821 --- /dev/null +++ b/test/rescriptTests/IntTest/moduloTest.res @@ -0,0 +1,9 @@ +test ("modulo(-4,3)", () => expect(Int.modulo(-4,3)) |> toEqual(Eq.int, 2)) +test ("modulo(-3,3)", () => expect(Int.modulo(-3,3)) |> toEqual(Eq.int, 0)) +test ("modulo(-2,3)", () => expect(Int.modulo(-2,3)) |> toEqual(Eq.int, 1)) +test ("modulo(-1,3)", () => expect(Int.modulo(-1,3)) |> toEqual(Eq.int, 2)) +test ("modulo(0,3)", () => expect(Int.modulo(0,3)) |> toEqual(Eq.int, 0)) +test ("modulo(1,3)", () => expect(Int.modulo(1,3)) |> toEqual(Eq.int, 1)) +test ("modulo(2,3)", () => expect(Int.modulo(2,3)) |> toEqual(Eq.int, 2)) +test ("modulo(3,3)", () => expect(Int.modulo(3,3)) |> toEqual(Eq.int, 0)) +test ("modulo(4,3)", () => expect(Int.modulo(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/multiplyTest.res b/test/rescriptTests/IntTest/multiplyTest.res new file mode 100644 index 00000000..898853b9 --- /dev/null +++ b/test/rescriptTests/IntTest/multiplyTest.res @@ -0,0 +1 @@ +test ("multiply(2,7)", () => expect(Int.multiply(2,7)) |> toEqual(Eq.int, 14)) diff --git a/test/rescriptTests/IntTest/negateTest.res b/test/rescriptTests/IntTest/negateTest.res new file mode 100644 index 00000000..cddf9366 --- /dev/null +++ b/test/rescriptTests/IntTest/negateTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/IntTest/powerTest.res b/test/rescriptTests/IntTest/powerTest.res new file mode 100644 index 00000000..3ffb6d9a --- /dev/null +++ b/test/rescriptTests/IntTest/powerTest.res @@ -0,0 +1,3 @@ +test ("power(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) +test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) +test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/remainderTest.res b/test/rescriptTests/IntTest/remainderTest.res new file mode 100644 index 00000000..1dafae54 --- /dev/null +++ b/test/rescriptTests/IntTest/remainderTest.res @@ -0,0 +1,8 @@ +test ("remainder(-4,3)", () => expect(Int.remainder(-4,3)) |> toEqual(Eq.int, -1)) +test ("remainder(-2,3)", () => expect(Int.remainder(-2,3)) |> toEqual(Eq.int, -2)) +test ("remainder(-1,3)", () => expect(Int.remainder(-1,3)) |> toEqual(Eq.int, -1)) +test ("remainder(0,3)", () => expect(Int.remainder(0,3)) |> toEqual(Eq.int, 0)) +test ("remainder(1,3)", () => expect(Int.remainder(1,3)) |> toEqual(Eq.int, 1)) +test ("remainder(2,3)", () => expect(Int.remainder(2,3)) |> toEqual(Eq.int, 2)) +test ("remainder(3,3)", () => expect(Int.remainder(3,3)) |> toEqual(Eq.int, 0)) +test ("remainder(4,3)", () => expect(Int.remainder(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/subtractTest.res b/test/rescriptTests/IntTest/subtractTest.res new file mode 100644 index 00000000..d8585c6d --- /dev/null +++ b/test/rescriptTests/IntTest/subtractTest.res @@ -0,0 +1 @@ +test ("subtract(4,3)", () => expect(Int.subtract(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/toFloatTest.res b/test/rescriptTests/IntTest/toFloatTest.res new file mode 100644 index 00000000..a7a2ec59 --- /dev/null +++ b/test/rescriptTests/IntTest/toFloatTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/yaml-files/Bool.compare.yaml b/yaml-files/Bool.compare.yaml new file mode 100644 index 00000000..8e262acd --- /dev/null +++ b/yaml-files/Bool.compare.yaml @@ -0,0 +1,32 @@ +module: Bool +name: compare +docstring: Compare two and . +parameters: + - name: a + type: bool + - name: a + type: bool +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..c05578c2 --- /dev/null +++ b/yaml-files/Bool.equal.yaml @@ -0,0 +1,28 @@ +module: Bool +name: equal +docstring: Test for the equality of and +parameters: + - name: a + type: bool + - name: a + type: bool +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..b6cba8b4 --- /dev/null +++ b/yaml-files/Bool.fromInt.yaml @@ -0,0 +1,42 @@ +module: Bool +name: fromInt +docstring: Convert (Int) into a Boolean +parameters: + - name: a + type: int +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..995a2a57 --- /dev/null +++ b/yaml-files/Bool.fromString.yaml @@ -0,0 +1,30 @@ +module: Bool +name: fromString +docstring: Convert (String) into a Boolean +parameters: + - name: a + type: string +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..fb736094 --- /dev/null +++ b/yaml-files/Bool.toInt.yaml @@ -0,0 +1,22 @@ +module: Bool +name: toInt +docstring: Convert (Bool) into an Int +parameters: + - name: a + type: bool +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..729d3628 --- /dev/null +++ b/yaml-files/Bool.toString.yaml @@ -0,0 +1,22 @@ +module: Bool +name: toString +docstring: Convert (Bool) into a String +parameters: + - name: a + type: bool +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..33f67563 --- /dev/null +++ b/yaml-files/Bool.xor.yaml @@ -0,0 +1,32 @@ +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 + - name: b + type: bool +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 From fcf500a59a281693cec03d348d8f1fd38b4c760b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Oct 2022 23:16:15 +0200 Subject: [PATCH 08/31] Add FloatTest functions' yaml files --- yaml-files/Float.absolute.yaml | 26 ++++ yaml-files/Float.add.yaml | 20 +++ yaml-files/Float.atan.yaml | 34 ++++ yaml-files/Float.atan2.yaml | 36 +++++ yaml-files/Float.ceiling.yaml | 38 +++++ yaml-files/Float.clamp.yaml | 54 +++++++ yaml-files/Float.cos.yaml | 22 +++ yaml-files/Float.degrees.yaml | 18 +++ yaml-files/Float.divide.yaml | 28 ++++ yaml-files/Float.floor.yaml | 38 +++++ yaml-files/Float.fromInt.yaml | 26 ++++ yaml-files/Float.fromString.yaml | 42 +++++ yaml-files/Float.hypotenuse.yaml | 20 +++ yaml-files/Float.inRange.yaml | 54 +++++++ yaml-files/Float.isFinite.yaml | 42 +++++ yaml-files/Float.isInfinite.yaml | 42 +++++ yaml-files/Float.isInteger.yaml | 22 +++ yaml-files/Float.isNaN.yaml | 21 +++ yaml-files/Float.log.yaml | 28 ++++ yaml-files/Float.maximum.yaml | 36 +++++ yaml-files/Float.minimum.yaml | 36 +++++ yaml-files/Float.multiply.yaml | 20 +++ yaml-files/Float.negate.yaml | 26 ++++ yaml-files/Float.power.yaml | 28 ++++ yaml-files/Float.radians.yaml | 18 +++ yaml-files/Float.round.yaml | 256 +++++++++++++++++++++++++++++++ yaml-files/Float.sin.yaml | 22 +++ yaml-files/Float.squareRoot.yaml | 26 ++++ yaml-files/Float.subtract.yaml | 20 +++ yaml-files/Float.tan.yaml | 26 ++++ yaml-files/Float.toInt.yaml | 42 +++++ yaml-files/Float.truncate.yaml | 38 +++++ yaml-files/Float.turns.yaml | 18 +++ 33 files changed, 1223 insertions(+) create mode 100644 yaml-files/Float.absolute.yaml create mode 100644 yaml-files/Float.add.yaml create mode 100644 yaml-files/Float.atan.yaml create mode 100644 yaml-files/Float.atan2.yaml create mode 100644 yaml-files/Float.ceiling.yaml create mode 100644 yaml-files/Float.clamp.yaml create mode 100644 yaml-files/Float.cos.yaml create mode 100644 yaml-files/Float.degrees.yaml create mode 100644 yaml-files/Float.divide.yaml create mode 100644 yaml-files/Float.floor.yaml create mode 100644 yaml-files/Float.fromInt.yaml create mode 100644 yaml-files/Float.fromString.yaml create mode 100644 yaml-files/Float.hypotenuse.yaml create mode 100644 yaml-files/Float.inRange.yaml create mode 100644 yaml-files/Float.isFinite.yaml create mode 100644 yaml-files/Float.isInfinite.yaml create mode 100644 yaml-files/Float.isInteger.yaml create mode 100644 yaml-files/Float.isNaN.yaml create mode 100644 yaml-files/Float.log.yaml create mode 100644 yaml-files/Float.maximum.yaml create mode 100644 yaml-files/Float.minimum.yaml create mode 100644 yaml-files/Float.multiply.yaml create mode 100644 yaml-files/Float.negate.yaml create mode 100644 yaml-files/Float.power.yaml create mode 100644 yaml-files/Float.radians.yaml create mode 100644 yaml-files/Float.round.yaml create mode 100644 yaml-files/Float.sin.yaml create mode 100644 yaml-files/Float.squareRoot.yaml create mode 100644 yaml-files/Float.subtract.yaml create mode 100644 yaml-files/Float.tan.yaml create mode 100644 yaml-files/Float.toInt.yaml create mode 100644 yaml-files/Float.truncate.yaml create mode 100644 yaml-files/Float.turns.yaml diff --git a/yaml-files/Float.absolute.yaml b/yaml-files/Float.absolute.yaml new file mode 100644 index 00000000..20c64fa7 --- /dev/null +++ b/yaml-files/Float.absolute.yaml @@ -0,0 +1,26 @@ +module: Float +name: absolute +docstring: Get the absolute value of +parameters: + - name: a + type: float +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..f5154f86 --- /dev/null +++ b/yaml-files/Float.add.yaml @@ -0,0 +1,20 @@ +module: Float +name: add +docstring: Add to , returning their sum +parameters: + - name: a + type: float + - name: b + type: float +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..78e42e03 --- /dev/null +++ b/yaml-files/Float.atan.yaml @@ -0,0 +1,34 @@ +module: Float +name: atan +docstring: Find the angle (in radians) to an [(x, y)] coordinate +parameters: + - name: a + type: float +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..a95e0bfe --- /dev/null +++ b/yaml-files/Float.atan2.yaml @@ -0,0 +1,36 @@ +module: Float +name: atan2 +docstring: Find the angle (in radians) to an [(x, y)] coordinate +parameters: + - name: \y + type: float + - name: x + type: float +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..322f0b01 --- /dev/null +++ b/yaml-files/Float.ceiling.yaml @@ -0,0 +1,38 @@ +module: Float +name: ceiling +docstring: Takes param, and returns the least number greater than or equal to param +parameters: + - name: a + type: float +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..43918938 --- /dev/null +++ b/yaml-files/Float.clamp.yaml @@ -0,0 +1,54 @@ +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 + - name: lower + type: float + - name: upper + type: float +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..759ee85c --- /dev/null +++ b/yaml-files/Float.cos.yaml @@ -0,0 +1,22 @@ +module: Float +name: cos +docstring: Takes in radians and figure out its cosine +parameters: + - name: a + type: radians +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..ea9c1d3f --- /dev/null +++ b/yaml-files/Float.degrees.yaml @@ -0,0 +1,18 @@ +module: Float +name: degrees +docstring: Converts an angle in degrees to radians +parameters: + - name: a + type: float +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..3c9dba4f --- /dev/null +++ b/yaml-files/Float.divide.yaml @@ -0,0 +1,28 @@ +module: Float +name: divide +docstring: divide by , returning their quotient +parameters: + - name: a + type: float + - name: by + type: float +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..5828aa6b --- /dev/null +++ b/yaml-files/Float.floor.yaml @@ -0,0 +1,38 @@ +module: Float +name: floor +docstring: Takes param, and returns the greatest number less than or equal to param +parameters: + - name: a + type: float +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..992dba4f --- /dev/null +++ b/yaml-files/Float.fromInt.yaml @@ -0,0 +1,26 @@ +module: Float +name: fromInt +docstring: Convert into a Float +parameters: + - name: a + type: int +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..80289bba --- /dev/null +++ b/yaml-files/Float.fromString.yaml @@ -0,0 +1,42 @@ +module: Float +name: fromString +docstring: Attempt to parse to a float +parameters: + - name: a + type: string +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..cf04fbb5 --- /dev/null +++ b/yaml-files/Float.hypotenuse.yaml @@ -0,0 +1,20 @@ +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 + - name: b + type: float +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..9258c2c0 --- /dev/null +++ b/yaml-files/Float.inRange.yaml @@ -0,0 +1,54 @@ +module: Float +name: inRange +docstring: Checks if is between and up to, but not including, +parameters: + - name: a + type: float + - name: lower + type: float + - name: upper + type: float +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..c118d6f3 --- /dev/null +++ b/yaml-files/Float.isFinite.yaml @@ -0,0 +1,42 @@ +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 +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..f3752682 --- /dev/null +++ b/yaml-files/Float.isInfinite.yaml @@ -0,0 +1,42 @@ +module: Float +name: isInfinite +docstring: Determine whether is positive or negative infinity. +parameters: + - name: a + type: float +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..900f06d4 --- /dev/null +++ b/yaml-files/Float.isInteger.yaml @@ -0,0 +1,22 @@ +module: Float +name: isInteger +docstring: Determine whether the is an integer. +parameters: + - name: a + type: float +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..38d12844 --- /dev/null +++ b/yaml-files/Float.isNaN.yaml @@ -0,0 +1,21 @@ +module: Float +name: isNaN +docstring: Determine whether is an [undefined] or unrepresentable number. + - name: a + type: float +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..33739afe --- /dev/null +++ b/yaml-files/Float.log.yaml @@ -0,0 +1,28 @@ +module: Float +name: log +docstring: Calculate the logarithm of with a given base +parameters: + - name: a + type: float + - name: base + type: float +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..b64c5063 --- /dev/null +++ b/yaml-files/Float.maximum.yaml @@ -0,0 +1,36 @@ +module: Float +name: maximum +docstring: Compare and , returning the highest value +parameters: + - name: a + type: float + - name: b + type: float +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..04a3adb5 --- /dev/null +++ b/yaml-files/Float.minimum.yaml @@ -0,0 +1,36 @@ +module: Float +name: minimum +docstring: Compare and , returning the lowest value +parameters: + - name: a + type: float + - name: b + type: float +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..0df1a00b --- /dev/null +++ b/yaml-files/Float.multiply.yaml @@ -0,0 +1,20 @@ +module: Float +name: multiply +docstring: Multiply by , returning their product +parameters: + - name: a + type: float + - name: b + type: float +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..cd1fcb49 --- /dev/null +++ b/yaml-files/Float.negate.yaml @@ -0,0 +1,26 @@ +module: Float +name: negate +docstring: Flips the 'sign' of +parameters: + - name: a + type: float +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..7e879c07 --- /dev/null +++ b/yaml-files/Float.power.yaml @@ -0,0 +1,28 @@ +module: Float +name: power +docstring: Raise to the power of , returning the power +parameters: + - name: base + type: float + - name: exponent + type: float +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..a8b4ddb0 --- /dev/null +++ b/yaml-files/Float.radians.yaml @@ -0,0 +1,18 @@ +module: Float +name: radians +docstring: Convert to radians +parameters: + - name: a + type: float +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..1d037e8f --- /dev/null +++ b/yaml-files/Float.round.yaml @@ -0,0 +1,256 @@ +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 + - name: a + type: float +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..160cbe50 --- /dev/null +++ b/yaml-files/Float.sin.yaml @@ -0,0 +1,22 @@ +module: Float +name: sin +docstring: Takes in radians and figure out its sine +parameters: + - name: a + type: radians +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..33c2134c --- /dev/null +++ b/yaml-files/Float.squareRoot.yaml @@ -0,0 +1,26 @@ +module: Float +name: squareRoot +docstring: Takes and returns its square root or [NaN] when it is negative +parameters: + - name: a + type: float +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..c93e0776 --- /dev/null +++ b/yaml-files/Float.subtract.yaml @@ -0,0 +1,20 @@ +module: Float +name: subtract +docstring: Subtract from , returning their difference +parameters: + - name: a + type: float + - name: b + type: float +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..78e4faff --- /dev/null +++ b/yaml-files/Float.tan.yaml @@ -0,0 +1,26 @@ +module: Float +name: tan +docstring: Takes and figure out its tangent +parameters: + - name: a + type: radians +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..fe4e5c3b --- /dev/null +++ b/yaml-files/Float.toInt.yaml @@ -0,0 +1,42 @@ +module: Float +name: toInt +docstring: Attempt to convert into an Int +parameters: + - name: a + type: float +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..b31dd891 --- /dev/null +++ b/yaml-files/Float.truncate.yaml @@ -0,0 +1,38 @@ +module: Float +name: truncate +docstring: Takes and remove all the positions after the decimal point +parameters: + - name: a + type: float +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..d4c30185 --- /dev/null +++ b/yaml-files/Float.turns.yaml @@ -0,0 +1,18 @@ +module: Float +name: turns +docstring: Convert an angle in turns into radians +parameters: + - name: a + type: float +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 From 95285f7d4ce6b4961c7531a4165d937c58ea252b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Oct 2022 12:41:38 +0200 Subject: [PATCH 09/31] Fix functions that have a string return type --- src/newMethod.res | 25 ++++++++++++-------- test/fsharpTests/BoolTest/toStringTest.fs | 4 ++-- test/fsharpTests/IntTest/toStringTest.fs | 8 +++++++ test/ocamlTests/BoolTest/toStringTest.ml | 4 ++-- test/ocamlTests/IntTest/toStringTest.ml | 2 ++ test/rescriptTests/BoolTest/toStringTest.res | 4 ++-- test/rescriptTests/IntTest/toStringTest.res | 2 ++ 7 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 test/fsharpTests/IntTest/toStringTest.fs create mode 100644 test/ocamlTests/IntTest/toStringTest.ml create mode 100644 test/rescriptTests/IntTest/toStringTest.res diff --git a/src/newMethod.res b/src/newMethod.res index 554bf9e3..e40bdadd 100644 --- a/src/newMethod.res +++ b/src/newMethod.res @@ -19,13 +19,13 @@ type data = { name: string, parameters:array, tests: array, - returnType: int + returnType: string } @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Bool.toString.json", #utf8) +let file = readFileSync(~name="../json-files/Int.fromString.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let returnType = myData.returnType @@ -37,11 +37,16 @@ let inparr =[] let newInput=ref("") let newInputR=ref("") let newInputOF=ref("") -let output=ref(0) +let output=ref("") let length =Belt.Array.length(myData.parameters) let generate =Belt.Array.map(myData.tests, (test =>{ - output:= test.output + output:= Belt.Int.toString(test.output) + if (myData.returnType=="string"){ + output:=`"${Belt.Int.toString(test.output)}"` + }else{ + output:= Belt.Int.toString(test.output) + } if (length==1){ //param length == 1 type string if (myData.parameters[0].\"type"=="string"){ @@ -80,12 +85,12 @@ let generate =Belt.Array.map(myData.tests, (test =>{ } - let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${Belt.Int.toString(output.contents)!="exception"? `${\"module"}.${name}(${newInput.contents})) |> toEqual(${Js.String.includes("Some", Belt.Int.toString(output.contents)) || Js.String.includes("None", Belt.Int.toString(output.contents)) ? `{open Eq\n${Js.String.slice(~from=0, ~to_=6, Belt.Int.toString(returnType))}(${Js.String.replace(">", "" ,Js.String.sliceToEnd(~from=7, Belt.Int.toString(returnType)))})}`: `Eq.${Belt.Int.toString(returnType)}`}, ${Belt.Int.toString(output.contents)}))` : `() => ${\"module"}.${name}(${newInput.contents})) |> toThrow)`} \n` + let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents!="exception"? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${Belt.Int.toString(output.contents)!="exception"? `${\"module"}.${name} ${newInputOF.contents}) |> toEqual ${Js.String.includes("Some", Belt.Int.toString(output.contents)) || Js.String.includes("None", Belt.Int.toString(output.contents)) ? `(let open Eq in ${Js.String.slice(~from=0, ~to_=6, Belt.Int.toString(returnType))} ${Js.String.replace(">", "" ,Js.String.sliceToEnd(~from=7, Belt.Int.toString(returnType)))})`: `Eq.${Belt.Int.toString(returnType)}`} ${Belt.Int.toString(output.contents) == "exception"? "|> toThrow":Belt.Int.toString(output.contents)}) ; `:`fun () -> ${name} ${newInputOF.contents}) |> toThrow); `}\n` + let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents!="exception"? `${\"module"}.${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 ${Belt.Int.toString(output.contents)!="exception"? `let expected = ${Belt.Int.toString(output.contents)}\n Expect.equal expected (${\"module"}.${name} ${newInputOF.contents}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` + `testCase "${name}(${newInput.contents})" \n<| fun _ -> \n ${output.contents!="exception"? `let expected = ${output.contents}\n Expect.equal expected (${\"module"}.${name} ${newInputOF.contents}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` resultsF->Belt.Array.push(resultFSharp) })) @@ -96,6 +101,6 @@ let generate =Belt.Array.map(myData.tests, (test =>{ // %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") // %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") // %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") - Node.Fs.writeFileSync(`../test/rescriptTests/Bool/${name}Test.res`, finalresultR, #utf8) - Node.Fs.writeFileSync(`../test/ocamlTests/Bool/${name}Test.ml`, finalresultO, #utf8) - Node.Fs.writeFileSync(`../test/fsharpTests/Bool/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file + Node.Fs.writeFileSync(`../test/rescriptTests/IntTest/${name}Test.res`, finalresultR, #utf8) + Node.Fs.writeFileSync(`../test/ocamlTests/IntTest/${name}Test.ml`, finalresultO, #utf8) + Node.Fs.writeFileSync(`../test/fsharpTests/IntTest/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file diff --git a/test/fsharpTests/BoolTest/toStringTest.fs b/test/fsharpTests/BoolTest/toStringTest.fs index b4e3746f..179dc9c1 100644 --- a/test/fsharpTests/BoolTest/toStringTest.fs +++ b/test/fsharpTests/BoolTest/toStringTest.fs @@ -1,8 +1,8 @@ testCase "toString(true)" <| fun _ -> - let expected = true + let expected = "true" Expect.equal expected (Bool.toString true) "error" testCase "toString(false)" <| fun _ -> - let expected = false + let expected = "false" Expect.equal expected (Bool.toString false) "error" diff --git a/test/fsharpTests/IntTest/toStringTest.fs b/test/fsharpTests/IntTest/toStringTest.fs new file mode 100644 index 00000000..615e0209 --- /dev/null +++ b/test/fsharpTests/IntTest/toStringTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/ocamlTests/BoolTest/toStringTest.ml b/test/ocamlTests/BoolTest/toStringTest.ml index c94d7514..c92fcf06 100644 --- a/test/ocamlTests/BoolTest/toStringTest.ml +++ b/test/ocamlTests/BoolTest/toStringTest.ml @@ -1,2 +1,2 @@ -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 "toString(true)" (fun () -> expect (Bool.toString true) |> toEqual Eq.string "true") ; +test "toString(false)" (fun () -> expect (Bool.toString false) |> toEqual Eq.string "false") ; diff --git a/test/ocamlTests/IntTest/toStringTest.ml b/test/ocamlTests/IntTest/toStringTest.ml new file mode 100644 index 00000000..fc99f7ed --- /dev/null +++ b/test/ocamlTests/IntTest/toStringTest.ml @@ -0,0 +1,2 @@ +test "toString(1)" (fun () -> expect (Int.toString 1) |> toEqual Eq.string "1") ; +test "toString(-1)" (fun () -> expect (Int.toString -1) |> toEqual Eq.string "-1") ; diff --git a/test/rescriptTests/BoolTest/toStringTest.res b/test/rescriptTests/BoolTest/toStringTest.res index cdf37b1b..b83c3799 100644 --- a/test/rescriptTests/BoolTest/toStringTest.res +++ b/test/rescriptTests/BoolTest/toStringTest.res @@ -1,2 +1,2 @@ -test ("toString(true)", () => expect(Bool.toString(true)) |> toEqual(Eq.string, true)) -test ("toString(false)", () => expect(Bool.toString(false)) |> toEqual(Eq.string, false)) +test ("toString(true)", () => expect(Bool.toString(true)) |> toEqual(Eq.string, "true")) +test ("toString(false)", () => expect(Bool.toString(false)) |> toEqual(Eq.string, "false")) diff --git a/test/rescriptTests/IntTest/toStringTest.res b/test/rescriptTests/IntTest/toStringTest.res new file mode 100644 index 00000000..0bfcaf31 --- /dev/null +++ b/test/rescriptTests/IntTest/toStringTest.res @@ -0,0 +1,2 @@ +test ("toString(1)", () => expect(Int.toString(1)) |> toEqual(Eq.string, "1")) +test ("toString(-1)", () => expect(Int.toString(-1)) |> toEqual(Eq.string, "-1")) From 7eb906f29327d429502fcc56f775699509102885 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Oct 2022 21:00:14 +0200 Subject: [PATCH 10/31] Add Option, Tuple2 and Tuple3 yaml files + add support for array return type --- src/newMethod.res | 193 ++++++++++++++++++----------- yaml-files/Option.andThen.yaml | 25 ++++ yaml-files/Option.and_.yaml | 32 +++++ yaml-files/Option.both.yaml | 32 +++++ yaml-files/Option.compare.yaml | 30 +++++ yaml-files/Option.equal.yaml | 34 +++++ yaml-files/Option.flatten.yaml | 26 ++++ yaml-files/Option.isNone.yaml | 22 ++++ yaml-files/Option.isSome.yaml | 22 ++++ yaml-files/Option.map.yaml | 30 +++++ yaml-files/Option.map2.yaml | 30 +++++ yaml-files/Option.orElse.yaml | 32 +++++ yaml-files/Option.or_.yaml | 32 +++++ yaml-files/Option.toArray.yaml | 22 ++++ yaml-files/Option.toList.yaml | 22 ++++ yaml-files/Option.unwrap.yaml | 24 ++++ yaml-files/Tuple2.first.yaml | 19 +++ yaml-files/Tuple2.make.yaml | 22 ++++ yaml-files/Tuple2.mapEach.yaml | 24 ++++ yaml-files/Tuple2.mapFirst.yaml | 21 ++++ yaml-files/Tuple2.mapSecond.yaml | 21 ++++ yaml-files/Tuple2.second.yaml | 19 +++ yaml-files/Tuple2.swap.yaml | 18 +++ yaml-files/Tuple2.toArray.yaml | 18 +++ yaml-files/Tuple2.toList.yaml | 18 +++ yaml-files/Tuple3.first.yaml | 19 +++ yaml-files/Tuple3.initial.yaml | 18 +++ yaml-files/Tuple3.make.yaml | 25 ++++ yaml-files/Tuple3.mapEach.yaml | 27 ++++ yaml-files/Tuple3.mapFirst.yaml | 21 ++++ yaml-files/Tuple3.mapSecond.yaml | 21 ++++ yaml-files/Tuple3.mapThird.yaml | 21 ++++ yaml-files/Tuple3.rotateLeft.yaml | 18 +++ yaml-files/Tuple3.rotateRight.yaml | 18 +++ yaml-files/Tuple3.second.yaml | 19 +++ yaml-files/Tuple3.tail.yaml | 18 +++ yaml-files/Tuple3.third.yaml | 19 +++ yaml-files/Tuple3.toArray.yaml | 18 +++ yaml-files/Tuple3.toList.yaml | 18 +++ 39 files changed, 996 insertions(+), 72 deletions(-) create mode 100644 yaml-files/Option.andThen.yaml create mode 100644 yaml-files/Option.and_.yaml create mode 100644 yaml-files/Option.both.yaml create mode 100644 yaml-files/Option.compare.yaml create mode 100644 yaml-files/Option.equal.yaml create mode 100644 yaml-files/Option.flatten.yaml create mode 100644 yaml-files/Option.isNone.yaml create mode 100644 yaml-files/Option.isSome.yaml create mode 100644 yaml-files/Option.map.yaml create mode 100644 yaml-files/Option.map2.yaml create mode 100644 yaml-files/Option.orElse.yaml create mode 100644 yaml-files/Option.or_.yaml create mode 100644 yaml-files/Option.toArray.yaml create mode 100644 yaml-files/Option.toList.yaml create mode 100644 yaml-files/Option.unwrap.yaml create mode 100644 yaml-files/Tuple2.first.yaml create mode 100644 yaml-files/Tuple2.make.yaml create mode 100644 yaml-files/Tuple2.mapEach.yaml create mode 100644 yaml-files/Tuple2.mapFirst.yaml create mode 100644 yaml-files/Tuple2.mapSecond.yaml create mode 100644 yaml-files/Tuple2.second.yaml create mode 100644 yaml-files/Tuple2.swap.yaml create mode 100644 yaml-files/Tuple2.toArray.yaml create mode 100644 yaml-files/Tuple2.toList.yaml create mode 100644 yaml-files/Tuple3.first.yaml create mode 100644 yaml-files/Tuple3.initial.yaml create mode 100644 yaml-files/Tuple3.make.yaml create mode 100644 yaml-files/Tuple3.mapEach.yaml create mode 100644 yaml-files/Tuple3.mapFirst.yaml create mode 100644 yaml-files/Tuple3.mapSecond.yaml create mode 100644 yaml-files/Tuple3.mapThird.yaml create mode 100644 yaml-files/Tuple3.rotateLeft.yaml create mode 100644 yaml-files/Tuple3.rotateRight.yaml create mode 100644 yaml-files/Tuple3.second.yaml create mode 100644 yaml-files/Tuple3.tail.yaml create mode 100644 yaml-files/Tuple3.third.yaml create mode 100644 yaml-files/Tuple3.toArray.yaml create mode 100644 yaml-files/Tuple3.toList.yaml diff --git a/src/newMethod.res b/src/newMethod.res index e40bdadd..b0da8021 100644 --- a/src/newMethod.res +++ b/src/newMethod.res @@ -1,15 +1,12 @@ @module("fs") -external readFileSync: ( - ~name: string, - [#utf8], -) => string = "readFileSync" +external readFileSync: (~name: string, [#utf8]) => string = "readFileSync" type tests = { inputs: array, output: int, } -type parameter ={ +type parameter = { name: string, \"type": string, } @@ -17,15 +14,15 @@ type parameter ={ type data = { \"module": string, name: string, - parameters:array, + parameters: array, tests: array, - returnType: string + returnType: string, } @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Int.fromString.json", #utf8) +let file = readFileSync(~name="../json-files/Tuple3.mapAll.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let returnType = myData.returnType @@ -33,74 +30,126 @@ let \"module" = myData.\"module" let resultsR = [] let resultsF = [] let resultsO = [] -let inparr =[] -let newInput=ref("") -let newInputR=ref("") -let newInputOF=ref("") -let output=ref("") -let length =Belt.Array.length(myData.parameters) +let inparr = [] +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{ - output:= Belt.Int.toString(test.output) +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)}]` + Js.log(output) } - 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)}"` - - }else{ - //param length == 1 type array - if (Js.Array.isArray(test.inputs)){ - newInput:= `[${Js.Array.toString(test.inputs)}]` - - } - //param length == 1 type int - else{ - newInput:= Js.Array.toString(test.inputs) - newInputR:= Js.Array.toString(test.inputs) - newInputOF:= Js.Array.toString(test.inputs) - }} - } - //param length > 1 type - else{ + } + + 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)}]` + } else { + //param length == 1 type int - for i in 0 to length-1{ - //param length > 1 type array - if (Js.Array.isArray(test.inputs[i])){ - newInput:= `[${Belt.Int.toString(test.inputs[i])}]` - inparr->Belt.Array.push(newInput) - newInput:=Js_array.joinWith(",", inparr) - } - //param length > 1 type int + newInput := Js.Array.toString(test.inputs) + newInputR := Js.Array.toString(test.inputs) + newInputOF := Js.Array.toString(test.inputs) } - newInput := Js_array.joinWith(",", test.inputs) - newInputOF := Js_array.joinWith(" ", test.inputs) - newInputR := Js_array.joinWith(",", test.inputs) - -} + } else { + //param length > 1 type - let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents!="exception"? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents!="exception"? `${\"module"}.${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"}.${name} ${newInputOF.contents}) "error"` : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` - resultsF->Belt.Array.push(resultFSharp) + for i in 0 to length - 1 { + //param length > 1 type array + if Js.Array.isArray(test.inputs[i]) { + newInput := `[${Belt.Int.toString(test.inputs[i])}]` + inparr->Belt.Array.push(newInput) + newInput := Js_array.joinWith(",", inparr) + } + //param length > 1 type int + } + newInput := Js_array.joinWith(",", test.inputs) + newInputOF := Js_array.joinWith(" ", test.inputs) + newInputR := Js_array.joinWith(",", test.inputs) + } -})) + let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents != "exception" + ? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + + + + let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents != "exception" + ? `${\"module"}.${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"}.${name} ${newInputOF.contents}) "error"` + : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` + resultsF->Belt.Array.push(resultFSharp) +}) - let finalresultR = Js.Array.joinWith("",resultsR) - let finalresultF = Js.Array.joinWith("",resultsF) - let finalresultO = Js.Array.joinWith("",resultsO) - // %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") - // %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") - // %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") - Node.Fs.writeFileSync(`../test/rescriptTests/IntTest/${name}Test.res`, finalresultR, #utf8) - Node.Fs.writeFileSync(`../test/ocamlTests/IntTest/${name}Test.ml`, finalresultO, #utf8) - Node.Fs.writeFileSync(`../test/fsharpTests/IntTest/${name}Test.fs`, finalresultF, #utf8) \ No newline at end of file +let finalresultR = Js.Array.joinWith("", resultsR) +let finalresultF = Js.Array.joinWith("", resultsF) +let finalresultO = Js.Array.joinWith("", resultsO) +// %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") +// %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") +// %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") +Node.Fs.writeFileSync( + `../test/rescriptTests/Tuple2Test/${name}Test.res`, + finalresultR, + #utf8, +) +Node.Fs.writeFileSync( + `../test/ocamlTests/Tuple2Test/${name}Test.ml`, + finalresultO, + #utf8, +) +Node.Fs.writeFileSync( + `../test/fsharpTests/Tuple2Test/${name}Test.fs`, + finalresultF, + #utf8, +) diff --git a/yaml-files/Option.andThen.yaml b/yaml-files/Option.andThen.yaml new file mode 100644 index 00000000..69c2c7ff --- /dev/null +++ b/yaml-files/Option.andThen.yaml @@ -0,0 +1,25 @@ +module: Option +name: andThen +docstring: Chain together many computations that may not return a value +parameters: + - name: a + type: option<'a> + - name: f + type: 'a => option<'b> +returnType: option<'b> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: [Some(list{1, 2, 3}), List.head] + output: Some(1) + - inputs: [Some(list{}), List.head] + output: None +examples: + - inputs: [Some(list{1, 2, 3}), List.head] + output: Some(1) + - inputs: [Some(list{}), 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..285aadac --- /dev/null +++ b/yaml-files/Option.and_.yaml @@ -0,0 +1,32 @@ +module: Option +name: and_ +docstring: Returns [None] if is [None], otherwise return . +parameters: + - name: a + type: option<'a> + - name: b + type: option<'a> +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..57d08c0b --- /dev/null +++ b/yaml-files/Option.both.yaml @@ -0,0 +1,32 @@ +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> + - name: b + type: option<'b> +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..916924a3 --- /dev/null +++ b/yaml-files/Option.compare.yaml @@ -0,0 +1,30 @@ +module: Option +name: compare +docstring: Compare and using the provided [f] function +parameters: + - name: a + type: option<'a> + - name: b + type: option<'a> + - name: f + type: ('a, 'a) => int +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..655e5534 --- /dev/null +++ b/yaml-files/Option.equal.yaml @@ -0,0 +1,34 @@ +module: Option +name: equal +docstring: Test and for equality using the provided function +parameters: + - name: a + type: option<'a> + - name: b + type: option<'a> + - name: c + type: ('a, 'a) => bool +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..6e04ec84 --- /dev/null +++ b/yaml-files/Option.flatten.yaml @@ -0,0 +1,26 @@ +module: Option +name: flatten +docstring: Flatten two optional layers into a single optional layer +parameters: + - name: a + type: option> +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..68eaee81 --- /dev/null +++ b/yaml-files/Option.isNone.yaml @@ -0,0 +1,22 @@ +module: Option +name: isNone +docstring: Check if is a [None] +parameters: + - name: a + type: option<'a> +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..969a3ae4 --- /dev/null +++ b/yaml-files/Option.isSome.yaml @@ -0,0 +1,22 @@ +module: Option +name: isSome +docstring: Check if is a [Some]. +parameters: + - name: a + type: option<'a> +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..f360f8b9 --- /dev/null +++ b/yaml-files/Option.map.yaml @@ -0,0 +1,30 @@ +module: Option +name: map +docstring: Transform the value inside an option. Leaves [None] untouched. +parameters: + - name: a + type: option<'a> + - name: f + type: 'a => 'b +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..2587a74a --- /dev/null +++ b/yaml-files/Option.map2.yaml @@ -0,0 +1,30 @@ +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> + - name: b + type: option<'b> + - name: f + type: ('a, 'b) => 'c +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..b5d87b9b --- /dev/null +++ b/yaml-files/Option.orElse.yaml @@ -0,0 +1,32 @@ +module: Option +name: orElse +docstring: Return the if it {!isSome}, otherwise return +parameters: + - name: a + type: option<'a> + - name: b + type: option<'a> +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..50a12a62 --- /dev/null +++ b/yaml-files/Option.or_.yaml @@ -0,0 +1,32 @@ +module: Option +name: or_ +docstring: Return if it {!isSome}, otherwise return . +parameters: + - name: a + type: option<'a> + - name: b + type: option<'a> +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..d6085dfc --- /dev/null +++ b/yaml-files/Option.toArray.yaml @@ -0,0 +1,22 @@ +module: Option +name: toArray +docstring: Convert to an {!Array} +parameters: + - name: a + type: option<'a> +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..ff6fddc5 --- /dev/null +++ b/yaml-files/Option.toList.yaml @@ -0,0 +1,22 @@ +module: Option +name: toList +docstring: Convert to a {!List} +parameters: + - name: a + type: option<'a> +returnType: list<'a> +# For compatibility +constraints: + - no-ocaml + - no-rescript +tests: + - inputs: Some(3004) + output: list{3004} + - inputs: None + output: list{} +examples: + - inputs: Some(3004) + output: list{3004} + - inputs: None + output: list{} +added: 0.1.0 diff --git a/yaml-files/Option.unwrap.yaml b/yaml-files/Option.unwrap.yaml new file mode 100644 index 00000000..2e7329f6 --- /dev/null +++ b/yaml-files/Option.unwrap.yaml @@ -0,0 +1,24 @@ +module: Option +name: unwrap +docstring: Unwrap returning [default] if called with [None] +parameters: + - name: a + type: option<'a> + - name: default + type: \'a +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/Tuple2.first.yaml b/yaml-files/Tuple2.first.yaml new file mode 100644 index 00000000..5e0484b4 --- /dev/null +++ b/yaml-files/Tuple2.first.yaml @@ -0,0 +1,19 @@ +module: Tuple2 +name: first +docstring: Extract the first value from a tuple +parameters: + - name: a + type: ('a, 'b) +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..28ec9626 --- /dev/null +++ b/yaml-files/Tuple2.make.yaml @@ -0,0 +1,22 @@ +module: Tuple2 +name: make +docstring: Create a two-tuple with the given values +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'b +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.mapEach.yaml b/yaml-files/Tuple2.mapEach.yaml new file mode 100644 index 00000000..12e997dc --- /dev/null +++ b/yaml-files/Tuple2.mapEach.yaml @@ -0,0 +1,24 @@ +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) + - name: f + type: >- + 'a => 'x + - name: g + type: >- + 'b => 'y +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..d259cc99 --- /dev/null +++ b/yaml-files/Tuple2.mapFirst.yaml @@ -0,0 +1,21 @@ +module: Tuple2 +name: mapFirst +docstring: Transform the {!first} value in a tuple +parameters: + - name: a + type: ('a, 'b) + - name: f + type: >- + 'a => 'x +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..03d8663c --- /dev/null +++ b/yaml-files/Tuple2.mapSecond.yaml @@ -0,0 +1,21 @@ +module: Tuple2 +name: mapSecond +docstring: Transform the {!second} value in a tuple +parameters: + - name: a + type: ('a, 'b) + - name: f + type: >- + 'b => 'c +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..ce6b7ef4 --- /dev/null +++ b/yaml-files/Tuple2.second.yaml @@ -0,0 +1,19 @@ +module: Tuple2 +name: second +docstring: Extract the second value from a tuple +parameters: + - name: a + type: ('a, 'b) +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..d2fbc0fe --- /dev/null +++ b/yaml-files/Tuple2.swap.yaml @@ -0,0 +1,18 @@ +module: Tuple2 +name: swap +docstring: Switches the first and second values of a tuple +parameters: + - name: a + type: ('a, 'b) +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..51bb0c77 --- /dev/null +++ b/yaml-files/Tuple2.toArray.yaml @@ -0,0 +1,18 @@ +module: Tuple2 +name: toArray +docstring: Turns a tuple into an {!Array} of length two +parameters: + - name: a + type: ('a, 'a) +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..73ea116e --- /dev/null +++ b/yaml-files/Tuple2.toList.yaml @@ -0,0 +1,18 @@ +module: Tuple2 +name: toList +docstring: Turns a tuple into a list of length two +parameters: + - name: a + type: ('a, 'a) +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..f3268e79 --- /dev/null +++ b/yaml-files/Tuple3.first.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: first +docstring: Extract the first value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) +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..b8eb5cb9 --- /dev/null +++ b/yaml-files/Tuple3.initial.yaml @@ -0,0 +1,18 @@ +module: Tuple3 +name: initial +docstring: Extract the first and second values of a {!Tuple3} as a {!Tuple2} +parameters: + - name: a + type: ('a, 'b, 'c) +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..b283643b --- /dev/null +++ b/yaml-files/Tuple3.make.yaml @@ -0,0 +1,25 @@ +module: Tuple3 +name: make +docstring: Create a {!Tuple3} +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'b + - name: c + type: >- + 'c +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.mapEach.yaml b/yaml-files/Tuple3.mapEach.yaml new file mode 100644 index 00000000..a6cf7bee --- /dev/null +++ b/yaml-files/Tuple3.mapEach.yaml @@ -0,0 +1,27 @@ +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) + - name: f + type: >- + 'a => 'x + - name: g + type: >- + 'b => 'y + - name: h + type: >- + 'c => 'z +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..d5f45658 --- /dev/null +++ b/yaml-files/Tuple3.mapFirst.yaml @@ -0,0 +1,21 @@ +module: Tuple3 +name: mapFirst +docstring: Transform the {!first} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + - name: f + type: >- + 'a => 'x +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..60b165c7 --- /dev/null +++ b/yaml-files/Tuple3.mapSecond.yaml @@ -0,0 +1,21 @@ +module: Tuple3 +name: mapSecond +docstring: Transform the {!second} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + - name: f + type: >- + 'b => 'y +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..e9995ff7 --- /dev/null +++ b/yaml-files/Tuple3.mapThird.yaml @@ -0,0 +1,21 @@ +module: Tuple3 +name: mapThird +docstring: Transform the {!third} value in a tuple +parameters: + - name: a + type: ('a, 'b, 'c) + - name: f + type: >- + 'c => 'z +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..2887a0ff --- /dev/null +++ b/yaml-files/Tuple3.rotateLeft.yaml @@ -0,0 +1,18 @@ +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) +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..2c268dab --- /dev/null +++ b/yaml-files/Tuple3.rotateRight.yaml @@ -0,0 +1,18 @@ +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) +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..2c4e5dce --- /dev/null +++ b/yaml-files/Tuple3.second.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: second +docstring: Extract the second value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) +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..fd7ff3d1 --- /dev/null +++ b/yaml-files/Tuple3.tail.yaml @@ -0,0 +1,18 @@ +module: Tuple3 +name: tail +docstring: Extract the second and third values of a {!Tuple3} as a {!Tuple2} +parameters: + - name: a + type: ('a, 'b, 'c) +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..d2f2116a --- /dev/null +++ b/yaml-files/Tuple3.third.yaml @@ -0,0 +1,19 @@ +module: Tuple3 +name: third +docstring: Extract the third value from a tuple +parameters: + - name: a + type: ('a, 'b, 'c) +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..045aa3fe --- /dev/null +++ b/yaml-files/Tuple3.toArray.yaml @@ -0,0 +1,18 @@ +module: Tuple3 +name: toArray +docstring: Turns a tuple into an {!Array} of length three +parameters: + - name: a + type: ('a, 'a, 'a) +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..786e2332 --- /dev/null +++ b/yaml-files/Tuple3.toList.yaml @@ -0,0 +1,18 @@ +module: Tuple3 +name: toList +docstring: Turns a tuple into a list of length three +parameters: + - name: a + type: ('a, 'a, 'a) +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 From b67ba1763beb71fd5d8c41145b43ab459bbe7ee8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 30 Oct 2022 13:00:29 +0100 Subject: [PATCH 11/31] Add FunTest yaml files --- yaml-files/Fun.apply.yaml | 23 +++++++++++++++++++++++ yaml-files/Fun.compose..yaml | 26 ++++++++++++++++++++++++++ yaml-files/Fun.composeRight.yaml | 26 ++++++++++++++++++++++++++ yaml-files/Fun.constant.yaml | 23 +++++++++++++++++++++++ yaml-files/Fun.curry.yaml | 25 +++++++++++++++++++++++++ yaml-files/Fun.curry3.yaml | 28 ++++++++++++++++++++++++++++ yaml-files/Fun.flip.yaml | 25 +++++++++++++++++++++++++ yaml-files/Fun.identity.yaml | 20 ++++++++++++++++++++ yaml-files/Fun.ignore.yaml | 18 ++++++++++++++++++ yaml-files/Fun.negate.yaml | 22 ++++++++++++++++++++++ yaml-files/Fun.sequence.yaml | 23 +++++++++++++++++++++++ yaml-files/Fun.uncurry.yaml | 21 +++++++++++++++++++++ yaml-files/Fun.uncurry3.yaml | 21 +++++++++++++++++++++ 13 files changed, 301 insertions(+) create mode 100644 yaml-files/Fun.apply.yaml create mode 100644 yaml-files/Fun.compose..yaml create mode 100644 yaml-files/Fun.composeRight.yaml create mode 100644 yaml-files/Fun.constant.yaml create mode 100644 yaml-files/Fun.curry.yaml create mode 100644 yaml-files/Fun.curry3.yaml create mode 100644 yaml-files/Fun.flip.yaml create mode 100644 yaml-files/Fun.identity.yaml create mode 100644 yaml-files/Fun.ignore.yaml create mode 100644 yaml-files/Fun.negate.yaml create mode 100644 yaml-files/Fun.sequence.yaml create mode 100644 yaml-files/Fun.uncurry.yaml create mode 100644 yaml-files/Fun.uncurry3.yaml diff --git a/yaml-files/Fun.apply.yaml b/yaml-files/Fun.apply.yaml new file mode 100644 index 00000000..bf7dc8d5 --- /dev/null +++ b/yaml-files/Fun.apply.yaml @@ -0,0 +1,23 @@ +module: Fun +name: apply +docstring: Calls function [f] with an argument [x] +parameters: + - name: a + type: >- + 'a => 'b + - name: b + type: >- + 'a +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..4465d15b --- /dev/null +++ b/yaml-files/Fun.compose..yaml @@ -0,0 +1,26 @@ +module: Fun +name: compose +docstring: Function composition, passing result from left to right +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'a => 'b + - name: c + type: >- + 'b => 'c +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..0550ebbb --- /dev/null +++ b/yaml-files/Fun.composeRight.yaml @@ -0,0 +1,26 @@ +module: Fun +name: compose +docstring: Function composition, passing result from right to left +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'b => 'c + - name: c + type: >- + 'a => 'b +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..7c3a3a30 --- /dev/null +++ b/yaml-files/Fun.constant.yaml @@ -0,0 +1,23 @@ +module: Fun +name: constant +docstring: Create a function that {b always} returns the same value +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'b +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..57e3b31e --- /dev/null +++ b/yaml-files/Fun.curry.yaml @@ -0,0 +1,25 @@ +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 + - name: b + type: >- + 'a + - name: c + type: >- + 'b +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..edea54a2 --- /dev/null +++ b/yaml-files/Fun.curry3.yaml @@ -0,0 +1,28 @@ +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 + - name: b + type: >- + 'a + - name: c + type: >- + 'b + - name: d + type: >- + 'c +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..1496e51b --- /dev/null +++ b/yaml-files/Fun.flip.yaml @@ -0,0 +1,25 @@ +module: Fun +name: flip +docstring: Reverses the argument order of a function +parameters: + - name: f + type: ('a, 'b) => 'c + - name: a + type: >- + 'b + - name: b + type: >- + 'a +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..2a6940ff --- /dev/null +++ b/yaml-files/Fun.identity.yaml @@ -0,0 +1,20 @@ +module: Fun +name: identity +docstring: Given a value, returns exactly the same value +parameters: + - name: a + type: >- + 'a +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..a8fd9374 --- /dev/null +++ b/yaml-files/Fun.ignore.yaml @@ -0,0 +1,18 @@ +module: Fun +name: ignore +docstring: Discards the value it is given and returns [()] +parameters: + - name: a + type: _ +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..02ff7134 --- /dev/null +++ b/yaml-files/Fun.negate.yaml @@ -0,0 +1,22 @@ +module: Fun +name: negate +docstring: Negate a function +parameters: + - name: a + type: >- + 'a => bool + - name: b + type: >- + 'a +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..57d3c0f9 --- /dev/null +++ b/yaml-files/Fun.sequence.yaml @@ -0,0 +1,23 @@ +module: Fun +name: sequence +docstring: Create a function which always returns its second argument +parameters: + - name: a + type: >- + 'a + - name: b + type: >- + 'b +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..dc0a1b4a --- /dev/null +++ b/yaml-files/Fun.uncurry.yaml @@ -0,0 +1,21 @@ +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 + - name: b + type: ('a, 'b) +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..b8420842 --- /dev/null +++ b/yaml-files/Fun.uncurry3.yaml @@ -0,0 +1,21 @@ +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 + - name: b + type: ('a, 'b, 'c) +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 From 6ce6fcaf6449f000c6ec6f3d09353b66bab5be27 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 30 Oct 2022 21:13:31 +0100 Subject: [PATCH 12/31] Add some of ArrayTest's functions yaml files --- yaml-files/Array.filter.yaml | 20 +++++++++++ yaml-files/Array.find.yaml | 29 ++++++++++++++++ yaml-files/Array.findIndex.yaml | 28 ++++++++++++++++ yaml-files/Array.first.yaml | 22 +++++++++++++ yaml-files/Array.get.yaml | 37 +++++++++++++++++++++ yaml-files/Array.getAt.yaml | 28 ++++++++++++++++ yaml-files/Array.initialize.yaml | 28 ++++++++++++++++ yaml-files/Array.isEmpty.yaml | 22 +++++++++++++ yaml-files/Array.join.yaml | 24 ++++++++++++++ yaml-files/Array.last.yaml | 22 +++++++++++++ yaml-files/Array.length.yaml | 26 +++++++++++++++ yaml-files/Array.map.yaml | 21 ++++++++++++ yaml-files/Array.map2.yaml | 26 +++++++++++++++ yaml-files/Array.map3.yaml | 53 ++++++++++++++++++++++++++++++ yaml-files/Array.mapWithIndex.yaml | 20 +++++++++++ yaml-files/Array.partition.yaml | 21 ++++++++++++ yaml-files/Array.range.yaml | 36 ++++++++++++++++++++ yaml-files/Array.repeat.yaml | 32 ++++++++++++++++++ yaml-files/Array.singleton.yaml | 23 +++++++++++++ yaml-files/Array.sliding.yaml | 46 ++++++++++++++++++++++++++ yaml-files/Array.splitAt.yaml | 24 ++++++++++++++ yaml-files/Array.splitWhen.yaml | 33 +++++++++++++++++++ 22 files changed, 621 insertions(+) create mode 100644 yaml-files/Array.filter.yaml create mode 100644 yaml-files/Array.find.yaml create mode 100644 yaml-files/Array.findIndex.yaml create mode 100644 yaml-files/Array.first.yaml create mode 100644 yaml-files/Array.get.yaml create mode 100644 yaml-files/Array.getAt.yaml create mode 100644 yaml-files/Array.initialize.yaml create mode 100644 yaml-files/Array.isEmpty.yaml create mode 100644 yaml-files/Array.join.yaml create mode 100644 yaml-files/Array.last.yaml create mode 100644 yaml-files/Array.length.yaml create mode 100644 yaml-files/Array.map.yaml create mode 100644 yaml-files/Array.map2.yaml create mode 100644 yaml-files/Array.map3.yaml create mode 100644 yaml-files/Array.mapWithIndex.yaml create mode 100644 yaml-files/Array.partition.yaml create mode 100644 yaml-files/Array.range.yaml create mode 100644 yaml-files/Array.repeat.yaml create mode 100644 yaml-files/Array.singleton.yaml create mode 100644 yaml-files/Array.sliding.yaml create mode 100644 yaml-files/Array.splitAt.yaml create mode 100644 yaml-files/Array.splitWhen.yaml diff --git a/yaml-files/Array.filter.yaml b/yaml-files/Array.filter.yaml new file mode 100644 index 00000000..1fadd8db --- /dev/null +++ b/yaml-files/Array.filter.yaml @@ -0,0 +1,20 @@ +module: Array +name: filter +docstring: Keep elements where function [f] will return [true] +parameters: + - name: a + type: array<'a> + - name: f + type: (int, 'a) => 'b +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..85691c15 --- /dev/null +++ b/yaml-files/Array.find.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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..f11d7f9a --- /dev/null +++ b/yaml-files/Array.findIndex.yaml @@ -0,0 +1,28 @@ +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> + - name: f + type: (int, 'a) => bool +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..8538286c --- /dev/null +++ b/yaml-files/Array.first.yaml @@ -0,0 +1,22 @@ +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> +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.get.yaml b/yaml-files/Array.get.yaml new file mode 100644 index 00000000..290238cc --- /dev/null +++ b/yaml-files/Array.get.yaml @@ -0,0 +1,37 @@ +module: Array +name: get +docstring: Get the element at the specified index. +parameters: + - name: a + type: array<'a> + - name: b + type: int +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..914a7b76 --- /dev/null +++ b/yaml-files/Array.getAt.yaml @@ -0,0 +1,28 @@ +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> + - name: index + type: int +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.initialize.yaml b/yaml-files/Array.initialize.yaml new file mode 100644 index 00000000..45303b71 --- /dev/null +++ b/yaml-files/Array.initialize.yaml @@ -0,0 +1,28 @@ +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 + - name: f + type: int => 'a +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.isEmpty.yaml b/yaml-files/Array.isEmpty.yaml new file mode 100644 index 00000000..13c75c21 --- /dev/null +++ b/yaml-files/Array.isEmpty.yaml @@ -0,0 +1,22 @@ +module: Array +name: isEmpty +docstring: Check if an array is empty +parameters: + - name: a + type: array<'a> +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..fe4541a4 --- /dev/null +++ b/yaml-files/Array.join.yaml @@ -0,0 +1,24 @@ +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 + - name: sep + type: string +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..6fbd09fd --- /dev/null +++ b/yaml-files/Array.last.yaml @@ -0,0 +1,22 @@ +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> +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..360545a3 --- /dev/null +++ b/yaml-files/Array.length.yaml @@ -0,0 +1,26 @@ +module: Array +name: length +docstring: Return the length of an array +parameters: + - name: a + type: array<'a> +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..d311c1f7 --- /dev/null +++ b/yaml-files/Array.map.yaml @@ -0,0 +1,21 @@ +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> + - name: f + type: >- + 'a => 'b +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..51f4093d --- /dev/null +++ b/yaml-files/Array.map2.yaml @@ -0,0 +1,26 @@ +module: Array +name: map2 +docstring: Combine two arrays, using [f] to combine each pair of elements +parameters: + - name: a + type: array<'a> + - name: b + type: array<'b> + - name: f + type: ('a, 'b) => 'c +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..e9ffddfe --- /dev/null +++ b/yaml-files/Array.map3.yaml @@ -0,0 +1,53 @@ +module: Array +name: map3 +docstring: Combine three arrays, using [f] to combine each trio of elements +parameters: + - name: a + type: array<'a> + - name: b + type: array<'b> + - name: c + type: array<'c> + - name: f + type: ('a, 'b, 'c) => 'd +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..e1dcc65f --- /dev/null +++ b/yaml-files/Array.mapWithIndex.yaml @@ -0,0 +1,20 @@ +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> + - name: f + type: (int, 'a) => 'b +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.partition.yaml b/yaml-files/Array.partition.yaml new file mode 100644 index 00000000..c3ef4468 --- /dev/null +++ b/yaml-files/Array.partition.yaml @@ -0,0 +1,21 @@ +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> + - name: f + type: >- + 'a => bool +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..193a02aa --- /dev/null +++ b/yaml-files/Array.range.yaml @@ -0,0 +1,36 @@ +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 + - name: to + type: int +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..b61d7a3d --- /dev/null +++ b/yaml-files/Array.repeat.yaml @@ -0,0 +1,32 @@ +module: Array +name: repeat +docstring: Create an array of length with the value of populated at each index. +parameters: + - name: a + type: \'a + - name: length + type: int +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.singleton.yaml b/yaml-files/Array.singleton.yaml new file mode 100644 index 00000000..2e86f7ab --- /dev/null +++ b/yaml-files/Array.singleton.yaml @@ -0,0 +1,23 @@ +module: Array +name: singleton +docstring: Create an array with only one element +parameters: + - name: a + type: >- + 'a +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..636d9c00 --- /dev/null +++ b/yaml-files/Array.sliding.yaml @@ -0,0 +1,46 @@ +module: Array +name: sliding +docstring: Provides a sliding 'window' of sub-arrays over an array +parameters: + - name: a + type: array<'a> + - name: size + type: int + - name: step + type: int=? +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.splitAt.yaml b/yaml-files/Array.splitAt.yaml new file mode 100644 index 00000000..0d14a9b3 --- /dev/null +++ b/yaml-files/Array.splitAt.yaml @@ -0,0 +1,24 @@ +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> + - name: index + type: int +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..79d94d48 --- /dev/null +++ b/yaml-files/Array.splitWhen.yaml @@ -0,0 +1,33 @@ +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> + - name: f + type: >- + 'a => bool +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 From 757940bfbc19032769bdaad05e7ecf54d89a9556 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2022 00:10:46 +0100 Subject: [PATCH 13/31] Add more ArrayTest's functions yaml files --- yaml-files/Array.all.yaml | 29 +++++++++++++++++++++++++++++ yaml-files/Array.any.yaml | 29 +++++++++++++++++++++++++++++ yaml-files/Array.append.yaml | 20 ++++++++++++++++++++ yaml-files/Array.count.yaml | 29 +++++++++++++++++++++++++++++ yaml-files/Array.extent.yaml | 28 ++++++++++++++++++++++++++++ yaml-files/Array.flatten.yaml | 18 ++++++++++++++++++ yaml-files/Array.includes.yaml | 31 +++++++++++++++++++++++++++++++ yaml-files/Array.maximum.yaml | 24 ++++++++++++++++++++++++ yaml-files/Array.minimum.yaml | 24 ++++++++++++++++++++++++ yaml-files/Array.unzip.yaml | 18 ++++++++++++++++++ yaml-files/Array.zip.yaml | 24 ++++++++++++++++++++++++ 11 files changed, 274 insertions(+) create mode 100644 yaml-files/Array.all.yaml create mode 100644 yaml-files/Array.any.yaml create mode 100644 yaml-files/Array.append.yaml create mode 100644 yaml-files/Array.count.yaml create mode 100644 yaml-files/Array.extent.yaml create mode 100644 yaml-files/Array.flatten.yaml create mode 100644 yaml-files/Array.includes.yaml create mode 100644 yaml-files/Array.maximum.yaml create mode 100644 yaml-files/Array.minimum.yaml create mode 100644 yaml-files/Array.unzip.yaml create mode 100644 yaml-files/Array.zip.yaml diff --git a/yaml-files/Array.all.yaml b/yaml-files/Array.all.yaml new file mode 100644 index 00000000..46c61174 --- /dev/null +++ b/yaml-files/Array.all.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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..7821ebf4 --- /dev/null +++ b/yaml-files/Array.any.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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..dee7c873 --- /dev/null +++ b/yaml-files/Array.append.yaml @@ -0,0 +1,20 @@ +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> + - name: b + type: array<'a> +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.count.yaml b/yaml-files/Array.count.yaml new file mode 100644 index 00000000..2404d8f5 --- /dev/null +++ b/yaml-files/Array.count.yaml @@ -0,0 +1,29 @@ +module: Array +name: count +docstring: Count the number of elements which function [f] will return [true] +parameters: + - name: a + type: array<'a> + - name: f + type: >- + 'a => bool +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..e42010f0 --- /dev/null +++ b/yaml-files/Array.extent.yaml @@ -0,0 +1,28 @@ +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> + - name: compare + type: ('a, 'a) => int +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.flatten.yaml b/yaml-files/Array.flatten.yaml new file mode 100644 index 00000000..d6514f37 --- /dev/null +++ b/yaml-files/Array.flatten.yaml @@ -0,0 +1,18 @@ +module: Array +name: flatten +docstring: Flatten an array of arrays into a single array +parameters: + - name: a + type: array> +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.includes.yaml b/yaml-files/Array.includes.yaml new file mode 100644 index 00000000..17e71c9f --- /dev/null +++ b/yaml-files/Array.includes.yaml @@ -0,0 +1,31 @@ +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> + - name: b + type: >- + 'a + - name: equal + type: ('a, 'a) => bool +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.maximum.yaml b/yaml-files/Array.maximum.yaml new file mode 100644 index 00000000..f67d5160 --- /dev/null +++ b/yaml-files/Array.maximum.yaml @@ -0,0 +1,24 @@ +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> + - name: compare + type: ('a, 'a) => int +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..5a955dbe --- /dev/null +++ b/yaml-files/Array.minimum.yaml @@ -0,0 +1,24 @@ +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> + - name: compare + type: ('a, 'a) => int +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.unzip.yaml b/yaml-files/Array.unzip.yaml new file mode 100644 index 00000000..dbed2639 --- /dev/null +++ b/yaml-files/Array.unzip.yaml @@ -0,0 +1,18 @@ +module: Array +name: zip +docstring: Decompose an array of {!Tuple2}s into a {!Tuple2} of arrays +parameters: + - name: a + type: array<('a, 'b)> +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.zip.yaml b/yaml-files/Array.zip.yaml new file mode 100644 index 00000000..b49af9ed --- /dev/null +++ b/yaml-files/Array.zip.yaml @@ -0,0 +1,24 @@ +module: Array +name: zip +docstring: Combine two arrays by merging each pair of elements into a {!Tuple2} +parameters: + - name: a + type: array<'a> + - name: b + type: array<'b> +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 From 7b6e9a6ccd4302ac94abd7cc318e8467d3655b03 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2022 11:04:24 +0100 Subject: [PATCH 14/31] Add more ArrayTest's functions yaml files --- yaml-files/Array.chunksOf.yaml | 28 ++++++++++++++++++++++++++++ yaml-files/Array.compare.yaml | 30 ++++++++++++++++++++++++++++++ yaml-files/Array.intersperse.yaml | 25 +++++++++++++++++++++++++ yaml-files/Array.values.yaml | 22 ++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 yaml-files/Array.chunksOf.yaml create mode 100644 yaml-files/Array.compare.yaml create mode 100644 yaml-files/Array.intersperse.yaml create mode 100644 yaml-files/Array.values.yaml diff --git a/yaml-files/Array.chunksOf.yaml b/yaml-files/Array.chunksOf.yaml new file mode 100644 index 00000000..877ca709 --- /dev/null +++ b/yaml-files/Array.chunksOf.yaml @@ -0,0 +1,28 @@ +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> + - name: size + type: int +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.compare.yaml b/yaml-files/Array.compare.yaml new file mode 100644 index 00000000..af9bece3 --- /dev/null +++ b/yaml-files/Array.compare.yaml @@ -0,0 +1,30 @@ +module: Array +name: compare +docstring: Compare two arrays using the provided [f] function to compare pairs of elements +parameters: + - name: a + type: array<'a> + - name: b + type: array<'a> + - name: f + type: ('a, 'a) => int +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.intersperse.yaml b/yaml-files/Array.intersperse.yaml new file mode 100644 index 00000000..f5adedae --- /dev/null +++ b/yaml-files/Array.intersperse.yaml @@ -0,0 +1,25 @@ +module: Array +name: intersperse +docstring: Places [sep] between all the elements of the given array +parameters: + - name: a + type: array<'a> + - name: sep + type: >- + 'a +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.values.yaml b/yaml-files/Array.values.yaml new file mode 100644 index 00000000..bdbce914 --- /dev/null +++ b/yaml-files/Array.values.yaml @@ -0,0 +1,22 @@ +module: Array +name: values +docstring: Return all of the [Some] values from an array of options +parameters: + - name: a + type: array> +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 From addba119804f7a282c09de25f76204f52a06ab65 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2022 14:43:32 +0100 Subject: [PATCH 15/31] Add StringTest's functions yaml files --- yaml-files/String.fromArray.yaml | 30 +++++++++++++++++++++ yaml-files/String.fromChar.yaml | 38 ++++++++++++++++++++++++++ yaml-files/String.indexOf.yaml | 32 ++++++++++++++++++++++ yaml-files/String.indexOfRight.yaml | 28 +++++++++++++++++++ yaml-files/String.initialize.yaml | 28 +++++++++++++++++++ yaml-files/String.insertAt.yaml | 42 +++++++++++++++++++++++++++++ yaml-files/String.isEmpty.yaml | 30 +++++++++++++++++++++ yaml-files/String.length.yaml | 22 +++++++++++++++ yaml-files/String.repeat.yaml | 28 +++++++++++++++++++ yaml-files/String.reverse.yaml | 22 +++++++++++++++ yaml-files/String.toArray.yaml | 20 ++++++++++++++ 11 files changed, 320 insertions(+) create mode 100644 yaml-files/String.fromArray.yaml create mode 100644 yaml-files/String.fromChar.yaml create mode 100644 yaml-files/String.indexOf.yaml create mode 100644 yaml-files/String.indexOfRight.yaml create mode 100644 yaml-files/String.initialize.yaml create mode 100644 yaml-files/String.insertAt.yaml create mode 100644 yaml-files/String.isEmpty.yaml create mode 100644 yaml-files/String.length.yaml create mode 100644 yaml-files/String.repeat.yaml create mode 100644 yaml-files/String.reverse.yaml create mode 100644 yaml-files/String.toArray.yaml diff --git a/yaml-files/String.fromArray.yaml b/yaml-files/String.fromArray.yaml new file mode 100644 index 00000000..3780a983 --- /dev/null +++ b/yaml-files/String.fromArray.yaml @@ -0,0 +1,30 @@ +module: String +name: fromArray +docstring: Create a string from an {!Array} of characters +parameters: + - name: a + type: array +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..b774fa67 --- /dev/null +++ b/yaml-files/String.fromChar.yaml @@ -0,0 +1,38 @@ +module: String +name: fromChar +docstring: Converts the to an equivalent string of length one +parameters: + - name: a + type: char +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.indexOf.yaml b/yaml-files/String.indexOf.yaml new file mode 100644 index 00000000..8c576249 --- /dev/null +++ b/yaml-files/String.indexOf.yaml @@ -0,0 +1,32 @@ +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 + - name: b + type: string +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..76fbdfed --- /dev/null +++ b/yaml-files/String.indexOfRight.yaml @@ -0,0 +1,28 @@ +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 + - name: b + type: string +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..dd45e629 --- /dev/null +++ b/yaml-files/String.initialize.yaml @@ -0,0 +1,28 @@ +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 + - name: f + type: int => char +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..00ca52b0 --- /dev/null +++ b/yaml-files/String.insertAt.yaml @@ -0,0 +1,42 @@ +module: String +name: insertAt +docstring: Insert a string at [index] +parameters: + - name: a + type: string + - name: index + type: int + - name: value + type: string +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..f4689eda --- /dev/null +++ b/yaml-files/String.isEmpty.yaml @@ -0,0 +1,30 @@ +module: String +name: isEmpty +docstring: Check if a string is empty +parameters: + - name: a + type: string +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..0293020a --- /dev/null +++ b/yaml-files/String.length.yaml @@ -0,0 +1,22 @@ +module: String +name: length +docstring: Returns the length of the given string +parameters: + - name: a + type: string +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..cbec8af1 --- /dev/null +++ b/yaml-files/String.repeat.yaml @@ -0,0 +1,28 @@ +module: String +name: repeat +docstring: Create a string by repeating a string [count] time +parameters: + - name: a + type: string + - name: count + type: int +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..d1427440 --- /dev/null +++ b/yaml-files/String.reverse.yaml @@ -0,0 +1,22 @@ +module: String +name: reverse +docstring: Reverse a string +parameters: + - name: a + type: string +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.toArray.yaml b/yaml-files/String.toArray.yaml new file mode 100644 index 00000000..a8e239f0 --- /dev/null +++ b/yaml-files/String.toArray.yaml @@ -0,0 +1,20 @@ +module: String +name: toArray +docstring: Returns an {!Array} of the individual characters in the given string +parameters: + - name: a + type: string +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 From e6c2ed41833e4238015f4502531169a986a53d5a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2022 17:05:28 +0100 Subject: [PATCH 16/31] Add CharTest's functions yaml files --- yaml-files/Char.fromCode.yaml | 26 ++++++++++ yaml-files/Char.fromString.yaml | 26 ++++++++++ yaml-files/Char.isAlphanumeric.yaml | 26 ++++++++++ yaml-files/Char.isDigit.yaml | 80 +++++++++++++++++++++++++++++ yaml-files/Char.isLetter.yaml | 50 ++++++++++++++++++ yaml-files/Char.isLowercase.yaml | 32 ++++++++++++ yaml-files/Char.isPrintable.yaml | 24 +++++++++ yaml-files/Char.isUppercase.yaml | 32 ++++++++++++ yaml-files/Char.isWhitespace.yaml | 26 ++++++++++ yaml-files/Char.toCode.yaml | 20 ++++++++ yaml-files/Char.toDigit.yaml | 32 ++++++++++++ yaml-files/Char.toLowercase.yaml | 46 +++++++++++++++++ yaml-files/Char.toString.yaml | 20 ++++++++ yaml-files/Char.toUppercase.yaml | 46 +++++++++++++++++ 14 files changed, 486 insertions(+) create mode 100644 yaml-files/Char.fromCode.yaml create mode 100644 yaml-files/Char.fromString.yaml create mode 100644 yaml-files/Char.isAlphanumeric.yaml create mode 100644 yaml-files/Char.isDigit.yaml create mode 100644 yaml-files/Char.isLetter.yaml create mode 100644 yaml-files/Char.isLowercase.yaml create mode 100644 yaml-files/Char.isPrintable.yaml create mode 100644 yaml-files/Char.isUppercase.yaml create mode 100644 yaml-files/Char.isWhitespace.yaml create mode 100644 yaml-files/Char.toCode.yaml create mode 100644 yaml-files/Char.toDigit.yaml create mode 100644 yaml-files/Char.toLowercase.yaml create mode 100644 yaml-files/Char.toString.yaml create mode 100644 yaml-files/Char.toUppercase.yaml diff --git a/yaml-files/Char.fromCode.yaml b/yaml-files/Char.fromCode.yaml new file mode 100644 index 00000000..830e9aaa --- /dev/null +++ b/yaml-files/Char.fromCode.yaml @@ -0,0 +1,26 @@ +module: Char +name: fromCode +docstring: Convert an ASCII code point to a character +parameters: + - name: a + type: int +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..293f5ae8 --- /dev/null +++ b/yaml-files/Char.fromString.yaml @@ -0,0 +1,26 @@ +module: Char +name: fromString +docstring: Converts a string to character +parameters: + - name: a + type: string +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..4c642f46 --- /dev/null +++ b/yaml-files/Char.isAlphanumeric.yaml @@ -0,0 +1,26 @@ +module: Char +name: isAlphanumeric +docstring: Detect upper case, lower case and digit ASCII characters +parameters: + - name: a + type: char +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..5298af88 --- /dev/null +++ b/yaml-files/Char.isDigit.yaml @@ -0,0 +1,80 @@ +module: Char +name: isDigit +docstring: Detect when a character is a number +parameters: + - name: a + type: char +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..4a265945 --- /dev/null +++ b/yaml-files/Char.isLetter.yaml @@ -0,0 +1,50 @@ +module: Char +name: isLetter +docstring: Detect upper and lower case ASCII alphabetic characters. +parameters: + - name: a + type: char +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..63f2fb64 --- /dev/null +++ b/yaml-files/Char.isLowercase.yaml @@ -0,0 +1,32 @@ +module: Char +name: isLowercase +docstring: Detect lower case ASCII characters +parameters: + - name: a + type: char +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..ffd7ce88 --- /dev/null +++ b/yaml-files/Char.isPrintable.yaml @@ -0,0 +1,24 @@ +module: Char +name: isPrintable +docstring: Detect if a character is a printable character +parameters: + - name: a + type: char +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..a7ec0c1b --- /dev/null +++ b/yaml-files/Char.isUppercase.yaml @@ -0,0 +1,32 @@ +module: Char +name: isUppercase +docstring: Detect upper case ASCII characters +parameters: + - name: a + type: char +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..ab49e6d7 --- /dev/null +++ b/yaml-files/Char.isWhitespace.yaml @@ -0,0 +1,26 @@ +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 +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..90874551 --- /dev/null +++ b/yaml-files/Char.toCode.yaml @@ -0,0 +1,20 @@ +module: Char +name: toCode +docstring: Convert to the corresponding ASCII code point +parameters: + - name: a + type: char +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..c9443a5d --- /dev/null +++ b/yaml-files/Char.toDigit.yaml @@ -0,0 +1,32 @@ +module: Char +name: toDigit +docstring: Converts a digit character to its corresponding {!Int} +parameters: + - name: a + type: char +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..9349f19f --- /dev/null +++ b/yaml-files/Char.toLowercase.yaml @@ -0,0 +1,46 @@ +module: Char +name: toLowercase +docstring: Converts an ASCII character to lower case, preserving non alphabetic ASCII characters +parameters: + - name: a + type: char +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..9f1711e2 --- /dev/null +++ b/yaml-files/Char.toString.yaml @@ -0,0 +1,20 @@ +module: Char +name: toString +docstring: Convert to a [string] +parameters: + - name: a + type: char +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..8d07941a --- /dev/null +++ b/yaml-files/Char.toUppercase.yaml @@ -0,0 +1,46 @@ +module: Char +name: toUppercase +docstring: Converts an ASCII character to upper case, preserving non alphabetic ASCII characters +parameters: + - name: a + type: char +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 From fa590e7decb28d7acf62521bb57706c965dda39b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Oct 2022 22:39:43 +0100 Subject: [PATCH 17/31] Add CharTest's functions test files --- src/newMethod.res | 24 +++++++--- test/fsharpTests/CharTest/fromCodeTest.fs | 12 +++++ test/fsharpTests/CharTest/fromStringTest.fs | 12 +++++ .../CharTest/isAlphanumericTest.fs | 8 ++++ test/fsharpTests/CharTest/isDigitTest.fs | 44 +++++++++++++++++++ test/fsharpTests/CharTest/isLetterTest.fs | 24 ++++++++++ test/fsharpTests/CharTest/isLowercaseTest.fs | 12 +++++ test/fsharpTests/CharTest/isPrintableTest.fs | 8 ++++ test/fsharpTests/CharTest/isUppercaseTest.fs | 12 +++++ test/fsharpTests/CharTest/isWhitespaceTest.fs | 8 ++++ test/fsharpTests/CharTest/toCodeTest.fs | 4 ++ test/fsharpTests/CharTest/toDigitTest.fs | 12 +++++ test/fsharpTests/CharTest/toLowercaseTest.fs | 16 +++++++ test/fsharpTests/CharTest/toStringTest.fs | 4 ++ test/fsharpTests/CharTest/toUppercaseTest.fs | 16 +++++++ test/ocamlTests/CharTest/fromCodeTest.ml | 3 ++ test/ocamlTests/CharTest/fromStringTest.ml | 3 ++ .../ocamlTests/CharTest/isAlphanumericTest.ml | 2 + test/ocamlTests/CharTest/isDigitTest.ml | 11 +++++ test/ocamlTests/CharTest/isLetterTest.ml | 6 +++ test/ocamlTests/CharTest/isLowercaseTest.ml | 3 ++ test/ocamlTests/CharTest/isPrintableTest.ml | 2 + test/ocamlTests/CharTest/isUppercaseTest.ml | 3 ++ test/ocamlTests/CharTest/isWhitespaceTest.ml | 2 + test/ocamlTests/CharTest/toCodeTest.ml | 1 + test/ocamlTests/CharTest/toDigitTest.ml | 3 ++ test/ocamlTests/CharTest/toLowercaseTest.ml | 4 ++ test/ocamlTests/CharTest/toStringTest.ml | 1 + test/ocamlTests/CharTest/toUppercaseTest.ml | 4 ++ test/rescriptTests/CharTest/fromCodeTest.res | 6 +++ .../rescriptTests/CharTest/fromStringTest.res | 6 +++ .../CharTest/isAlphanumericTest.res | 3 ++ test/rescriptTests/CharTest/isDigitTest.res | 12 +++++ test/rescriptTests/CharTest/isLetterTest.res | 6 +++ .../CharTest/isLowercaseTest.res | 3 ++ .../CharTest/isPrintableTest.res | 3 ++ .../CharTest/isUppercaseTest.res | 3 ++ .../CharTest/isWhitespaceTest.res | 2 + test/rescriptTests/CharTest/toCodeTest.res | 1 + test/rescriptTests/CharTest/toDigitTest.res | 6 +++ .../CharTest/toLowercaseTest.res | 4 ++ test/rescriptTests/CharTest/toStringTest.res | 1 + .../CharTest/toUppercaseTest.res | 4 ++ 43 files changed, 317 insertions(+), 7 deletions(-) create mode 100644 test/fsharpTests/CharTest/fromCodeTest.fs create mode 100644 test/fsharpTests/CharTest/fromStringTest.fs create mode 100644 test/fsharpTests/CharTest/isAlphanumericTest.fs create mode 100644 test/fsharpTests/CharTest/isDigitTest.fs create mode 100644 test/fsharpTests/CharTest/isLetterTest.fs create mode 100644 test/fsharpTests/CharTest/isLowercaseTest.fs create mode 100644 test/fsharpTests/CharTest/isPrintableTest.fs create mode 100644 test/fsharpTests/CharTest/isUppercaseTest.fs create mode 100644 test/fsharpTests/CharTest/isWhitespaceTest.fs create mode 100644 test/fsharpTests/CharTest/toCodeTest.fs create mode 100644 test/fsharpTests/CharTest/toDigitTest.fs create mode 100644 test/fsharpTests/CharTest/toLowercaseTest.fs create mode 100644 test/fsharpTests/CharTest/toStringTest.fs create mode 100644 test/fsharpTests/CharTest/toUppercaseTest.fs create mode 100644 test/ocamlTests/CharTest/fromCodeTest.ml create mode 100644 test/ocamlTests/CharTest/fromStringTest.ml create mode 100644 test/ocamlTests/CharTest/isAlphanumericTest.ml create mode 100644 test/ocamlTests/CharTest/isDigitTest.ml create mode 100644 test/ocamlTests/CharTest/isLetterTest.ml create mode 100644 test/ocamlTests/CharTest/isLowercaseTest.ml create mode 100644 test/ocamlTests/CharTest/isPrintableTest.ml create mode 100644 test/ocamlTests/CharTest/isUppercaseTest.ml create mode 100644 test/ocamlTests/CharTest/isWhitespaceTest.ml create mode 100644 test/ocamlTests/CharTest/toCodeTest.ml create mode 100644 test/ocamlTests/CharTest/toDigitTest.ml create mode 100644 test/ocamlTests/CharTest/toLowercaseTest.ml create mode 100644 test/ocamlTests/CharTest/toStringTest.ml create mode 100644 test/ocamlTests/CharTest/toUppercaseTest.ml create mode 100644 test/rescriptTests/CharTest/fromCodeTest.res create mode 100644 test/rescriptTests/CharTest/fromStringTest.res create mode 100644 test/rescriptTests/CharTest/isAlphanumericTest.res create mode 100644 test/rescriptTests/CharTest/isDigitTest.res create mode 100644 test/rescriptTests/CharTest/isLetterTest.res create mode 100644 test/rescriptTests/CharTest/isLowercaseTest.res create mode 100644 test/rescriptTests/CharTest/isPrintableTest.res create mode 100644 test/rescriptTests/CharTest/isUppercaseTest.res create mode 100644 test/rescriptTests/CharTest/isWhitespaceTest.res create mode 100644 test/rescriptTests/CharTest/toCodeTest.res create mode 100644 test/rescriptTests/CharTest/toDigitTest.res create mode 100644 test/rescriptTests/CharTest/toLowercaseTest.res create mode 100644 test/rescriptTests/CharTest/toStringTest.res create mode 100644 test/rescriptTests/CharTest/toUppercaseTest.res diff --git a/src/newMethod.res b/src/newMethod.res index b0da8021..58e0ebbc 100644 --- a/src/newMethod.res +++ b/src/newMethod.res @@ -22,7 +22,7 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Tuple3.mapAll.json", #utf8) +let file = readFileSync(~name="../json-files/Char.toUppercase.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let returnType = myData.returnType @@ -44,7 +44,7 @@ let generate = Belt.Array.map(myData.tests, test => { } else { if Js.String.includes("array", myData.returnType){ output := `[${Belt.Int.toString(test.output)}]` - Js.log(output) + //TODO: add a different output for ocaml and f# ([||]) } } @@ -57,6 +57,7 @@ let generate = Belt.Array.map(myData.tests, test => { } //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 type int @@ -65,7 +66,6 @@ let generate = Belt.Array.map(myData.tests, test => { newInputOF := Js.Array.toString(test.inputs) } } else { - //param length > 1 type for i in 0 to length - 1 { //param length > 1 type array @@ -74,8 +74,18 @@ let generate = Belt.Array.map(myData.tests, test => { inparr->Belt.Array.push(newInput) newInput := Js_array.joinWith(",", inparr) } - //param length > 1 type int } + + //param length > 1 type string + for i in 0 to length - 1 { + if myData.parameters[i].\"type" == "string" { + newInput := `"${Js.Array.toString(test.inputs)}"` + inparr->Belt.Array.push(newInput) + newInput := Js_array.joinWith(",", inparr) + } + } + + //param length > 1 type int newInput := Js_array.joinWith(",", test.inputs) newInputOF := Js_array.joinWith(" ", test.inputs) newInputR := Js_array.joinWith(",", test.inputs) @@ -139,17 +149,17 @@ let finalresultO = Js.Array.joinWith("", resultsO) // %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") // %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") Node.Fs.writeFileSync( - `../test/rescriptTests/Tuple2Test/${name}Test.res`, + `../test/rescriptTests/CharTest/${name}Test.res`, finalresultR, #utf8, ) Node.Fs.writeFileSync( - `../test/ocamlTests/Tuple2Test/${name}Test.ml`, + `../test/ocamlTests/CharTest/${name}Test.ml`, finalresultO, #utf8, ) Node.Fs.writeFileSync( - `../test/fsharpTests/Tuple2Test/${name}Test.fs`, + `../test/fsharpTests/CharTest/${name}Test.fs`, finalresultF, #utf8, ) diff --git a/test/fsharpTests/CharTest/fromCodeTest.fs b/test/fsharpTests/CharTest/fromCodeTest.fs new file mode 100644 index 00000000..e98bcdd9 --- /dev/null +++ b/test/fsharpTests/CharTest/fromCodeTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/CharTest/fromStringTest.fs b/test/fsharpTests/CharTest/fromStringTest.fs new file mode 100644 index 00000000..be259a53 --- /dev/null +++ b/test/fsharpTests/CharTest/fromStringTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/CharTest/isAlphanumericTest.fs b/test/fsharpTests/CharTest/isAlphanumericTest.fs new file mode 100644 index 00000000..781ec02a --- /dev/null +++ b/test/fsharpTests/CharTest/isAlphanumericTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/fsharpTests/CharTest/isDigitTest.fs b/test/fsharpTests/CharTest/isDigitTest.fs new file mode 100644 index 00000000..6ce7ca7a --- /dev/null +++ b/test/fsharpTests/CharTest/isDigitTest.fs @@ -0,0 +1,44 @@ +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" diff --git a/test/fsharpTests/CharTest/isLetterTest.fs b/test/fsharpTests/CharTest/isLetterTest.fs new file mode 100644 index 00000000..7325c539 --- /dev/null +++ b/test/fsharpTests/CharTest/isLetterTest.fs @@ -0,0 +1,24 @@ +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" diff --git a/test/fsharpTests/CharTest/isLowercaseTest.fs b/test/fsharpTests/CharTest/isLowercaseTest.fs new file mode 100644 index 00000000..dd11a502 --- /dev/null +++ b/test/fsharpTests/CharTest/isLowercaseTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/CharTest/isPrintableTest.fs b/test/fsharpTests/CharTest/isPrintableTest.fs new file mode 100644 index 00000000..94a898d4 --- /dev/null +++ b/test/fsharpTests/CharTest/isPrintableTest.fs @@ -0,0 +1,8 @@ +testCase "isPrintable('~')" +<| fun _ -> + let expected = true + Expect.equal expected (Char.isPrintable '~') "error" +testCase "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" +<| fun _ -> + let expected = Some(false) + Expect.equal expected (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) "error" diff --git a/test/fsharpTests/CharTest/isUppercaseTest.fs b/test/fsharpTests/CharTest/isUppercaseTest.fs new file mode 100644 index 00000000..b46385a6 --- /dev/null +++ b/test/fsharpTests/CharTest/isUppercaseTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/CharTest/isWhitespaceTest.fs b/test/fsharpTests/CharTest/isWhitespaceTest.fs new file mode 100644 index 00000000..e1123438 --- /dev/null +++ b/test/fsharpTests/CharTest/isWhitespaceTest.fs @@ -0,0 +1,8 @@ +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" diff --git a/test/fsharpTests/CharTest/toCodeTest.fs b/test/fsharpTests/CharTest/toCodeTest.fs new file mode 100644 index 00000000..1c06c903 --- /dev/null +++ b/test/fsharpTests/CharTest/toCodeTest.fs @@ -0,0 +1,4 @@ +testCase "toCode('a')" +<| fun _ -> + let expected = 97 + Expect.equal expected (Char.toCode 'a') "error" diff --git a/test/fsharpTests/CharTest/toDigitTest.fs b/test/fsharpTests/CharTest/toDigitTest.fs new file mode 100644 index 00000000..4922c697 --- /dev/null +++ b/test/fsharpTests/CharTest/toDigitTest.fs @@ -0,0 +1,12 @@ +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" diff --git a/test/fsharpTests/CharTest/toLowercaseTest.fs b/test/fsharpTests/CharTest/toLowercaseTest.fs new file mode 100644 index 00000000..efb285c0 --- /dev/null +++ b/test/fsharpTests/CharTest/toLowercaseTest.fs @@ -0,0 +1,16 @@ +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" diff --git a/test/fsharpTests/CharTest/toStringTest.fs b/test/fsharpTests/CharTest/toStringTest.fs new file mode 100644 index 00000000..5f568646 --- /dev/null +++ b/test/fsharpTests/CharTest/toStringTest.fs @@ -0,0 +1,4 @@ +testCase "toString('a')" +<| fun _ -> + let expected = "a" + Expect.equal expected (Char.toString 'a') "error" diff --git a/test/fsharpTests/CharTest/toUppercaseTest.fs b/test/fsharpTests/CharTest/toUppercaseTest.fs new file mode 100644 index 00000000..f375c492 --- /dev/null +++ b/test/fsharpTests/CharTest/toUppercaseTest.fs @@ -0,0 +1,16 @@ +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" diff --git a/test/ocamlTests/CharTest/fromCodeTest.ml b/test/ocamlTests/CharTest/fromCodeTest.ml new file mode 100644 index 00000000..29ecd80b --- /dev/null +++ b/test/ocamlTests/CharTest/fromCodeTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/CharTest/fromStringTest.ml b/test/ocamlTests/CharTest/fromStringTest.ml new file mode 100644 index 00000000..2edd6514 --- /dev/null +++ b/test/ocamlTests/CharTest/fromStringTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/CharTest/isAlphanumericTest.ml b/test/ocamlTests/CharTest/isAlphanumericTest.ml new file mode 100644 index 00000000..786836e3 --- /dev/null +++ b/test/ocamlTests/CharTest/isAlphanumericTest.ml @@ -0,0 +1,2 @@ +test "isAlphanumeric('A')" (fun () -> expect (Char.isAlphanumeric 'A') |> toEqual Eq.bool true) ; +test "isAlphanumeric('?')" (fun () -> expect (Char.isAlphanumeric '?') |> toEqual Eq.bool false) ; diff --git a/test/ocamlTests/CharTest/isDigitTest.ml b/test/ocamlTests/CharTest/isDigitTest.ml new file mode 100644 index 00000000..c1efc307 --- /dev/null +++ b/test/ocamlTests/CharTest/isDigitTest.ml @@ -0,0 +1,11 @@ +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) ; diff --git a/test/ocamlTests/CharTest/isLetterTest.ml b/test/ocamlTests/CharTest/isLetterTest.ml new file mode 100644 index 00000000..5d6be160 --- /dev/null +++ b/test/ocamlTests/CharTest/isLetterTest.ml @@ -0,0 +1,6 @@ +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) ; diff --git a/test/ocamlTests/CharTest/isLowercaseTest.ml b/test/ocamlTests/CharTest/isLowercaseTest.ml new file mode 100644 index 00000000..99f07767 --- /dev/null +++ b/test/ocamlTests/CharTest/isLowercaseTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/CharTest/isPrintableTest.ml b/test/ocamlTests/CharTest/isPrintableTest.ml new file mode 100644 index 00000000..8abe46ed --- /dev/null +++ b/test/ocamlTests/CharTest/isPrintableTest.ml @@ -0,0 +1,2 @@ +test "isPrintable('~')" (fun () -> expect (Char.isPrintable '~') |> toEqual Eq.bool true) ; +test "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" (fun () -> expect (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) |> toEqual (let open Eq in bool ) Some(false)) ; diff --git a/test/ocamlTests/CharTest/isUppercaseTest.ml b/test/ocamlTests/CharTest/isUppercaseTest.ml new file mode 100644 index 00000000..c81af2c6 --- /dev/null +++ b/test/ocamlTests/CharTest/isUppercaseTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/CharTest/isWhitespaceTest.ml b/test/ocamlTests/CharTest/isWhitespaceTest.ml new file mode 100644 index 00000000..33ac3f2d --- /dev/null +++ b/test/ocamlTests/CharTest/isWhitespaceTest.ml @@ -0,0 +1,2 @@ +test "isWhitespace(' ')" (fun () -> expect (Char.isWhitespace ' ') |> toEqual Eq.bool true) ; +test "isWhitespace('a')" (fun () -> expect (Char.isWhitespace 'a') |> toEqual Eq.bool false) ; diff --git a/test/ocamlTests/CharTest/toCodeTest.ml b/test/ocamlTests/CharTest/toCodeTest.ml new file mode 100644 index 00000000..347c51d1 --- /dev/null +++ b/test/ocamlTests/CharTest/toCodeTest.ml @@ -0,0 +1 @@ +test "toCode('a')" (fun () -> expect (Char.toCode 'a') |> toEqual Eq.int 97) ; diff --git a/test/ocamlTests/CharTest/toDigitTest.ml b/test/ocamlTests/CharTest/toDigitTest.ml new file mode 100644 index 00000000..a0413df8 --- /dev/null +++ b/test/ocamlTests/CharTest/toDigitTest.ml @@ -0,0 +1,3 @@ +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) ; diff --git a/test/ocamlTests/CharTest/toLowercaseTest.ml b/test/ocamlTests/CharTest/toLowercaseTest.ml new file mode 100644 index 00000000..e07f04ff --- /dev/null +++ b/test/ocamlTests/CharTest/toLowercaseTest.ml @@ -0,0 +1,4 @@ +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') ; diff --git a/test/ocamlTests/CharTest/toStringTest.ml b/test/ocamlTests/CharTest/toStringTest.ml new file mode 100644 index 00000000..2a1108a9 --- /dev/null +++ b/test/ocamlTests/CharTest/toStringTest.ml @@ -0,0 +1 @@ +test "toString('a')" (fun () -> expect (Char.toString 'a') |> toEqual Eq.string "a") ; diff --git a/test/ocamlTests/CharTest/toUppercaseTest.ml b/test/ocamlTests/CharTest/toUppercaseTest.ml new file mode 100644 index 00000000..66bc2db1 --- /dev/null +++ b/test/ocamlTests/CharTest/toUppercaseTest.ml @@ -0,0 +1,4 @@ +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') ; diff --git a/test/rescriptTests/CharTest/fromCodeTest.res b/test/rescriptTests/CharTest/fromCodeTest.res new file mode 100644 index 00000000..1b26348c --- /dev/null +++ b/test/rescriptTests/CharTest/fromCodeTest.res @@ -0,0 +1,6 @@ +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)) diff --git a/test/rescriptTests/CharTest/fromStringTest.res b/test/rescriptTests/CharTest/fromStringTest.res new file mode 100644 index 00000000..daffb601 --- /dev/null +++ b/test/rescriptTests/CharTest/fromStringTest.res @@ -0,0 +1,6 @@ +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)) diff --git a/test/rescriptTests/CharTest/isAlphanumericTest.res b/test/rescriptTests/CharTest/isAlphanumericTest.res new file mode 100644 index 00000000..453028d9 --- /dev/null +++ b/test/rescriptTests/CharTest/isAlphanumericTest.res @@ -0,0 +1,3 @@ +test ("isAlphanumeric('A')", () => expect(Char.isAlphanumeric('A')) |> toEqual(Eq.bool, true)) +test ("isAlphanumeric('?')", () => expect(Char.isAlphanumeric('?')) |> toEqual(Eq.bool, false)) + diff --git a/test/rescriptTests/CharTest/isDigitTest.res b/test/rescriptTests/CharTest/isDigitTest.res new file mode 100644 index 00000000..ab1ac091 --- /dev/null +++ b/test/rescriptTests/CharTest/isDigitTest.res @@ -0,0 +1,12 @@ +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)) + diff --git a/test/rescriptTests/CharTest/isLetterTest.res b/test/rescriptTests/CharTest/isLetterTest.res new file mode 100644 index 00000000..baee0141 --- /dev/null +++ b/test/rescriptTests/CharTest/isLetterTest.res @@ -0,0 +1,6 @@ +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)) diff --git a/test/rescriptTests/CharTest/isLowercaseTest.res b/test/rescriptTests/CharTest/isLowercaseTest.res new file mode 100644 index 00000000..5ca09d57 --- /dev/null +++ b/test/rescriptTests/CharTest/isLowercaseTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/CharTest/isPrintableTest.res b/test/rescriptTests/CharTest/isPrintableTest.res new file mode 100644 index 00000000..5ef6c67d --- /dev/null +++ b/test/rescriptTests/CharTest/isPrintableTest.res @@ -0,0 +1,3 @@ +test ("isPrintable('~')", () => expect(Char.isPrintable('~')) |> toEqual(Eq.bool, true)) +test ("isPrintable(fromCode(31) |> Option.map(~f=isPrintable))", () => expect(Char.isPrintable(fromCode(31) |> Option.map(~f=isPrintable))) |> toEqual({open Eq +bool()}, Some(false))) diff --git a/test/rescriptTests/CharTest/isUppercaseTest.res b/test/rescriptTests/CharTest/isUppercaseTest.res new file mode 100644 index 00000000..4fa2a48d --- /dev/null +++ b/test/rescriptTests/CharTest/isUppercaseTest.res @@ -0,0 +1,3 @@ +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)) diff --git a/test/rescriptTests/CharTest/isWhitespaceTest.res b/test/rescriptTests/CharTest/isWhitespaceTest.res new file mode 100644 index 00000000..fb3ff619 --- /dev/null +++ b/test/rescriptTests/CharTest/isWhitespaceTest.res @@ -0,0 +1,2 @@ +test ("isWhitespace(' ')", () => expect(Char.isWhitespace(' ')) |> toEqual(Eq.bool, true)) +test ("isWhitespace('a')", () => expect(Char.isWhitespace('a')) |> toEqual(Eq.bool, false)) diff --git a/test/rescriptTests/CharTest/toCodeTest.res b/test/rescriptTests/CharTest/toCodeTest.res new file mode 100644 index 00000000..232e8a18 --- /dev/null +++ b/test/rescriptTests/CharTest/toCodeTest.res @@ -0,0 +1 @@ +test ("toCode('a')", () => expect(Char.toCode('a')) |> toEqual(Eq.int, 97)) diff --git a/test/rescriptTests/CharTest/toDigitTest.res b/test/rescriptTests/CharTest/toDigitTest.res new file mode 100644 index 00000000..f3a2fac2 --- /dev/null +++ b/test/rescriptTests/CharTest/toDigitTest.res @@ -0,0 +1,6 @@ +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)) diff --git a/test/rescriptTests/CharTest/toLowercaseTest.res b/test/rescriptTests/CharTest/toLowercaseTest.res new file mode 100644 index 00000000..47c608c8 --- /dev/null +++ b/test/rescriptTests/CharTest/toLowercaseTest.res @@ -0,0 +1,4 @@ +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')) diff --git a/test/rescriptTests/CharTest/toStringTest.res b/test/rescriptTests/CharTest/toStringTest.res new file mode 100644 index 00000000..35906376 --- /dev/null +++ b/test/rescriptTests/CharTest/toStringTest.res @@ -0,0 +1 @@ +test ("toString('a')", () => expect(Char.toString('a')) |> toEqual(Eq.string, "a")) diff --git a/test/rescriptTests/CharTest/toUppercaseTest.res b/test/rescriptTests/CharTest/toUppercaseTest.res new file mode 100644 index 00000000..6a9a540a --- /dev/null +++ b/test/rescriptTests/CharTest/toUppercaseTest.res @@ -0,0 +1,4 @@ +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')) From ab120f0cbdce1632ddef611723a9f74b98626ab5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 10:24:25 +0100 Subject: [PATCH 18/31] Add the remaining StringTest's functions yaml files --- yaml-files/String.fromList.yaml | 30 ++++++++++++++++++++++++++++++ yaml-files/String.split.yaml | 29 +++++++++++++++++++++++++++++ yaml-files/String.toList.yaml | 20 ++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 yaml-files/String.fromList.yaml create mode 100644 yaml-files/String.split.yaml create mode 100644 yaml-files/String.toList.yaml diff --git a/yaml-files/String.fromList.yaml b/yaml-files/String.fromList.yaml new file mode 100644 index 00000000..f8ebbb59 --- /dev/null +++ b/yaml-files/String.fromList.yaml @@ -0,0 +1,30 @@ +module: String +name: fromList +docstring: Create a string from a {!List} of characters +parameters: + - name: a + type: list +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.split.yaml b/yaml-files/String.split.yaml new file mode 100644 index 00000000..4c20a3f4 --- /dev/null +++ b/yaml-files/String.split.yaml @@ -0,0 +1,29 @@ +module: String +name: split +docstring: Divide a string into a list of strings, splitting whenever [on] is encountered +parameters: + - name: a + type: string + - name: >- + on + type: string +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.toList.yaml b/yaml-files/String.toList.yaml new file mode 100644 index 00000000..4fd648fd --- /dev/null +++ b/yaml-files/String.toList.yaml @@ -0,0 +1,20 @@ +module: String +name: toList +docstring: Returns a {!List} of the individual characters in the given string +parameters: + - name: a + type: string +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 From 1fe0f59fa13920dca1065461f433317aac8ecf87 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 11:34:59 +0100 Subject: [PATCH 19/31] Add more ArrayTest's functions yaml files --- yaml-files/Array.clone.yaml | 22 ++++++++++++++++++++++ yaml-files/Array.fromList.yaml | 18 ++++++++++++++++++ yaml-files/Array.reverse.yaml | 18 ++++++++++++++++++ yaml-files/Array.setAt.yaml | 27 +++++++++++++++++++++++++++ yaml-files/Array.sort.yaml | 28 ++++++++++++++++++++++++++++ yaml-files/Array.swap.yaml | 22 ++++++++++++++++++++++ yaml-files/Array.toList.yaml | 18 ++++++++++++++++++ 7 files changed, 153 insertions(+) create mode 100644 yaml-files/Array.clone.yaml create mode 100644 yaml-files/Array.fromList.yaml create mode 100644 yaml-files/Array.reverse.yaml create mode 100644 yaml-files/Array.setAt.yaml create mode 100644 yaml-files/Array.sort.yaml create mode 100644 yaml-files/Array.swap.yaml create mode 100644 yaml-files/Array.toList.yaml diff --git a/yaml-files/Array.clone.yaml b/yaml-files/Array.clone.yaml new file mode 100644 index 00000000..90b02ec2 --- /dev/null +++ b/yaml-files/Array.clone.yaml @@ -0,0 +1,22 @@ +module: Array +name: clone +docstring: Create a shallow copy of an array +parameters: + - name: a + type: array<'a> +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.fromList.yaml b/yaml-files/Array.fromList.yaml new file mode 100644 index 00000000..1dbc3456 --- /dev/null +++ b/yaml-files/Array.fromList.yaml @@ -0,0 +1,18 @@ +module: Array +name: fromList +docstring: Create an array from a {!List} +parameters: + - name: a + type: list<'a> +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.reverse.yaml b/yaml-files/Array.reverse.yaml new file mode 100644 index 00000000..55e3203a --- /dev/null +++ b/yaml-files/Array.reverse.yaml @@ -0,0 +1,18 @@ +module: Array +name: reverse +docstring: Reverses an array {b in place}, mutating the existing array +parameters: + - name: a + type: array<'a> +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..49ad8a60 --- /dev/null +++ b/yaml-files/Array.setAt.yaml @@ -0,0 +1,27 @@ +module: Array +name: setAt +docstring: Modifies an array in place, replacing the element at [index] with [value] +parameters: + - name: a + type: array<'a> + - name: index + type: int + - name: value + type: >- + 'a +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.sort.yaml b/yaml-files/Array.sort.yaml new file mode 100644 index 00000000..000af58a --- /dev/null +++ b/yaml-files/Array.sort.yaml @@ -0,0 +1,28 @@ +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> + - name: compare + type: ('a, 'a) => int +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.swap.yaml b/yaml-files/Array.swap.yaml new file mode 100644 index 00000000..6f1fa88f --- /dev/null +++ b/yaml-files/Array.swap.yaml @@ -0,0 +1,22 @@ +module: Array +name: swap +docstring: Swaps the values at the provided indicies +parameters: + - name: a + type: array<'a> + - name: b + type: int + - name: c + type: int +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.toList.yaml b/yaml-files/Array.toList.yaml new file mode 100644 index 00000000..a6f49b56 --- /dev/null +++ b/yaml-files/Array.toList.yaml @@ -0,0 +1,18 @@ +module: Array +name: toList +docstring: Create a {!List} of elements from an array +parameters: + - name: a + type: array<'a> +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 From 45d86aa85f79c1c1a8f6967373a90638a303d14c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 12:57:19 +0100 Subject: [PATCH 20/31] Minor fixes --- yaml-files/Array.toIndexedList.yaml | 22 ++++++++++++++++++++++ yaml-files/Tuple2.mapAll.yaml | 21 +++++++++++++++++++++ yaml-files/Tuple2.toArray.yaml | 4 ++-- yaml-files/Tuple2.toList.yaml | 4 ++-- yaml-files/Tuple3.mapAll.yaml | 21 +++++++++++++++++++++ yaml-files/Tuple3.toArray.yaml | 4 ++-- yaml-files/Tuple3.toList.yaml | 4 ++-- 7 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 yaml-files/Array.toIndexedList.yaml create mode 100644 yaml-files/Tuple2.mapAll.yaml create mode 100644 yaml-files/Tuple3.mapAll.yaml diff --git a/yaml-files/Array.toIndexedList.yaml b/yaml-files/Array.toIndexedList.yaml new file mode 100644 index 00000000..d34a8a44 --- /dev/null +++ b/yaml-files/Array.toIndexedList.yaml @@ -0,0 +1,22 @@ +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> +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/Tuple2.mapAll.yaml b/yaml-files/Tuple2.mapAll.yaml new file mode 100644 index 00000000..9c642831 --- /dev/null +++ b/yaml-files/Tuple2.mapAll.yaml @@ -0,0 +1,21 @@ +module: Tuple2 +name: mapAll +docstring: Transform both of the values of a tuple using the same function +parameters: + - name: a + type: ('a, 'a) + - name: f + type: >- + 'a => 'b +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.toArray.yaml b/yaml-files/Tuple2.toArray.yaml index 51bb0c77..f21bd93f 100644 --- a/yaml-files/Tuple2.toArray.yaml +++ b/yaml-files/Tuple2.toArray.yaml @@ -11,8 +11,8 @@ constraints: - no-rescript tests: - inputs: (3, 4) - output: [[3, 4]] + output: [3, 4] examples: - inputs: (3, 4) - output: [[3, 4]] + output: [3, 4] added: 0.1.0 diff --git a/yaml-files/Tuple2.toList.yaml b/yaml-files/Tuple2.toList.yaml index 73ea116e..2cb0a8b1 100644 --- a/yaml-files/Tuple2.toList.yaml +++ b/yaml-files/Tuple2.toList.yaml @@ -11,8 +11,8 @@ constraints: - no-rescript tests: - inputs: (3, 4) - output: 3, 4 + output: [3, 4] examples: - inputs: (3, 4) - output: 3, 4 + output: [3, 4] added: 0.1.0 diff --git a/yaml-files/Tuple3.mapAll.yaml b/yaml-files/Tuple3.mapAll.yaml new file mode 100644 index 00000000..595724cd --- /dev/null +++ b/yaml-files/Tuple3.mapAll.yaml @@ -0,0 +1,21 @@ +module: Tuple3 +name: mapAll +docstring: Transform both of the values of a tuple using the same function +parameters: + - name: a + type: ('a, 'a, 'a) + - name: f + type: >- + 'a => 'b +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.toArray.yaml b/yaml-files/Tuple3.toArray.yaml index 045aa3fe..c02939a7 100644 --- a/yaml-files/Tuple3.toArray.yaml +++ b/yaml-files/Tuple3.toArray.yaml @@ -11,8 +11,8 @@ constraints: - no-rescript tests: - inputs: (3, 4, 5) - output: [[3, 4, 5]] + output: [3, 4, 5] examples: - inputs: (3, 4, 5) - output: [[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 index 786e2332..7ee904fb 100644 --- a/yaml-files/Tuple3.toList.yaml +++ b/yaml-files/Tuple3.toList.yaml @@ -11,8 +11,8 @@ constraints: - no-rescript tests: - inputs: (3, 4, 5) - output: 3, 4, 5 + output: [3, 4, 5] examples: - inputs: (3, 4, 5) - output: 3, 4, 5 + output: [3, 4, 5] added: 0.1.0 From b24e445899d8d5b7d979ab064431f55aa329a887 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 19:46:26 +0100 Subject: [PATCH 21/31] Clean up code + generate tests in the same file --- src/generateTest.res | 131 ++++++++--- src/newMethod.res | 165 ------------- test/fsharpTests/BoolTest.fs | 104 +++++++++ test/fsharpTests/CharTest.fs | 192 +++++++++++++++ test/fsharpTests/IntTest.fs | 398 ++++++++++++++++++++++++++++++++ test/ocamlTests/BoolTest.ml | 26 +++ test/ocamlTests/CharTest.ml | 48 ++++ test/ocamlTests/IntTest.ml | 81 +++++++ test/rescriptTests/BoolTest.res | 37 +++ test/rescriptTests/CharTest.res | 58 +++++ test/rescriptTests/IntTest.res | 93 ++++++++ yaml-files/Int.toFloat.yaml | 18 +- 12 files changed, 1154 insertions(+), 197 deletions(-) delete mode 100644 src/newMethod.res create mode 100644 test/fsharpTests/BoolTest.fs create mode 100644 test/fsharpTests/CharTest.fs create mode 100644 test/fsharpTests/IntTest.fs create mode 100644 test/ocamlTests/BoolTest.ml create mode 100644 test/ocamlTests/CharTest.ml create mode 100644 test/ocamlTests/IntTest.ml create mode 100644 test/rescriptTests/BoolTest.res create mode 100644 test/rescriptTests/CharTest.res create mode 100644 test/rescriptTests/IntTest.res diff --git a/src/generateTest.res b/src/generateTest.res index b42ef5de..62e7a06a 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -1,16 +1,12 @@ - @module("fs") -external readFileSync: ( - ~name: string, - [#utf8], -) => string = "readFileSync" +external readFileSync: (~name: string, [#utf8]) => string = "readFileSync" type tests = { inputs: array, output: int, } -type parameter ={ +type parameter = { name: string, \"type": string, } @@ -18,42 +14,125 @@ type parameter ={ type data = { \"module": string, name: string, - parameters:array, + parameters: array, tests: array, + returnType: string, } @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Int.subtract.json", #utf8) +let file = readFileSync(~name="../json-files/Bool.xor.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name +let returnType = myData.returnType let \"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) -for i in 0 to Belt.Array.length(myData.tests)-1{ - let test = myData.tests[i]; - let inputs = test.inputs - let output = test.output - let resultRescript = `test ("${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})", () => expect(${Belt.Int.toString(output)!="exception"? `${\"module"}.${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toEqual(Eq.int, ${Belt.Int.toString(output)}))` : `() => ${\"module"}.${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - let resultOcaml = `test "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" (fun () -> expect (${Belt.Int.toString(output)!="exception"? `${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toEqual Eq.int ${Belt.Int.toString(output) == "exception"? "|> toThrow":Belt.Int.toString(output)}) ; `:`fun () -> ${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> toThrow); `}\n` - resultsO->Belt.Array.push(resultOcaml) - let resultFSharp = - `testCase "${name}(${Js.Array.isArray(inputs)?Js.Array.joinWith(",",inputs): Js.Array.toString(inputs)})" \n<| fun _ -> \n ${Belt.Int.toString(output)!="exception"? `let expected = ${Belt.Int.toString(output)}\n Expect.equal expected (${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) "error"` : `Expect.equal (${\"module"}.${name} ${Js.Array.isArray(inputs)?Js.Array.joinWith(" ",inputs): Js.Array.toString(inputs)}) |> failwith "error"`}\n` - resultsF->Belt.Array.push(resultFSharp) +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# ([||]) + } -} - let finalresultR = Js.Array.joinWith("",resultsR) - let finalresultF = Js.Array.joinWith("",resultsF) - let finalresultO = Js.Array.joinWith("",resultsO) - %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") - %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") - %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") + 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 type int + newInput := Js.Array.toString(test.inputs) + newInputR := Js.Array.toString(test.inputs) + newInputOF := Js.Array.toString(test.inputs) + } + } else { + //param length > 1 type int + newInput := Js_array.joinWith(",", test.inputs) + newInputOF := Js_array.joinWith(" ", test.inputs) + newInputR := Js_array.joinWith(",", test.inputs) + } + let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents != "exception" + ? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` + resultsR->Belt.Array.push(resultRescript) + let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents != "exception" + ? `${\"module"}.${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"}.${name} ${newInputOF.contents}) "error"` + : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` + resultsF->Belt.Array.push(resultFSharp) +}) +let finalresultR = Js.Array.joinWith("", resultsR) +let finalresultF = Js.Array.joinWith("", resultsF) +let finalresultO = Js.Array.joinWith("", resultsO) +%raw("Fs.appendFileSync(`../test/rescriptTests/BoolTest.res`, finalresultR, 'utf8')") +%raw("Fs.appendFileSync(`../test/ocamlTests/BoolTest.ml`, finalresultO, 'utf8')") +%raw("Fs.appendFileSync(`../test/fsharpTests/BoolTest.fs`, finalresultF, 'utf8')") +// Node.Fs.writeFileSync( +// `../test/rescriptTests/CharTest/${name}Test.res`, +// finalresultR, +// #utf8, +// ) +// Node.Fs.writeFileSync( +// `../test/ocamlTests/CharTest/${name}Test.ml`, +// finalresultO, +// #utf8, +// ) +// Node.Fs.writeFileSync( +// `../test/fsharpTests/CharTest/${name}Test.fs`, +// finalresultF, +// #utf8, +// ) diff --git a/src/newMethod.res b/src/newMethod.res deleted file mode 100644 index 58e0ebbc..00000000 --- a/src/newMethod.res +++ /dev/null @@ -1,165 +0,0 @@ -@module("fs") -external readFileSync: (~name: string, [#utf8]) => string = "readFileSync" - -type tests = { - inputs: array, - output: int, -} - -type parameter = { - name: string, - \"type": string, -} - -type data = { - \"module": string, - name: string, - parameters: array, - tests: array, - returnType: string, -} - -@scope("JSON") @val -external parseIntoMyData: string => data = "parse" - -let file = readFileSync(~name="../json-files/Char.toUppercase.json", #utf8) -let myData = parseIntoMyData(file) -let name = myData.name -let returnType = myData.returnType -let \"module" = myData.\"module" -let resultsR = [] -let resultsF = [] -let resultsO = [] -let inparr = [] -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 type int - - newInput := Js.Array.toString(test.inputs) - newInputR := Js.Array.toString(test.inputs) - newInputOF := Js.Array.toString(test.inputs) - } - } else { - - for i in 0 to length - 1 { - //param length > 1 type array - if Js.Array.isArray(test.inputs[i]) { - newInput := `[${Belt.Int.toString(test.inputs[i])}]` - inparr->Belt.Array.push(newInput) - newInput := Js_array.joinWith(",", inparr) - } - } - - //param length > 1 type string - for i in 0 to length - 1 { - if myData.parameters[i].\"type" == "string" { - newInput := `"${Js.Array.toString(test.inputs)}"` - inparr->Belt.Array.push(newInput) - newInput := Js_array.joinWith(",", inparr) - } - } - - //param length > 1 type int - newInput := Js_array.joinWith(",", test.inputs) - newInputOF := Js_array.joinWith(" ", test.inputs) - newInputR := Js_array.joinWith(",", test.inputs) - } - - let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents != "exception" - ? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) - - - - let resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents != "exception" - ? `${\"module"}.${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"}.${name} ${newInputOF.contents}) "error"` - : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` - resultsF->Belt.Array.push(resultFSharp) -}) - -let finalresultR = Js.Array.joinWith("", resultsR) -let finalresultF = Js.Array.joinWith("", resultsF) -let finalresultO = Js.Array.joinWith("", resultsO) -// %raw("Fs.appendFileSync(`../test/rescriptTests/IntTest.res`, finalresultR, 'utf8')") -// %raw("Fs.appendFileSync(`../test/ocamlTests/IntTest.ml`, finalresultO, 'utf8')") -// %raw("Fs.appendFileSync(`../test/fsharpTests/IntTest.fs`, finalresultF, 'utf8')") -Node.Fs.writeFileSync( - `../test/rescriptTests/CharTest/${name}Test.res`, - finalresultR, - #utf8, -) -Node.Fs.writeFileSync( - `../test/ocamlTests/CharTest/${name}Test.ml`, - finalresultO, - #utf8, -) -Node.Fs.writeFileSync( - `../test/fsharpTests/CharTest/${name}Test.fs`, - finalresultF, - #utf8, -) diff --git a/test/fsharpTests/BoolTest.fs b/test/fsharpTests/BoolTest.fs new file mode 100644 index 00000000..de494db4 --- /dev/null +++ b/test/fsharpTests/BoolTest.fs @@ -0,0 +1,104 @@ +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" diff --git a/test/fsharpTests/CharTest.fs b/test/fsharpTests/CharTest.fs new file mode 100644 index 00000000..1b83910a --- /dev/null +++ b/test/fsharpTests/CharTest.fs @@ -0,0 +1,192 @@ +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 "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" +<| fun _ -> + let expected = Some(false) + Expect.equal expected (Char.isPrintable fromCode(31) |> Option.map(~f=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" diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs new file mode 100644 index 00000000..bf7c3566 --- /dev/null +++ b/test/fsharpTests/IntTest.fs @@ -0,0 +1,398 @@ +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,0,8)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.clamp 5 0 8) "error" + +testCase "clamp(9,0,8)" +<| fun _ -> + let expected = 8 + Expect.equal expected (Int.clamp 9 0 8) "error" + +testCase "clamp(1,2,8)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.clamp 1 2 8) "error" + +testCase "clamp(5,-10,-5)" +<| fun _ -> + let expected = -5 + Expect.equal expected (Int.clamp 5 -10 -5) "error" + +testCase "clamp(-15,-10,-5)" +<| fun _ -> + let expected = -10 + Expect.equal expected (Int.clamp -15 -10 -5) "error" + +testCase "clamp(3,7,1)" +<| fun _ -> Expect.equal (Int.clamp 3 7 1) |> failwith "error" + +testCase "divideFloat(3,2)" +<| fun _ -> + let expected = 1.5 + Expect.equal expected (Int.divideFloat 3 2) "error" + +testCase "divideFloat(27,5)" +<| fun _ -> + let expected = 5.4 + Expect.equal expected (Int.divideFloat 27 5) "error" + +testCase "divideFloat(8,4)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.divideFloat 8 4) "error" + +testCase "divideFloat(8,0)" +<| fun _ -> + let expected = Float.infinity + Expect.equal expected (Int.divideFloat 8 0) "error" + +testCase "divideFloat(-8,0)" +<| fun _ -> + let expected = Float.negativeInfinity + Expect.equal expected (Int.divideFloat -8 0) "error" + +testCase "divide(3,2)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.divide 3 2) "error" + +testCase "divide(3,0)" +<| fun _ -> Expect.equal (Int.divide 3 0) |> failwith "error" + +testCase "divide(27,5)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.divide 27 5) "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,2,4)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange 3 2 4) "error" + +testCase "inRange(8,2,4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 8 2 4) "error" + +testCase "inRange(1,2,4)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 1 2 4) "error" + +testCase "inRange(2,1,2)" +<| fun _ -> + let expected = false + Expect.equal expected (Int.inRange 2 1 2) "error" + +testCase "inRange(-6,-7,-5)" +<| fun _ -> + let expected = true + Expect.equal expected (Int.inRange -6 -7 -5) "error" + +testCase "inRange(3,7,1)" +<| fun _ -> Expect.equal (Int.inRange 3 7 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,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -4 3) "error" + +testCase "modulo(-3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo -3 3) "error" + +testCase "modulo(-2,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo -2 3) "error" + +testCase "modulo(-1,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo -1 3) "error" + +testCase "modulo(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 0 3) "error" + +testCase "modulo(1,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 1 3) "error" + +testCase "modulo(2,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.modulo 2 3) "error" + +testCase "modulo(3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.modulo 3 3) "error" + +testCase "modulo(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.modulo 4 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(7,3)" +<| fun _ -> + let expected = 343 + Expect.equal expected (Int.power 7 3) "error" + +testCase "power(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.power 0 3) "error" + +testCase "power(7,0)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.power 7 0) "error" + +testCase "remainder(-4,3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -4 3) "error" + +testCase "remainder(-2,3)" +<| fun _ -> + let expected = -2 + Expect.equal expected (Int.remainder -2 3) "error" + +testCase "remainder(-1,3)" +<| fun _ -> + let expected = -1 + Expect.equal expected (Int.remainder -1 3) "error" + +testCase "remainder(0,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 0 3) "error" + +testCase "remainder(1,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 1 3) "error" + +testCase "remainder(2,3)" +<| fun _ -> + let expected = 2 + Expect.equal expected (Int.remainder 2 3) "error" + +testCase "remainder(3,3)" +<| fun _ -> + let expected = 0 + Expect.equal expected (Int.remainder 3 3) "error" + +testCase "remainder(4,3)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.remainder 4 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(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" diff --git a/test/ocamlTests/BoolTest.ml b/test/ocamlTests/BoolTest.ml new file mode 100644 index 00000000..95657d4a --- /dev/null +++ b/test/ocamlTests/BoolTest.ml @@ -0,0 +1,26 @@ +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) ; diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml new file mode 100644 index 00000000..32ba1854 --- /dev/null +++ b/test/ocamlTests/CharTest.ml @@ -0,0 +1,48 @@ +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 "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" (fun () -> expect (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) |> toEqual (let open Eq in bool ) Some(false)) ; +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') ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml new file mode 100644 index 00000000..eeae2805 --- /dev/null +++ b/test/ocamlTests/IntTest.ml @@ -0,0 +1,81 @@ +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,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; +test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; +test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; +test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; +test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; +test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); +test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.float 1.5) ; +test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.float 5.4) ; +test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.float 2) ; +test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.float Float.infinity) ; +test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.float Float.negativeInfinity) ; +test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; +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,2,4)" (fun () -> expect (Int.inRange 3 2 4) |> toEqual Eq.bool true) ; +test "inRange(8,2,4)" (fun () -> expect (Int.inRange 8 2 4) |> toEqual Eq.bool false) ; +test "inRange(1,2,4)" (fun () -> expect (Int.inRange 1 2 4) |> toEqual Eq.bool false) ; +test "inRange(2,1,2)" (fun () -> expect (Int.inRange 2 1 2) |> toEqual Eq.bool false) ; +test "inRange(-6,-7,-5)" (fun () -> expect (Int.inRange -6 -7 -5) |> toEqual Eq.bool true) ; +test "inRange(3,7,1)" (fun () -> expect (fun () -> inRange 3 7 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,3)" (fun () -> expect (Int.modulo -4 3) |> toEqual Eq.int 2) ; +test "modulo(-3,3)" (fun () -> expect (Int.modulo -3 3) |> toEqual Eq.int 0) ; +test "modulo(-2,3)" (fun () -> expect (Int.modulo -2 3) |> toEqual Eq.int 1) ; +test "modulo(-1,3)" (fun () -> expect (Int.modulo -1 3) |> toEqual Eq.int 2) ; +test "modulo(0,3)" (fun () -> expect (Int.modulo 0 3) |> toEqual Eq.int 0) ; +test "modulo(1,3)" (fun () -> expect (Int.modulo 1 3) |> toEqual Eq.int 1) ; +test "modulo(2,3)" (fun () -> expect (Int.modulo 2 3) |> toEqual Eq.int 2) ; +test "modulo(3,3)" (fun () -> expect (Int.modulo 3 3) |> toEqual Eq.int 0) ; +test "modulo(4,3)" (fun () -> expect (Int.modulo 4 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(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; +test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; +test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; +test "remainder(-4,3)" (fun () -> expect (Int.remainder -4 3) |> toEqual Eq.int -1) ; +test "remainder(-2,3)" (fun () -> expect (Int.remainder -2 3) |> toEqual Eq.int -2) ; +test "remainder(-1,3)" (fun () -> expect (Int.remainder -1 3) |> toEqual Eq.int -1) ; +test "remainder(0,3)" (fun () -> expect (Int.remainder 0 3) |> toEqual Eq.int 0) ; +test "remainder(1,3)" (fun () -> expect (Int.remainder 1 3) |> toEqual Eq.int 1) ; +test "remainder(2,3)" (fun () -> expect (Int.remainder 2 3) |> toEqual Eq.int 2) ; +test "remainder(3,3)" (fun () -> expect (Int.remainder 3 3) |> toEqual Eq.int 0) ; +test "remainder(4,3)" (fun () -> expect (Int.remainder 4 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(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") ; diff --git a/test/rescriptTests/BoolTest.res b/test/rescriptTests/BoolTest.res new file mode 100644 index 00000000..7f2cf745 --- /dev/null +++ b/test/rescriptTests/BoolTest.res @@ -0,0 +1,37 @@ +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)) diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res new file mode 100644 index 00000000..3d253b85 --- /dev/null +++ b/test/rescriptTests/CharTest.res @@ -0,0 +1,58 @@ +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 ("isPrintable(fromCode(31) |> Option.map(~f=isPrintable))", () => expect(Char.isPrintable(fromCode(31) |> Option.map(~f=isPrintable))) |> toEqual({open Eq +bool()}, Some(false))) +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')) diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res new file mode 100644 index 00000000..e6392ff0 --- /dev/null +++ b/test/rescriptTests/IntTest.res @@ -0,0 +1,93 @@ +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,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) +test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) +test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) +test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) +test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) +test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) +test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.float, 1.5)) +test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.float, 5.4)) +test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.float, 2)) +test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.float, Float.infinity)) +test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.float, Float.negativeInfinity)) +test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) +test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) +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,2,4)", () => expect(Int.inRange(3,2,4)) |> toEqual(Eq.bool, true)) +test ("inRange(8,2,4)", () => expect(Int.inRange(8,2,4)) |> toEqual(Eq.bool, false)) +test ("inRange(1,2,4)", () => expect(Int.inRange(1,2,4)) |> toEqual(Eq.bool, false)) +test ("inRange(2,1,2)", () => expect(Int.inRange(2,1,2)) |> toEqual(Eq.bool, false)) +test ("inRange(-6,-7,-5)", () => expect(Int.inRange(-6,-7,-5)) |> toEqual(Eq.bool, true)) +test ("inRange(3,7,1)", () => expect(() => Int.inRange(3,7,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,3)", () => expect(Int.modulo(-4,3)) |> toEqual(Eq.int, 2)) +test ("modulo(-3,3)", () => expect(Int.modulo(-3,3)) |> toEqual(Eq.int, 0)) +test ("modulo(-2,3)", () => expect(Int.modulo(-2,3)) |> toEqual(Eq.int, 1)) +test ("modulo(-1,3)", () => expect(Int.modulo(-1,3)) |> toEqual(Eq.int, 2)) +test ("modulo(0,3)", () => expect(Int.modulo(0,3)) |> toEqual(Eq.int, 0)) +test ("modulo(1,3)", () => expect(Int.modulo(1,3)) |> toEqual(Eq.int, 1)) +test ("modulo(2,3)", () => expect(Int.modulo(2,3)) |> toEqual(Eq.int, 2)) +test ("modulo(3,3)", () => expect(Int.modulo(3,3)) |> toEqual(Eq.int, 0)) +test ("modulo(4,3)", () => expect(Int.modulo(4,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(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) +test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) +test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) +test ("remainder(-4,3)", () => expect(Int.remainder(-4,3)) |> toEqual(Eq.int, -1)) +test ("remainder(-2,3)", () => expect(Int.remainder(-2,3)) |> toEqual(Eq.int, -2)) +test ("remainder(-1,3)", () => expect(Int.remainder(-1,3)) |> toEqual(Eq.int, -1)) +test ("remainder(0,3)", () => expect(Int.remainder(0,3)) |> toEqual(Eq.int, 0)) +test ("remainder(1,3)", () => expect(Int.remainder(1,3)) |> toEqual(Eq.int, 1)) +test ("remainder(2,3)", () => expect(Int.remainder(2,3)) |> toEqual(Eq.int, 2)) +test ("remainder(3,3)", () => expect(Int.remainder(3,3)) |> toEqual(Eq.int, 0)) +test ("remainder(4,3)", () => expect(Int.remainder(4,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")) diff --git a/yaml-files/Int.toFloat.yaml b/yaml-files/Int.toFloat.yaml index aded128b..902ca1aa 100644 --- a/yaml-files/Int.toFloat.yaml +++ b/yaml-files/Int.toFloat.yaml @@ -11,16 +11,22 @@ constraints: - no-rescript tests: - inputs: 5 - output: 5. + output: >- + 5. - inputs: 0 - output: 0. + output: >- + 0. - inputs: -7 - output: -7. + output: >- + -7. examples: - inputs: 5 - output: 5. + output: >- + 5. - inputs: 0 - output: 0. + output: >- + 0. - inputs: -7 - output: -7. + output: >- + -7. added: 0.1.0 From 66d9f41ea9f206123f10b6085acf71f53e05265e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 20:18:55 +0100 Subject: [PATCH 22/31] Fix FloatTest's yaml files --- yaml-files/Float.absolute.yaml | 36 ++-- yaml-files/Float.atan.yaml | 12 +- yaml-files/Float.atan2.yaml | 36 ++-- yaml-files/Float.ceiling.yaml | 36 ++-- yaml-files/Float.clamp.yaml | 78 ++++--- yaml-files/Float.degrees.yaml | 6 +- yaml-files/Float.divide.yaml | 18 +- yaml-files/Float.floor.yaml | 36 ++-- yaml-files/Float.hypotenuse.yaml | 12 +- yaml-files/Float.inRange.yaml | 42 ++-- yaml-files/Float.isFinite.yaml | 12 +- yaml-files/Float.isInfinite.yaml | 12 +- yaml-files/Float.log.yaml | 30 ++- yaml-files/Float.maximum.yaml | 48 +++-- yaml-files/Float.minimum.yaml | 48 +++-- yaml-files/Float.multiply.yaml | 12 +- yaml-files/Float.negate.yaml | 36 ++-- yaml-files/Float.power.yaml | 36 ++-- yaml-files/Float.round.yaml | 354 ++++++++++++++++++++----------- yaml-files/Float.squareRoot.yaml | 21 +- yaml-files/Float.subtract.yaml | 12 +- yaml-files/Float.tan.yaml | 12 +- yaml-files/Float.toInt.yaml | 18 +- yaml-files/Float.truncate.yaml | 39 ++-- yaml-files/Float.turns.yaml | 6 +- 25 files changed, 672 insertions(+), 336 deletions(-) diff --git a/yaml-files/Float.absolute.yaml b/yaml-files/Float.absolute.yaml index 20c64fa7..227f4241 100644 --- a/yaml-files/Float.absolute.yaml +++ b/yaml-files/Float.absolute.yaml @@ -10,17 +10,29 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 8. - output: 8. - - inputs: -7. - output: 7. - - inputs: 0. - output: 0. + - 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. + - inputs: >- + 8. + output: >- + 8. + - inputs: >- + -7. + output: >- + 7. + - inputs: >- + 0. + output: >- + 0. added: 0.1.0 diff --git a/yaml-files/Float.atan.yaml b/yaml-files/Float.atan.yaml index 78e42e03..6a8c55c5 100644 --- a/yaml-files/Float.atan.yaml +++ b/yaml-files/Float.atan.yaml @@ -10,8 +10,10 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 0. - output: 0. + - inputs: >- + 0. + output: >- + 0. - inputs: 1. /. 1. output: 0.7853981633974483 - inputs: 1. /. -1. @@ -21,8 +23,10 @@ tests: - inputs: -1. /. 1. output: -0.7853981633974483 examples: - - inputs: 0. - output: 0. + - inputs: >- + 0. + output: >- + 0. - inputs: 1. /. 1. output: 0.7853981633974483 - inputs: 1. /. -1. diff --git a/yaml-files/Float.atan2.yaml b/yaml-files/Float.atan2.yaml index a95e0bfe..1de68cc2 100644 --- a/yaml-files/Float.atan2.yaml +++ b/yaml-files/Float.atan2.yaml @@ -12,25 +12,37 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [0., 0.] - output: 0. - - inputs: [1., 1.] + - inputs: >- + [0., 0.] + output: >- + 0. + - inputs: >- + [1., 1.] output: 0.7853981633974483 - - inputs: [1., -1.] + - inputs: >- + [1., -1.] output: 2.3561944901923449 - - inputs: [-1., -1.] + - inputs: >- + [-1., -1.] output: -2.3561944901923449 - - inputs: [-1., 1.] + - inputs: >- + [-1., 1.] output: -0.7853981633974483 examples: - - inputs: [0., 0.] - output: 0. - - inputs: [1., 1.] + - inputs: >- + [0., 0.] + output: >- + 0. + - inputs: >- + [1., 1.] output: 0.7853981633974483 - - inputs: [1., -1.] + - inputs: >- + [1., -1.] output: 2.3561944901923449 - - inputs: [-1., -1.] + - inputs: >- + [-1., -1.] output: -2.3561944901923449 - - inputs: [-1., 1.] + - inputs: >- + [-1., 1.] output: -0.7853981633974483 added: 0.1.0 diff --git a/yaml-files/Float.ceiling.yaml b/yaml-files/Float.ceiling.yaml index 322f0b01..ef0edd9a 100644 --- a/yaml-files/Float.ceiling.yaml +++ b/yaml-files/Float.ceiling.yaml @@ -11,28 +11,40 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: 2. + output: >- + 2. - inputs: 1.5 - output: 2. + output: >- + 2. - inputs: 1.8 - output: 2. + output: >- + 2. - inputs: -1.2 - output: -1. + output: >- + -1. - inputs: -1.5 - output: -1. + output: >- + -1. - inputs: -1.8 - output: -1. + output: >- + -1. examples: - inputs: 1.2 - output: 2. + output: >- + 2. - inputs: 1.5 - output: 2. + output: >- + 2. - inputs: 1.8 - output: 2. + output: >- + 2. - inputs: -1.2 - output: -1. + output: >- + -1. - inputs: -1.5 - output: -1. + output: >- + -1. - inputs: -1.8 - output: -1. + output: >- + -1. added: 0.1.0 diff --git a/yaml-files/Float.clamp.yaml b/yaml-files/Float.clamp.yaml index 43918938..3114d0e6 100644 --- a/yaml-files/Float.clamp.yaml +++ b/yaml-files/Float.clamp.yaml @@ -14,41 +14,67 @@ 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: >- + [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.] + - inputs: >- + [-6.6, nan, 0.] output: NaN - - inputs: [nan, 2., 8.] + - inputs: >- + [nan, 2., 8.] output: NaN - - inputs: [3., 7., 1.] + - 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: >- + [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.] + - inputs: >- + [-6.6, nan, 0.] output: NaN - - inputs: [nan, 2., 8.] + - inputs: >- + [nan, 2., 8.] output: NaN - - inputs: [3., 7., 1.] + - inputs: >- + [3., 7., 1.] output: exception added: 0.1.0 diff --git a/yaml-files/Float.degrees.yaml b/yaml-files/Float.degrees.yaml index ea9c1d3f..fc896f27 100644 --- a/yaml-files/Float.degrees.yaml +++ b/yaml-files/Float.degrees.yaml @@ -10,9 +10,11 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 180. + - inputs: >- + 180. output: pi examples: - - inputs: 180. + - inputs: >- + 180. output: pi added: 0.1.0 diff --git a/yaml-files/Float.divide.yaml b/yaml-files/Float.divide.yaml index 3c9dba4f..7ad606af 100644 --- a/yaml-files/Float.divide.yaml +++ b/yaml-files/Float.divide.yaml @@ -12,17 +12,23 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [3.14, 2.] + - inputs: >- + [3.14, 2.] output: 1.57 - - inputs: [3.14, 0.] + - inputs: >- + [3.14, 0.] output: infinity - - inputs: [3.14, -0.] + - inputs: >- + [3.14, -0.] output: negativeInfinity examples: - - inputs: [3.14, 2.] + - inputs: >- + [3.14, 2.] output: 1.57 - - inputs: [3.14, 0.] + - inputs: >- + [3.14, 0.] output: infinity - - inputs: [3.14, -0.] + - inputs: >- + [3.14, -0.] output: negativeInfinity added: 0.1.0 diff --git a/yaml-files/Float.floor.yaml b/yaml-files/Float.floor.yaml index 5828aa6b..1628e43f 100644 --- a/yaml-files/Float.floor.yaml +++ b/yaml-files/Float.floor.yaml @@ -11,28 +11,40 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: 1. + output: >- + 1. - inputs: 1.5 - output: 1. + output: >- + 1. - inputs: 1.8 - output: 1. + output: >- + 1. - inputs: -1.2 - output: -2. + output: >- + -2. - inputs: -1.5 - output: -2. + output: >- + -2. - inputs: -1.8 - output: -2. + output: >- + -2. examples: - inputs: 1.2 - output: 1. + output: >- + 1. - inputs: 1.5 - output: 1. + output: >- + 1. - inputs: 1.8 - output: 1. + output: >- + 1. - inputs: -1.2 - output: -2. + output: >- + -2. - inputs: -1.5 - output: -2. + output: >- + -2. - inputs: -1.8 - output: -2. + output: >- + -2. added: 0.1.0 diff --git a/yaml-files/Float.hypotenuse.yaml b/yaml-files/Float.hypotenuse.yaml index cf04fbb5..e39eed74 100644 --- a/yaml-files/Float.hypotenuse.yaml +++ b/yaml-files/Float.hypotenuse.yaml @@ -12,9 +12,13 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [3., 4.] - output: 5. + - inputs: >- + [3., 4.] + output: >- + 5. examples: - - inputs: [3., 4.] - output: 5. + - inputs: >- + [3., 4.] + output: >- + 5. added: 0.1.0 diff --git a/yaml-files/Float.inRange.yaml b/yaml-files/Float.inRange.yaml index 9258c2c0..48d4bb46 100644 --- a/yaml-files/Float.inRange.yaml +++ b/yaml-files/Float.inRange.yaml @@ -14,41 +14,55 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [3., 2., 4.] + - inputs: >- + [3., 2., 4.] output: true - - inputs: [8., 2., 4.] + - inputs: >- + [8., 2., 4.] output: false - - inputs: [1., 2., 4.] + - inputs: >- + [1., 2., 4.] output: false - - inputs: [2., 1., 2.] + - 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] + - inputs: >- + [-6.6, nan, 0.] output: false - - inputs: [nan, 2., 8.] + - inputs: >- + [nan, 2., 8.] output: false - - inputs: [3., 7., 1.] + - inputs: >- + [3., 7., 1.] output: exception examples: - - inputs: [3., 2., 4.] + - inputs: >- + [3., 2., 4.] output: true - - inputs: [8., 2., 4.] + - inputs: >- + [8., 2., 4.] output: false - - inputs: [1., 2., 4.] + - inputs: >- + [1., 2., 4.] output: false - - inputs: [2., 1., 2.] + - 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] + - inputs: >- + [-6.6, nan, 0.] output: false - - inputs: [nan, 2., 8.] + - inputs: >- + [nan, 2., 8.] output: false - - inputs: [3., 7., 1.] + - inputs: >- + [3., 7., 1.] output: exception added: 0.1.0 diff --git a/yaml-files/Float.isFinite.yaml b/yaml-files/Float.isFinite.yaml index c118d6f3..b47362c9 100644 --- a/yaml-files/Float.isFinite.yaml +++ b/yaml-files/Float.isFinite.yaml @@ -16,11 +16,13 @@ tests: output: false - inputs: nan output: false - - inputs: -5. + - inputs: >- + -5. output: true - inputs: -0.314 output: true - - inputs: 0. + - inputs: >- + 0. output: true - inputs: 3.14 output: true @@ -31,11 +33,13 @@ examples: output: false - inputs: nan output: false - - inputs: -5. + - inputs: >- + -5. output: true - inputs: -0.314 output: true - - inputs: 0. + - inputs: >- + 0. output: true - inputs: 3.14 output: true diff --git a/yaml-files/Float.isInfinite.yaml b/yaml-files/Float.isInfinite.yaml index f3752682..9dc264c3 100644 --- a/yaml-files/Float.isInfinite.yaml +++ b/yaml-files/Float.isInfinite.yaml @@ -16,11 +16,13 @@ tests: output: true - inputs: nan output: false - - inputs: -5. + - inputs: >- + -5. output: false - inputs: -0.314 output: false - - inputs: 0. + - inputs: >- + 0. output: false - inputs: 3.14 output: false @@ -31,11 +33,13 @@ examples: output: true - inputs: nan output: false - - inputs: -5. + - inputs: >- + -5. output: false - inputs: -0.314 output: false - - inputs: 0. + - inputs: >- + 0. output: false - inputs: 3.14 output: false diff --git a/yaml-files/Float.log.yaml b/yaml-files/Float.log.yaml index 33739afe..b6b711d5 100644 --- a/yaml-files/Float.log.yaml +++ b/yaml-files/Float.log.yaml @@ -12,17 +12,27 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [100., 10.] - output: 2. - - inputs: [256., 2.] - output: 8. - - inputs: [0., 10.] + - 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.] + - 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 index b64c5063..550ce4e1 100644 --- a/yaml-files/Float.maximum.yaml +++ b/yaml-files/Float.maximum.yaml @@ -12,25 +12,41 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [7., 9.] - output: 9. - - inputs: [-4., -1.] - output: -1. - - inputs: [7., nan] + - inputs: >- + [7., 9.] + output: >- + 9. + - inputs: >- + [-4., -1.] + output: >- + -1. + - inputs: >- + [7., nan] output: NaN - - inputs: [7., infinity] + - inputs: >- + [7., infinity] output: infinity - - inputs: [7., negativeInfinity] - output: 7. + - inputs: >- + [7., negativeInfinity] + output: >- + 7. examples: - - inputs: [7., 9.] - output: 9. - - inputs: [-4., -1.] - output: -1. - - inputs: [7., nan] + - inputs: >- + [7., 9.] + output: >- + 9. + - inputs: >- + [-4., -1.] + output: >- + -1. + - inputs: >- + [7., nan] output: NaN - - inputs: [7., infinity] + - inputs: >- + [7., infinity] output: infinity - - inputs: [7., negativeInfinity] - output: 7. + - inputs: >- + [7., negativeInfinity] + output: >- + 7. added: 0.1.0 diff --git a/yaml-files/Float.minimum.yaml b/yaml-files/Float.minimum.yaml index 04a3adb5..b1ccbff3 100644 --- a/yaml-files/Float.minimum.yaml +++ b/yaml-files/Float.minimum.yaml @@ -12,25 +12,41 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [7., 9.] - output: 7. - - inputs: [-4., -1.] - output: -4. - - inputs: [7., nan] + - inputs: >- + [7., 9.] + output: >- + 7. + - inputs: >- + [-4., -1.] + output: >- + -4. + - inputs: >- + [7., nan] output: NaN - - inputs: [7., infinity] - output: 7. - - inputs: [7., negativeInfinity] + - inputs: >- + [7., infinity] + output: >- + 7. + - inputs: >- + [7., negativeInfinity] output: negativeInfinity examples: - - inputs: [7., 9.] - output: 7. - - inputs: [-4., -1.] - output: -4. - - inputs: [7., nan] + - inputs: >- + [7., 9.] + output: >- + 7. + - inputs: >- + [-4., -1.] + output: >- + -4. + - inputs: >- + [7., nan] output: NaN - - inputs: [7., infinity] - output: 7. - - inputs: [7., negativeInfinity] + - 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 index 0df1a00b..c7529821 100644 --- a/yaml-files/Float.multiply.yaml +++ b/yaml-files/Float.multiply.yaml @@ -12,9 +12,13 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [2., 7.] - output: 14. + - inputs: >- + [2., 7.] + output: >- + 14. examples: - - inputs: [2., 7.] - output: 14. + - inputs: >- + [2., 7.] + output: >- + 14. added: 0.1.0 diff --git a/yaml-files/Float.negate.yaml b/yaml-files/Float.negate.yaml index cd1fcb49..c16b42a6 100644 --- a/yaml-files/Float.negate.yaml +++ b/yaml-files/Float.negate.yaml @@ -10,17 +10,29 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 8. - output: -8. - - inputs: -7. - output: 7. - - inputs: 0. - output: -0. + - 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. + - 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 index 7e879c07..1a368b7d 100644 --- a/yaml-files/Float.power.yaml +++ b/yaml-files/Float.power.yaml @@ -12,17 +12,29 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [7., 3.] - output: 343. - - inputs: [0., 3.] - output: 0. - - inputs: [7., 0.] - output: 1. + - 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. + - 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.round.yaml b/yaml-files/Float.round.yaml index 1d037e8f..e89ec07c 100644 --- a/yaml-files/Float.round.yaml +++ b/yaml-files/Float.round.yaml @@ -13,244 +13,362 @@ constraints: - no-rescript tests: - inputs: [#Zero, 1.2] - output: 1. + output: >- + 1. - inputs: [#Zero, 1.5] - output: 1. + output: >- + 1. - inputs: [#Zero, 1.8] - output: 1. + output: >- + 1. - inputs: [#Zero, -1.2] - output: -1. + output: >- + -1. - inputs: [#Zero, -1.5] - output: -1. + output: >- + -1. - inputs: [#Zero, -1.8] - output: -1. + output: >- + -1. - inputs: [#AwayFromZero, 1.2] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, 1.5] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, 1.8] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, -1.2] - output: -2. + output: >- + -2. - inputs: [#AwayFromZero, -1.5] - output: -2. + output: >- + -2. - inputs: [#AwayFromZero, -1.8] - output: -2. + output: >- + -2. - inputs: [#Up, 1.2] - output: 2. + output: >- + 2. - inputs: [#Up, 1.5] - output: 2. + output: >- + 2. - inputs: [#Up, 1.8] - output: 2. + output: >- + 2. - inputs: [#Up, -1.2] - output: -1. + output: >- + -1. - inputs: [#Up, -1.5] - output: -1. + output: >- + -1. - inputs: [#Up, -1.8] - output: -1. + output: >- + -1. - inputs: [#Down, 1.2] output: 1. - inputs: [#Down, 1.5] - output: 1. + output: >- + 1. - inputs: [#Down, 1.8] - output: 1. + output: >- + 1. - inputs: [#Down, -1.2] - output: -2. + output: >- + -2. - inputs: [#Down, -1.5] - output: -2. + output: >- + -2. - inputs: [#Down, -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Zero), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Zero), 1.5] - output: 1. + output: >- + 1. - inputs: [#Closest(#Zero), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Zero), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Zero), -1.5] - output: -1. + output: >- + -1. - inputs: [#Closest(#Zero), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#AwayFromZero), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#AwayFromZero), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#AwayFromZero), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#AwayFromZero), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#AwayFromZero), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#AwayFromZero), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Up), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Up), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#Up), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Up), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Up), -1.5] - output: -1. + output: >- + -1. - inputs: [#Closest(#Up), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Down), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Down), 1.5] - output: 1. + output: >- + 1. - inputs: [#Closest(#Down), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Down), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Down), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#Down), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#ToEven), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.2] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.8] - output: 3. + output: >- + 3. - inputs: [#Closest(#ToEven), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#ToEven), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.2] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.8] - output: -3. + output: >- + -3. examples: - inputs: [#Zero, 1.2] - output: 1. + output: >- + 1. - inputs: [#Zero, 1.5] - output: 1. + output: >- + 1. - inputs: [#Zero, 1.8] - output: 1. + output: >- + 1. - inputs: [#Zero, -1.2] - output: -1. + output: >- + -1. - inputs: [#Zero, -1.5] - output: -1. + output: >- + -1. - inputs: [#Zero, -1.8] - output: -1. + output: >- + -1. - inputs: [#AwayFromZero, 1.2] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, 1.5] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, 1.8] - output: 2. + output: >- + 2. - inputs: [#AwayFromZero, -1.2] - output: -2. + output: >- + -2. - inputs: [#AwayFromZero, -1.5] - output: -2. + output: >- + -2. - inputs: [#AwayFromZero, -1.8] - output: -2. + output: >- + -2. - inputs: [#Up, 1.2] - output: 2. + output: >- + 2. - inputs: [#Up, 1.5] - output: 2. + output: >- + 2. - inputs: [#Up, 1.8] - output: 2. + output: >- + 2. - inputs: [#Up, -1.2] - output: -1. + output: >- + -1. - inputs: [#Up, -1.5] - output: -1. + output: >- + -1. - inputs: [#Up, -1.8] - output: -1. + output: >- + -1. - inputs: [#Down, 1.2] output: 1. - inputs: [#Down, 1.5] - output: 1. + output: >- + 1. - inputs: [#Down, 1.8] - output: 1. + output: >- + 1. - inputs: [#Down, -1.2] - output: -2. + output: >- + -2. - inputs: [#Down, -1.5] - output: -2. + output: >- + -2. - inputs: [#Down, -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Zero), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Zero), 1.5] - output: 1. + output: >- + 1. - inputs: [#Closest(#Zero), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Zero), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Zero), -1.5] - output: -1. + output: >- + -1. - inputs: [#Closest(#Zero), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#AwayFromZero), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#AwayFromZero), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#AwayFromZero), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#AwayFromZero), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#AwayFromZero), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#AwayFromZero), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Up), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Up), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#Up), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Up), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Up), -1.5] - output: -1. + output: >- + -1. - inputs: [#Closest(#Up), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#Down), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#Down), 1.5] - output: 1. + output: >- + 1. - inputs: [#Closest(#Down), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#Down), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#Down), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#Down), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), 1.2] - output: 1. + output: >- + 1. - inputs: [#Closest(#ToEven), 1.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 1.8] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.2] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.5] - output: 2. + output: >- + 2. - inputs: [#Closest(#ToEven), 2.8] - output: 3. + output: >- + 3. - inputs: [#Closest(#ToEven), -1.2] - output: -1. + output: >- + -1. - inputs: [#Closest(#ToEven), -1.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -1.8] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.2] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.5] - output: -2. + output: >- + -2. - inputs: [#Closest(#ToEven), -2.8] - output: -3. + output: >- + -3. added: 0.1.0 diff --git a/yaml-files/Float.squareRoot.yaml b/yaml-files/Float.squareRoot.yaml index 33c2134c..b0abab00 100644 --- a/yaml-files/Float.squareRoot.yaml +++ b/yaml-files/Float.squareRoot.yaml @@ -1,4 +1,5 @@ -module: Float +>- + module: Float name: squareRoot docstring: Takes and returns its square root or [NaN] when it is negative parameters: @@ -10,17 +11,23 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 4. - output: 2. + - inputs: >- + 4. + output: >- + 2. - inputs: 20.25 output: 4.5 - - inputs: -1. + - inputs: >- + -1. output: NaN examples: - - inputs: 4. - output: 2. + - inputs: >- + 4. + output: >- + 2. - inputs: 20.25 output: 4.5 - - inputs: -1. + - inputs: >- + -1. output: NaN added: 0.1.0 diff --git a/yaml-files/Float.subtract.yaml b/yaml-files/Float.subtract.yaml index c93e0776..f566b487 100644 --- a/yaml-files/Float.subtract.yaml +++ b/yaml-files/Float.subtract.yaml @@ -12,9 +12,13 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [4., 3.] - output: 1. + - inputs: >- + [4., 3.] + output: >- + 1. examples: - - inputs: [4., 3.] - output: 1. + - inputs: >- + [4., 3.] + output: >- + 1. added: 0.1.0 diff --git a/yaml-files/Float.tan.yaml b/yaml-files/Float.tan.yaml index 78e4faff..5555ba5a 100644 --- a/yaml-files/Float.tan.yaml +++ b/yaml-files/Float.tan.yaml @@ -14,13 +14,17 @@ tests: output: 0.9999999999999999 - inputs: radians(pi /. 4.) output: 0.9999999999999999 - - inputs: 0. - output: 0. + - inputs: >- + 0. + output: >- + 0. examples: - inputs: degrees(45.) output: 0.9999999999999999 - inputs: radians(pi /. 4.) output: 0.9999999999999999 - - inputs: 0. - output: 0. + - inputs: >- + 0. + output: >- + 0. added: 0.1.0 diff --git a/yaml-files/Float.toInt.yaml b/yaml-files/Float.toInt.yaml index fe4e5c3b..52b5c1d1 100644 --- a/yaml-files/Float.toInt.yaml +++ b/yaml-files/Float.toInt.yaml @@ -10,13 +10,16 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 5. + - inputs: >- + 5. output: Some(5) - inputs: 5.3 output: Some(5) - - inputs: 0. + - inputs: >- + 0. output: Some(0) - - inputs: -7. + - inputs: >- + -7. output: Some(-7) - inputs: nan output: None @@ -25,13 +28,16 @@ tests: - inputs: negativeInfinity output: None examples: - - inputs: 5. + - inputs: >- + 5. output: Some(5) - inputs: 5.3 output: Some(5) - - inputs: 0. + - inputs: >- + 0. output: Some(0) - - inputs: -7. + - inputs: >- + -7. output: Some(-7) - inputs: nan output: None diff --git a/yaml-files/Float.truncate.yaml b/yaml-files/Float.truncate.yaml index b31dd891..a482c857 100644 --- a/yaml-files/Float.truncate.yaml +++ b/yaml-files/Float.truncate.yaml @@ -1,4 +1,5 @@ -module: Float +>- + module: Float name: truncate docstring: Takes and remove all the positions after the decimal point parameters: @@ -11,28 +12,40 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: 1. + output: >- + 1. - inputs: 1.5 - output: 1. + output: >- + 1. - inputs: 1.8 - output: 1. + output: >- + 1. - inputs: -1.2 - output: -1. + output: >- + -1. - inputs: -1.5 - output: -1. + output: >- + -1. - inputs: -1.8 - output: -1. + output: >- + -1. examples: - inputs: 1.2 - output: 1. + output: >- + 1. - inputs: 1.5 - output: 1. + output: >- + 1. - inputs: 1.8 - output: 1. + output: >- + 1. - inputs: -1.2 - output: -1. + output: >- + -1. - inputs: -1.5 - output: -1. + output: >- + -1. - inputs: -1.8 - output: -1. + output: >- + -1. added: 0.1.0 diff --git a/yaml-files/Float.turns.yaml b/yaml-files/Float.turns.yaml index d4c30185..fc012c76 100644 --- a/yaml-files/Float.turns.yaml +++ b/yaml-files/Float.turns.yaml @@ -10,9 +10,11 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 1. + - inputs: >- + 1. output: 2. *. pi examples: - - inputs: 1. + - inputs: >- + 1. output: 2. *. pi added: 0.1.0 From 9cad9a18f23cb1c1939191d4db47c6238189259e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 21:04:13 +0100 Subject: [PATCH 23/31] Fix FloatTest's yaml file + generate some Float tests --- src/generateTest.res | 8 +- test/fsharpTests/FloatTest.fs | 313 ++++++++++++++++++++++++++ test/ocamlTests/FloatTest.ml | 78 +++++++ test/rescriptTests/FloatTest.res | 92 ++++++++ yaml-files/Float.fromInt.yaml | 18 +- yaml-files/Float.isInteger.yaml | 6 +- yaml-files/Float.isNaN.yaml | 1 + yaml-files/Float.round.yaml | 362 ++++++++++++++++++++----------- yaml-files/Float.squareRoot.yaml | 3 +- yaml-files/Float.truncate.yaml | 3 +- 10 files changed, 747 insertions(+), 137 deletions(-) create mode 100644 test/fsharpTests/FloatTest.fs create mode 100644 test/ocamlTests/FloatTest.ml create mode 100644 test/rescriptTests/FloatTest.res diff --git a/src/generateTest.res b/src/generateTest.res index 62e7a06a..bc7be4ac 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -22,7 +22,7 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let file = readFileSync(~name="../json-files/Bool.xor.json", #utf8) +let file = readFileSync(~name="../json-files/Float.turns.json", #utf8) let myData = parseIntoMyData(file) let name = myData.name let returnType = myData.returnType @@ -118,9 +118,9 @@ let generate = Belt.Array.map(myData.tests, test => { let finalresultR = Js.Array.joinWith("", resultsR) let finalresultF = Js.Array.joinWith("", resultsF) let finalresultO = Js.Array.joinWith("", resultsO) -%raw("Fs.appendFileSync(`../test/rescriptTests/BoolTest.res`, finalresultR, 'utf8')") -%raw("Fs.appendFileSync(`../test/ocamlTests/BoolTest.ml`, finalresultO, 'utf8')") -%raw("Fs.appendFileSync(`../test/fsharpTests/BoolTest.fs`, finalresultF, 'utf8')") +%raw("Fs.appendFileSync(`../test/rescriptTests/FloatTest.res`, finalresultR, 'utf8')") +%raw("Fs.appendFileSync(`../test/ocamlTests/FloatTest.ml`, finalresultO, 'utf8')") +%raw("Fs.appendFileSync(`../test/fsharpTests/FloatTest.fs`, finalresultF, 'utf8')") // Node.Fs.writeFileSync( // `../test/rescriptTests/CharTest/${name}Test.res`, // finalresultR, diff --git a/test/fsharpTests/FloatTest.fs b/test/fsharpTests/FloatTest.fs new file mode 100644 index 00000000..cb387844 --- /dev/null +++ b/test/fsharpTests/FloatTest.fs @@ -0,0 +1,313 @@ +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 "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 "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 "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 "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 "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 "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 "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" diff --git a/test/ocamlTests/FloatTest.ml b/test/ocamlTests/FloatTest.ml new file mode 100644 index 00000000..81174373 --- /dev/null +++ b/test/ocamlTests/FloatTest.ml @@ -0,0 +1,78 @@ +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 "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 "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 "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 "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 "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 "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 "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) ; diff --git a/test/rescriptTests/FloatTest.res b/test/rescriptTests/FloatTest.res new file mode 100644 index 00000000..0d8332c0 --- /dev/null +++ b/test/rescriptTests/FloatTest.res @@ -0,0 +1,92 @@ +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 ("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 ("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 ("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 ("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 ("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 ("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 ("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)) diff --git a/yaml-files/Float.fromInt.yaml b/yaml-files/Float.fromInt.yaml index 992dba4f..4c15238f 100644 --- a/yaml-files/Float.fromInt.yaml +++ b/yaml-files/Float.fromInt.yaml @@ -11,16 +11,22 @@ constraints: - no-rescript tests: - inputs: 5 - output: 5.0 + output: >- + 5.0 - inputs: 0 - output: 0.0 + output: >- + 0.0 - inputs: -7 - output: -7.0 + output: >- + -7.0 examples: - inputs: 5 - output: 5.0 + output: >- + 5.0 - inputs: 0 - output: 0.0 + output: >- + 0.0 - inputs: -7 - output: -7.0 + output: >- + -7.0 added: 0.1.0 diff --git a/yaml-files/Float.isInteger.yaml b/yaml-files/Float.isInteger.yaml index 900f06d4..f1c0f1b9 100644 --- a/yaml-files/Float.isInteger.yaml +++ b/yaml-files/Float.isInteger.yaml @@ -10,12 +10,14 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: 5.0 + - inputs: >- + 5.0 output: true - inputs: pi output: false examples: - - inputs: 5.0 + - inputs: >- + 5.0 output: true - inputs: pi output: false diff --git a/yaml-files/Float.isNaN.yaml b/yaml-files/Float.isNaN.yaml index 38d12844..00e2d7a8 100644 --- a/yaml-files/Float.isNaN.yaml +++ b/yaml-files/Float.isNaN.yaml @@ -1,6 +1,7 @@ module: Float name: isNaN docstring: Determine whether is an [undefined] or unrepresentable number. +parameters: - name: a type: float returnType: bool diff --git a/yaml-files/Float.round.yaml b/yaml-files/Float.round.yaml index e89ec07c..9710d946 100644 --- a/yaml-files/Float.round.yaml +++ b/yaml-files/Float.round.yaml @@ -1,6 +1,6 @@ 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. +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 @@ -12,363 +12,483 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: [#Zero, 1.2] + - inputs: >- + [#Zero, 1.2] output: >- 1. - - inputs: [#Zero, 1.5] + - inputs: >- + [#Zero, 1.5] output: >- 1. - - inputs: [#Zero, 1.8] + - inputs: >- + [#Zero, 1.8] output: >- 1. - - inputs: [#Zero, -1.2] + - inputs: >- + [#Zero, -1.2] output: >- -1. - - inputs: [#Zero, -1.5] + - inputs: >- + [#Zero, -1.5] output: >- -1. - - inputs: [#Zero, -1.8] + - inputs: >- + [#Zero, -1.8] output: >- -1. - - inputs: [#AwayFromZero, 1.2] + - inputs: >- + [#AwayFromZero, 1.2] output: >- 2. - - inputs: [#AwayFromZero, 1.5] + - inputs: >- + [#AwayFromZero, 1.5] output: >- 2. - - inputs: [#AwayFromZero, 1.8] + - inputs: >- + [#AwayFromZero, 1.8] output: >- 2. - - inputs: [#AwayFromZero, -1.2] + - inputs: >- + [#AwayFromZero, -1.2] output: >- -2. - - inputs: [#AwayFromZero, -1.5] + - inputs: >- + [#AwayFromZero, -1.5] output: >- -2. - - inputs: [#AwayFromZero, -1.8] + - inputs: >- + [#AwayFromZero, -1.8] output: >- -2. - - inputs: [#Up, 1.2] + - inputs: >- + [#Up, 1.2] output: >- 2. - - inputs: [#Up, 1.5] + - inputs: >- + [#Up, 1.5] output: >- 2. - - inputs: [#Up, 1.8] + - inputs: >- + [#Up, 1.8] output: >- 2. - - inputs: [#Up, -1.2] + - inputs: >- + [#Up, -1.2] output: >- -1. - - inputs: [#Up, -1.5] + - inputs: >- + [#Up, -1.5] output: >- -1. - - inputs: [#Up, -1.8] + - inputs: >- + [#Up, -1.8] output: >- -1. - - inputs: [#Down, 1.2] + - inputs: >- + [#Down, 1.2] output: 1. - - inputs: [#Down, 1.5] + - inputs: >- + [#Down, 1.5] output: >- 1. - - inputs: [#Down, 1.8] + - inputs: >- + [#Down, 1.8] output: >- 1. - - inputs: [#Down, -1.2] + - inputs: >- + [#Down, -1.2] output: >- -2. - - inputs: [#Down, -1.5] + - inputs: >- + [#Down, -1.5] output: >- -2. - - inputs: [#Down, -1.8] + - inputs: >- + [#Down, -1.8] output: >- -2. - - inputs: [#Closest(#Zero), 1.2] + - inputs: >- + [#Closest(#Zero), 1.2] output: >- 1. - - inputs: [#Closest(#Zero), 1.5] + - inputs: >- + [#Closest(#Zero), 1.5] output: >- 1. - - inputs: [#Closest(#Zero), 1.8] + - inputs: >- + [#Closest(#Zero), 1.8] output: >- 2. - - inputs: [#Closest(#Zero), -1.2] + - inputs: >- + [#Closest(#Zero), -1.2] output: >- -1. - - inputs: [#Closest(#Zero), -1.5] + - inputs: >- + [#Closest(#Zero), -1.5] output: >- -1. - - inputs: [#Closest(#Zero), -1.8] + - inputs: >- + [#Closest(#Zero), -1.8] output: >- -2. - - inputs: [#Closest(#AwayFromZero), 1.2] + - inputs: >- + [#Closest(#AwayFromZero), 1.2] output: >- 1. - - inputs: [#Closest(#AwayFromZero), 1.5] + - inputs: >- + [#Closest(#AwayFromZero), 1.5] output: >- 2. - - inputs: [#Closest(#AwayFromZero), 1.8] + - inputs: >- + [#Closest(#AwayFromZero), 1.8] output: >- 2. - - inputs: [#Closest(#AwayFromZero), -1.2] + - inputs: >- + [#Closest(#AwayFromZero), -1.2] output: >- -1. - - inputs: [#Closest(#AwayFromZero), -1.5] + - inputs: >- + [#Closest(#AwayFromZero), -1.5] output: >- -2. - - inputs: [#Closest(#AwayFromZero), -1.8] + - inputs: >- + [#Closest(#AwayFromZero), -1.8] output: >- -2. - - inputs: [#Closest(#Up), 1.2] + - inputs: >- + [#Closest(#Up), 1.2] output: >- 1. - - inputs: [#Closest(#Up), 1.5] + - inputs: >- + [#Closest(#Up), 1.5] output: >- 2. - - inputs: [#Closest(#Up), 1.8] + - inputs: >- + [#Closest(#Up), 1.8] output: >- 2. - - inputs: [#Closest(#Up), -1.2] + - inputs: >- + [#Closest(#Up), -1.2] output: >- -1. - - inputs: [#Closest(#Up), -1.5] + - inputs: >- + [#Closest(#Up), -1.5] output: >- -1. - - inputs: [#Closest(#Up), -1.8] + - inputs: >- + [#Closest(#Up), -1.8] output: >- -2. - - inputs: [#Closest(#Down), 1.2] + - inputs: >- + [#Closest(#Down), 1.2] output: >- 1. - - inputs: [#Closest(#Down), 1.5] + - inputs: >- + [#Closest(#Down), 1.5] output: >- 1. - - inputs: [#Closest(#Down), 1.8] + - inputs: >- + [#Closest(#Down), 1.8] output: >- 2. - - inputs: [#Closest(#Down), -1.2] + - inputs: >- + [#Closest(#Down), -1.2] output: >- -1. - - inputs: [#Closest(#Down), -1.5] + - inputs: >- + [#Closest(#Down), -1.5] output: >- -2. - - inputs: [#Closest(#Down), -1.8] + - inputs: >- + [#Closest(#Down), -1.8] output: >- -2. - - inputs: [#Closest(#ToEven), 1.2] + - inputs: >- + [#Closest(#ToEven), 1.2] output: >- 1. - - inputs: [#Closest(#ToEven), 1.5] + - inputs: >- + [#Closest(#ToEven), 1.5] output: >- 2. - - inputs: [#Closest(#ToEven), 1.8] + - inputs: >- + [#Closest(#ToEven), 1.8] output: >- 2. - - inputs: [#Closest(#ToEven), 2.2] + - inputs: >- + [#Closest(#ToEven), 2.2] output: >- 2. - - inputs: [#Closest(#ToEven), 2.5] + - inputs: >- + [#Closest(#ToEven), 2.5] output: >- 2. - - inputs: [#Closest(#ToEven), 2.8] + - inputs: >- + [#Closest(#ToEven), 2.8] output: >- 3. - - inputs: [#Closest(#ToEven), -1.2] + - inputs: >- + [#Closest(#ToEven), -1.2] output: >- -1. - - inputs: [#Closest(#ToEven), -1.5] + - inputs: >- + [#Closest(#ToEven), -1.5] output: >- -2. - - inputs: [#Closest(#ToEven), -1.8] + - inputs: >- + [#Closest(#ToEven), -1.8] output: >- -2. - - inputs: [#Closest(#ToEven), -2.2] + - inputs: >- + [#Closest(#ToEven), -2.2] output: >- -2. - - inputs: [#Closest(#ToEven), -2.5] + - inputs: >- + [#Closest(#ToEven), -2.5] output: >- -2. - - inputs: [#Closest(#ToEven), -2.8] + - inputs: >- + [#Closest(#ToEven), -2.8] output: >- -3. examples: - - inputs: [#Zero, 1.2] + - inputs: >- + [#Zero, 1.2] output: >- 1. - - inputs: [#Zero, 1.5] + - inputs: >- + [#Zero, 1.5] output: >- 1. - - inputs: [#Zero, 1.8] + - inputs: >- + [#Zero, 1.8] output: >- 1. - - inputs: [#Zero, -1.2] + - inputs: >- + [#Zero, -1.2] output: >- -1. - - inputs: [#Zero, -1.5] + - inputs: >- + [#Zero, -1.5] output: >- -1. - - inputs: [#Zero, -1.8] + - inputs: >- + [#Zero, -1.8] output: >- -1. - - inputs: [#AwayFromZero, 1.2] + - inputs: >- + [#AwayFromZero, 1.2] output: >- 2. - - inputs: [#AwayFromZero, 1.5] + - inputs: >- + [#AwayFromZero, 1.5] output: >- 2. - - inputs: [#AwayFromZero, 1.8] + - inputs: >- + [#AwayFromZero, 1.8] output: >- 2. - - inputs: [#AwayFromZero, -1.2] + - inputs: >- + [#AwayFromZero, -1.2] output: >- -2. - - inputs: [#AwayFromZero, -1.5] + - inputs: >- + [#AwayFromZero, -1.5] output: >- -2. - - inputs: [#AwayFromZero, -1.8] + - inputs: >- + [#AwayFromZero, -1.8] output: >- -2. - - inputs: [#Up, 1.2] + - inputs: >- + [#Up, 1.2] output: >- 2. - - inputs: [#Up, 1.5] + - inputs: >- + [#Up, 1.5] output: >- 2. - - inputs: [#Up, 1.8] + - inputs: >- + [#Up, 1.8] output: >- 2. - - inputs: [#Up, -1.2] + - inputs: >- + [#Up, -1.2] output: >- -1. - - inputs: [#Up, -1.5] + - inputs: >- + [#Up, -1.5] output: >- -1. - - inputs: [#Up, -1.8] + - inputs: >- + [#Up, -1.8] output: >- -1. - - inputs: [#Down, 1.2] + - inputs: >- + [#Down, 1.2] output: 1. - - inputs: [#Down, 1.5] + - inputs: >- + [#Down, 1.5] output: >- 1. - - inputs: [#Down, 1.8] + - inputs: >- + [#Down, 1.8] output: >- 1. - - inputs: [#Down, -1.2] + - inputs: >- + [#Down, -1.2] output: >- -2. - - inputs: [#Down, -1.5] + - inputs: >- + [#Down, -1.5] output: >- -2. - - inputs: [#Down, -1.8] + - inputs: >- + [#Down, -1.8] output: >- -2. - - inputs: [#Closest(#Zero), 1.2] + - inputs: >- + [#Closest(#Zero), 1.2] output: >- 1. - - inputs: [#Closest(#Zero), 1.5] + - inputs: >- + [#Closest(#Zero), 1.5] output: >- 1. - - inputs: [#Closest(#Zero), 1.8] + - inputs: >- + [#Closest(#Zero), 1.8] output: >- 2. - - inputs: [#Closest(#Zero), -1.2] + - inputs: >- + [#Closest(#Zero), -1.2] output: >- -1. - - inputs: [#Closest(#Zero), -1.5] + - inputs: >- + [#Closest(#Zero), -1.5] output: >- -1. - - inputs: [#Closest(#Zero), -1.8] + - inputs: >- + [#Closest(#Zero), -1.8] output: >- -2. - - inputs: [#Closest(#AwayFromZero), 1.2] + - inputs: >- + [#Closest(#AwayFromZero), 1.2] output: >- 1. - - inputs: [#Closest(#AwayFromZero), 1.5] + - inputs: >- + [#Closest(#AwayFromZero), 1.5] output: >- 2. - - inputs: [#Closest(#AwayFromZero), 1.8] + - inputs: >- + [#Closest(#AwayFromZero), 1.8] output: >- 2. - - inputs: [#Closest(#AwayFromZero), -1.2] + - inputs: >- + [#Closest(#AwayFromZero), -1.2] output: >- -1. - - inputs: [#Closest(#AwayFromZero), -1.5] + - inputs: >- + [#Closest(#AwayFromZero), -1.5] output: >- -2. - - inputs: [#Closest(#AwayFromZero), -1.8] + - inputs: >- + [#Closest(#AwayFromZero), -1.8] output: >- -2. - - inputs: [#Closest(#Up), 1.2] + - inputs: >- + [#Closest(#Up), 1.2] output: >- 1. - - inputs: [#Closest(#Up), 1.5] + - inputs: >- + [#Closest(#Up), 1.5] output: >- 2. - - inputs: [#Closest(#Up), 1.8] + - inputs: >- + [#Closest(#Up), 1.8] output: >- 2. - - inputs: [#Closest(#Up), -1.2] + - inputs: >- + [#Closest(#Up), -1.2] output: >- -1. - - inputs: [#Closest(#Up), -1.5] + - inputs: >- + [#Closest(#Up), -1.5] output: >- -1. - - inputs: [#Closest(#Up), -1.8] + - inputs: >- + [#Closest(#Up), -1.8] output: >- -2. - - inputs: [#Closest(#Down), 1.2] + - inputs: >- + [#Closest(#Down), 1.2] output: >- 1. - - inputs: [#Closest(#Down), 1.5] + - inputs: >- + [#Closest(#Down), 1.5] output: >- 1. - - inputs: [#Closest(#Down), 1.8] + - inputs: >- + [#Closest(#Down), 1.8] output: >- 2. - - inputs: [#Closest(#Down), -1.2] + - inputs: >- + [#Closest(#Down), -1.2] output: >- -1. - - inputs: [#Closest(#Down), -1.5] + - inputs: >- + [#Closest(#Down), -1.5] output: >- -2. - - inputs: [#Closest(#Down), -1.8] + - inputs: >- + [#Closest(#Down), -1.8] output: >- -2. - - inputs: [#Closest(#ToEven), 1.2] + - inputs: >- + [#Closest(#ToEven), 1.2] output: >- 1. - - inputs: [#Closest(#ToEven), 1.5] + - inputs: >- + [#Closest(#ToEven), 1.5] output: >- 2. - - inputs: [#Closest(#ToEven), 1.8] + - inputs: >- + [#Closest(#ToEven), 1.8] output: >- 2. - - inputs: [#Closest(#ToEven), 2.2] + - inputs: >- + [#Closest(#ToEven), 2.2] output: >- 2. - - inputs: [#Closest(#ToEven), 2.5] + - inputs: >- + [#Closest(#ToEven), 2.5] output: >- 2. - - inputs: [#Closest(#ToEven), 2.8] + - inputs: >- + [#Closest(#ToEven), 2.8] output: >- 3. - - inputs: [#Closest(#ToEven), -1.2] + - inputs: >- + [#Closest(#ToEven), -1.2] output: >- -1. - - inputs: [#Closest(#ToEven), -1.5] + - inputs: >- + [#Closest(#ToEven), -1.5] output: >- -2. - - inputs: [#Closest(#ToEven), -1.8] + - inputs: >- + [#Closest(#ToEven), -1.8] output: >- -2. - - inputs: [#Closest(#ToEven), -2.2] + - inputs: >- + [#Closest(#ToEven), -2.2] output: >- -2. - - inputs: [#Closest(#ToEven), -2.5] + - inputs: >- + [#Closest(#ToEven), -2.5] output: >- -2. - - inputs: [#Closest(#ToEven), -2.8] + - inputs: >- + [#Closest(#ToEven), -2.8] output: >- -3. added: 0.1.0 diff --git a/yaml-files/Float.squareRoot.yaml b/yaml-files/Float.squareRoot.yaml index b0abab00..daab4b05 100644 --- a/yaml-files/Float.squareRoot.yaml +++ b/yaml-files/Float.squareRoot.yaml @@ -1,5 +1,4 @@ ->- - module: Float +module: Float name: squareRoot docstring: Takes and returns its square root or [NaN] when it is negative parameters: diff --git a/yaml-files/Float.truncate.yaml b/yaml-files/Float.truncate.yaml index a482c857..d00423a7 100644 --- a/yaml-files/Float.truncate.yaml +++ b/yaml-files/Float.truncate.yaml @@ -1,5 +1,4 @@ ->- - module: Float +module: Float name: truncate docstring: Takes and remove all the positions after the decimal point parameters: From f8f2173044f131d323eba2b3e72ebdadf37cfc75 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2022 23:19:46 +0100 Subject: [PATCH 24/31] Add some ListTest's yaml files --- yaml-files/List.cons.yaml | 25 +++++++++++++++ yaml-files/List.drop.yaml | 40 ++++++++++++++++++++++++ yaml-files/List.dropWhile.yaml | 33 ++++++++++++++++++++ yaml-files/List.filter.yaml | 29 ++++++++++++++++++ yaml-files/List.filterMap.yaml | 23 ++++++++++++++ yaml-files/List.filterWithIndex.yaml | 29 ++++++++++++++++++ yaml-files/List.findIndex.yaml | 28 +++++++++++++++++ yaml-files/List.flatMap.yaml | 35 +++++++++++++++++++++ yaml-files/List.fromArray.yaml | 30 ++++++++++++++++++ yaml-files/List.groupWhile.yaml | 30 ++++++++++++++++++ yaml-files/List.head.yaml | 22 +++++++++++++ yaml-files/List.includes.yaml | 31 +++++++++++++++++++ yaml-files/List.initialize.yaml | 24 +++++++++++++++ yaml-files/List.join.yaml | 24 +++++++++++++++ yaml-files/List.map2.yaml | 34 ++++++++++++++++++++ yaml-files/List.map3.yaml | 44 ++++++++++++++++++++++++++ yaml-files/List.mapWithIndex.yaml | 34 ++++++++++++++++++++ yaml-files/List.maximumBy.yaml | 28 +++++++++++++++++ yaml-files/List.minimum.yaml | 24 +++++++++++++++ yaml-files/List.minimumBy.yaml | 28 +++++++++++++++++ yaml-files/List.partition.yaml | 29 ++++++++++++++++++ yaml-files/List.range.yaml | 36 ++++++++++++++++++++++ yaml-files/List.repeat.yaml | 33 ++++++++++++++++++++ yaml-files/List.reverse.yaml | 26 ++++++++++++++++ yaml-files/List.singleton.yaml | 27 ++++++++++++++++ yaml-files/List.sliding.yaml | 46 ++++++++++++++++++++++++++++ yaml-files/List.sort.yaml | 32 +++++++++++++++++++ yaml-files/List.take.yaml | 32 +++++++++++++++++++ yaml-files/List.takeWhile.yaml | 41 +++++++++++++++++++++++++ yaml-files/List.uniqueBy.yaml | 31 +++++++++++++++++++ 30 files changed, 928 insertions(+) create mode 100644 yaml-files/List.cons.yaml create mode 100644 yaml-files/List.drop.yaml create mode 100644 yaml-files/List.dropWhile.yaml create mode 100644 yaml-files/List.filter.yaml create mode 100644 yaml-files/List.filterMap.yaml create mode 100644 yaml-files/List.filterWithIndex.yaml create mode 100644 yaml-files/List.findIndex.yaml create mode 100644 yaml-files/List.flatMap.yaml create mode 100644 yaml-files/List.fromArray.yaml create mode 100644 yaml-files/List.groupWhile.yaml create mode 100644 yaml-files/List.head.yaml create mode 100644 yaml-files/List.includes.yaml create mode 100644 yaml-files/List.initialize.yaml create mode 100644 yaml-files/List.join.yaml create mode 100644 yaml-files/List.map2.yaml create mode 100644 yaml-files/List.map3.yaml create mode 100644 yaml-files/List.mapWithIndex.yaml create mode 100644 yaml-files/List.maximumBy.yaml create mode 100644 yaml-files/List.minimum.yaml create mode 100644 yaml-files/List.minimumBy.yaml create mode 100644 yaml-files/List.partition.yaml create mode 100644 yaml-files/List.range.yaml create mode 100644 yaml-files/List.repeat.yaml create mode 100644 yaml-files/List.reverse.yaml create mode 100644 yaml-files/List.singleton.yaml create mode 100644 yaml-files/List.sliding.yaml create mode 100644 yaml-files/List.sort.yaml create mode 100644 yaml-files/List.take.yaml create mode 100644 yaml-files/List.takeWhile.yaml create mode 100644 yaml-files/List.uniqueBy.yaml diff --git a/yaml-files/List.cons.yaml b/yaml-files/List.cons.yaml new file mode 100644 index 00000000..fba4ad94 --- /dev/null +++ b/yaml-files/List.cons.yaml @@ -0,0 +1,25 @@ +module: List +name: cons +docstring: Prepend a value to the front of a list +parameters: + - name: a + type: list<'a> + - name: b + type: >- + 'a +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.drop.yaml b/yaml-files/List.drop.yaml new file mode 100644 index 00000000..05e45bba --- /dev/null +++ b/yaml-files/List.drop.yaml @@ -0,0 +1,40 @@ +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> + - name: count + type: int +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..71f86223 --- /dev/null +++ b/yaml-files/List.dropWhile.yaml @@ -0,0 +1,33 @@ +module: List +name: dropWhile +docstring: Drop elements from a list until [f] returns [false] +parameters: + - name: a + type: list<'a> + - name: f + type: >- + 'a => bool +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.filter.yaml b/yaml-files/List.filter.yaml new file mode 100644 index 00000000..1cf2b9bd --- /dev/null +++ b/yaml-files/List.filter.yaml @@ -0,0 +1,29 @@ +module: List +name: filter +docstring: Keep elements that [f] returns [true] for +parameters: + - name: a + type: list<'a> + - name: f + type: >- + 'a => bool +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..24890251 --- /dev/null +++ b/yaml-files/List.filterMap.yaml @@ -0,0 +1,23 @@ +module: List +name: filterMap +docstring: Allows you to combine {!map} and {!filter} into a single pass +parameters: + - name: a + type: list<'a> + - name: f + type: >- + 'a => option<'b> +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..6d162906 --- /dev/null +++ b/yaml-files/List.filterWithIndex.yaml @@ -0,0 +1,29 @@ +module: List +name: filterWithIndex +docstring: Like {!filter} but [f] is also called with each elements index +parameters: + - name: a + type: list<'a> + - name: f + type: >- + (int, 'a) => bool +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.findIndex.yaml b/yaml-files/List.findIndex.yaml new file mode 100644 index 00000000..c3a49603 --- /dev/null +++ b/yaml-files/List.findIndex.yaml @@ -0,0 +1,28 @@ +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> + - name: f + type: (int, 'a)=> bool +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..fe4d30bf --- /dev/null +++ b/yaml-files/List.flatMap.yaml @@ -0,0 +1,35 @@ +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> + - name: f + type: >- + 'a => list<'b> +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.fromArray.yaml b/yaml-files/List.fromArray.yaml new file mode 100644 index 00000000..01c22798 --- /dev/null +++ b/yaml-files/List.fromArray.yaml @@ -0,0 +1,30 @@ +module: List +name: fromArray +docstring: Create a list from an {!Array} +parameters: + - name: a + type: array<'a> +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.groupWhile.yaml b/yaml-files/List.groupWhile.yaml new file mode 100644 index 00000000..a2516867 --- /dev/null +++ b/yaml-files/List.groupWhile.yaml @@ -0,0 +1,30 @@ +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> + - name: f + type: ('a, 'a) => bool +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..8bb67973 --- /dev/null +++ b/yaml-files/List.head.yaml @@ -0,0 +1,22 @@ +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> +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..2a6c13b9 --- /dev/null +++ b/yaml-files/List.includes.yaml @@ -0,0 +1,31 @@ +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> + - name: b + type: >- + 'a + - name: equal + type: ('a, 'a) => bool +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.initialize.yaml b/yaml-files/List.initialize.yaml new file mode 100644 index 00000000..a29adece --- /dev/null +++ b/yaml-files/List.initialize.yaml @@ -0,0 +1,24 @@ +module: List +name: initialize +docstring: Initialize a list +parameters: + - name: a + type: int + - name: f + type: int => 'a +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.join.yaml b/yaml-files/List.join.yaml new file mode 100644 index 00000000..d7b92e32 --- /dev/null +++ b/yaml-files/List.join.yaml @@ -0,0 +1,24 @@ +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 + - name: sep + type: string +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.map2.yaml b/yaml-files/List.map2.yaml new file mode 100644 index 00000000..63531e9f --- /dev/null +++ b/yaml-files/List.map2.yaml @@ -0,0 +1,34 @@ +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> + - name: b + type: list<'b> + - name: f + type: ('a, 'b) => 'c) +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..f43656c4 --- /dev/null +++ b/yaml-files/List.map3.yaml @@ -0,0 +1,44 @@ +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> + - name: b + type: list<'b> + - name: c + type: list<'c> + - name: f + type: ('a, 'b, 'c) => 'd +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..8d8e6ff7 --- /dev/null +++ b/yaml-files/List.mapWithIndex.yaml @@ -0,0 +1,34 @@ +module: List +name: mapWithIndex +docstring: Apply a function [f] to every element and its index +parameters: + - name: a + type: list<'a> + - name: f + type: (int, 'a) => 'b) +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.maximumBy.yaml b/yaml-files/List.maximumBy.yaml new file mode 100644 index 00000000..7c98d73e --- /dev/null +++ b/yaml-files/List.maximumBy.yaml @@ -0,0 +1,28 @@ +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> + - name: f + type: >- + 'a => 'comparable +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..0070b339 --- /dev/null +++ b/yaml-files/List.minimum.yaml @@ -0,0 +1,24 @@ +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> + - name: compare + type: ('a, 'a) => int +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..640a7811 --- /dev/null +++ b/yaml-files/List.minimumBy.yaml @@ -0,0 +1,28 @@ +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> + - name: f + type: >- + 'a => 'comparable +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..0a8c97f0 --- /dev/null +++ b/yaml-files/List.partition.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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..60e78f34 --- /dev/null +++ b/yaml-files/List.range.yaml @@ -0,0 +1,36 @@ +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=? + - name: a + type: int +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.repeat.yaml b/yaml-files/List.repeat.yaml new file mode 100644 index 00000000..426b0caa --- /dev/null +++ b/yaml-files/List.repeat.yaml @@ -0,0 +1,33 @@ +module: List +name: repeat +docstring: Creates a list of length [times] with the value [a] populated at each index +parameters: + - name: a + type: >- + 'a + - name: times + type: int +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..a955127e --- /dev/null +++ b/yaml-files/List.reverse.yaml @@ -0,0 +1,26 @@ +module: List +name: reverse +docstring: Reverse the elements in a list +parameters: + - name: a + type: list<'a> +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..e8cc3cf5 --- /dev/null +++ b/yaml-files/List.singleton.yaml @@ -0,0 +1,27 @@ +module: List +name: singleton +docstring: Create a list with only one element +parameters: + - name: a + type: >- + 'a +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..ce0034b7 --- /dev/null +++ b/yaml-files/List.sliding.yaml @@ -0,0 +1,46 @@ +module: List +name: sliding +docstring: Provides a sliding 'window' of sub-lists over a list +parameters: + - name: a + type: list<'a> + - name: size + type: int + - name: step + type: int=? +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..f53e732b --- /dev/null +++ b/yaml-files/List.sort.yaml @@ -0,0 +1,32 @@ +module: List +name: sort +docstring: Sort using the provided [compare] function +parameters: + - name: a + type: list<'a> + - name: f + type: ('a, 'a) => int +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.take.yaml b/yaml-files/List.take.yaml new file mode 100644 index 00000000..14573032 --- /dev/null +++ b/yaml-files/List.take.yaml @@ -0,0 +1,32 @@ +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> + - name: count + type: int +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..21b3a05f --- /dev/null +++ b/yaml-files/List.takeWhile.yaml @@ -0,0 +1,41 @@ +module: List +name: takeWhile +docstring: Take elements from a list until [f] returns [false] +parameters: + - name: a + type: list<'a> + - name: f + type: >- + 'a => bool +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.uniqueBy.yaml b/yaml-files/List.uniqueBy.yaml new file mode 100644 index 00000000..154be75b --- /dev/null +++ b/yaml-files/List.uniqueBy.yaml @@ -0,0 +1,31 @@ +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> + - name: f + type: >- + 'a => string +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 From 64324b731b736c5267d5bb11187960f2d4f1386a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Nov 2022 16:37:35 +0100 Subject: [PATCH 25/31] Add more ListTest's yaml files --- yaml-files/List.all.yaml | 33 ++++++++++++++++++ yaml-files/List.any.yaml | 29 ++++++++++++++++ yaml-files/List.append.yaml | 32 +++++++++++++++++ yaml-files/List.chunksOf.yaml | 24 +++++++++++++ yaml-files/List.compare.yaml | 34 ++++++++++++++++++ yaml-files/List.count.yaml | 29 ++++++++++++++++ yaml-files/List.equal.yaml | 30 ++++++++++++++++ yaml-files/List.extent.yaml | 28 +++++++++++++++ yaml-files/List.find.yaml | 29 ++++++++++++++++ yaml-files/List.flatten.yaml | 30 ++++++++++++++++ yaml-files/List.getAt.yaml | 32 +++++++++++++++++ yaml-files/List.initial.yaml | 30 ++++++++++++++++ yaml-files/List.insertAt.yaml | 59 ++++++++++++++++++++++++++++++++ yaml-files/List.intersperse.yaml | 29 ++++++++++++++++ yaml-files/List.isEmpty.yaml | 26 ++++++++++++++ yaml-files/List.last.yaml | 30 ++++++++++++++++ yaml-files/List.length.yaml | 22 ++++++++++++ yaml-files/List.map.yaml | 37 ++++++++++++++++++++ yaml-files/List.maximum.yaml | 24 +++++++++++++ yaml-files/List.removeAt.yaml | 40 ++++++++++++++++++++++ yaml-files/List.splitAt.yaml | 46 +++++++++++++++++++++++++ yaml-files/List.splitWhen.yaml | 34 ++++++++++++++++++ yaml-files/List.toArray.yaml | 30 ++++++++++++++++ yaml-files/List.unzip.yaml | 17 +++++++++ yaml-files/List.updateAt.yaml | 43 +++++++++++++++++++++++ yaml-files/List.zip.yaml | 24 +++++++++++++ 26 files changed, 821 insertions(+) create mode 100644 yaml-files/List.all.yaml create mode 100644 yaml-files/List.any.yaml create mode 100644 yaml-files/List.append.yaml create mode 100644 yaml-files/List.chunksOf.yaml create mode 100644 yaml-files/List.compare.yaml create mode 100644 yaml-files/List.count.yaml create mode 100644 yaml-files/List.equal.yaml create mode 100644 yaml-files/List.extent.yaml create mode 100644 yaml-files/List.find.yaml create mode 100644 yaml-files/List.flatten.yaml create mode 100644 yaml-files/List.getAt.yaml create mode 100644 yaml-files/List.initial.yaml create mode 100644 yaml-files/List.insertAt.yaml create mode 100644 yaml-files/List.intersperse.yaml create mode 100644 yaml-files/List.isEmpty.yaml create mode 100644 yaml-files/List.last.yaml create mode 100644 yaml-files/List.length.yaml create mode 100644 yaml-files/List.map.yaml create mode 100644 yaml-files/List.maximum.yaml create mode 100644 yaml-files/List.removeAt.yaml create mode 100644 yaml-files/List.splitAt.yaml create mode 100644 yaml-files/List.splitWhen.yaml create mode 100644 yaml-files/List.toArray.yaml create mode 100644 yaml-files/List.unzip.yaml create mode 100644 yaml-files/List.updateAt.yaml create mode 100644 yaml-files/List.zip.yaml diff --git a/yaml-files/List.all.yaml b/yaml-files/List.all.yaml new file mode 100644 index 00000000..8199adf9 --- /dev/null +++ b/yaml-files/List.all.yaml @@ -0,0 +1,33 @@ +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> + - name: f + type: >- + 'a => bool +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..5265c24a --- /dev/null +++ b/yaml-files/List.any.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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..59175df6 --- /dev/null +++ b/yaml-files/List.append.yaml @@ -0,0 +1,32 @@ +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> + - name: b + type: list<'a> +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..4054e6be --- /dev/null +++ b/yaml-files/List.chunksOf.yaml @@ -0,0 +1,24 @@ +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> + - name: size + type: int +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..1c08bdcd --- /dev/null +++ b/yaml-files/List.compare.yaml @@ -0,0 +1,34 @@ +module: List +name: compare +docstring: Compare two lists using the provided [f] function to compare elements +parameters: + - name: a + type: list<'a> + - name: b + type: list<'a> + - name: c + type: ('a, 'a) => int +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.count.yaml b/yaml-files/List.count.yaml new file mode 100644 index 00000000..97b18c02 --- /dev/null +++ b/yaml-files/List.count.yaml @@ -0,0 +1,29 @@ +module: List +name: count +docstring: Count the number of elements where function [f] returns [true] +parameters: + - name: a + type: list<'a> + - name: f + type: >- + 'a => bool +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.equal.yaml b/yaml-files/List.equal.yaml new file mode 100644 index 00000000..492e3881 --- /dev/null +++ b/yaml-files/List.equal.yaml @@ -0,0 +1,30 @@ +module: List +name: equal +docstring: Test two lists for equality using the provided function to test elements +parameters: + - name: a + type: list<'a> + - name: b + type: list<'a> + - name: c + type: ('a, 'a) => bool +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..2fe61395 --- /dev/null +++ b/yaml-files/List.extent.yaml @@ -0,0 +1,28 @@ +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> + - name: compare + type: ('a, 'a) => int +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.find.yaml b/yaml-files/List.find.yaml new file mode 100644 index 00000000..d39b9ade --- /dev/null +++ b/yaml-files/List.find.yaml @@ -0,0 +1,29 @@ +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> + - name: f + type: >- + 'a => bool +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.flatten.yaml b/yaml-files/List.flatten.yaml new file mode 100644 index 00000000..d4b163e3 --- /dev/null +++ b/yaml-files/List.flatten.yaml @@ -0,0 +1,30 @@ +module: List +name: flatten +docstring: Concatenate a list of lists into a single list + - name: a + type: list> +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.getAt.yaml b/yaml-files/List.getAt.yaml new file mode 100644 index 00000000..6b458f6c --- /dev/null +++ b/yaml-files/List.getAt.yaml @@ -0,0 +1,32 @@ +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> + - name: index + type: int +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.initial.yaml b/yaml-files/List.initial.yaml new file mode 100644 index 00000000..cf43f3b6 --- /dev/null +++ b/yaml-files/List.initial.yaml @@ -0,0 +1,30 @@ +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> +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.insertAt.yaml b/yaml-files/List.insertAt.yaml new file mode 100644 index 00000000..c4330295 --- /dev/null +++ b/yaml-files/List.insertAt.yaml @@ -0,0 +1,59 @@ +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> + - name: index + type: int + - name: value + type: >- + 'a +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..c2e65873 --- /dev/null +++ b/yaml-files/List.intersperse.yaml @@ -0,0 +1,29 @@ +module: List +name: intersperse +docstring: Places [sep] between all the elements of the given list +parameters: + - name: a + type: list<'a> + - name: sep + type: >- + 'a +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..03424f0f --- /dev/null +++ b/yaml-files/List.isEmpty.yaml @@ -0,0 +1,26 @@ +module: List +name: isEmpty +docstring: Determine if a list is empty +parameters: + - name: a + type: list<_> +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.last.yaml b/yaml-files/List.last.yaml new file mode 100644 index 00000000..a7dbf2c0 --- /dev/null +++ b/yaml-files/List.last.yaml @@ -0,0 +1,30 @@ +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> +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..58dc2e19 --- /dev/null +++ b/yaml-files/List.length.yaml @@ -0,0 +1,22 @@ +module: List +name: length +docstring: Return the number of elements in a list +parameters: + - name: a + type: list<'a> +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..316763f8 --- /dev/null +++ b/yaml-files/List.map.yaml @@ -0,0 +1,37 @@ +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> + - name: f + type: >- + 'a => 'b +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.maximum.yaml b/yaml-files/List.maximum.yaml new file mode 100644 index 00000000..91c473e0 --- /dev/null +++ b/yaml-files/List.maximum.yaml @@ -0,0 +1,24 @@ +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> + - name: compare + type: ('a, 'a) => int +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.removeAt.yaml b/yaml-files/List.removeAt.yaml new file mode 100644 index 00000000..3f4b356e --- /dev/null +++ b/yaml-files/List.removeAt.yaml @@ -0,0 +1,40 @@ +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> + - name: index + type: int +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.splitAt.yaml b/yaml-files/List.splitAt.yaml new file mode 100644 index 00000000..5ab59854 --- /dev/null +++ b/yaml-files/List.splitAt.yaml @@ -0,0 +1,46 @@ +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> + - name: index + type: int +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..94b4b4bb --- /dev/null +++ b/yaml-files/List.splitWhen.yaml @@ -0,0 +1,34 @@ +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> + - name: f + type: >- + 'a => bool +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.toArray.yaml b/yaml-files/List.toArray.yaml new file mode 100644 index 00000000..db094bcb --- /dev/null +++ b/yaml-files/List.toArray.yaml @@ -0,0 +1,30 @@ +module: List +name: toArray +docstring: Converts a list to an {!Array}. +parameters: + - name: a + type: list<'a> +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.unzip.yaml b/yaml-files/List.unzip.yaml new file mode 100644 index 00000000..e3df9297 --- /dev/null +++ b/yaml-files/List.unzip.yaml @@ -0,0 +1,17 @@ +module: List +name: unzip +docstring: Decompose a list of {!Tuple2} into a {!Tuple2} of lists + - name: a + type: list<('a,'b)> +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..4d1e1b23 --- /dev/null +++ b/yaml-files/List.updateAt.yaml @@ -0,0 +1,43 @@ +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> + - name: index + type: int + - name: f + type: >- + 'a => 'a +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..0b686329 --- /dev/null +++ b/yaml-files/List.zip.yaml @@ -0,0 +1,24 @@ +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> + - name: b + type: list<'b> +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 + From 7e875286ef3cc34071eb4f2950ca9978e8f2e137 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Nov 2022 18:27:01 +0100 Subject: [PATCH 26/31] Generate tests in one file including test header + Delete separate files --- src/generateTest.res | 278 +++++++----- test/fsharpTests/BoolTest.fs | 10 +- test/fsharpTests/BoolTest/compareTest.fs | 16 - test/fsharpTests/BoolTest/equalTest.fs | 12 - test/fsharpTests/BoolTest/fromIntTest.fs | 28 -- test/fsharpTests/BoolTest/fromStringTest.fs | 16 - test/fsharpTests/BoolTest/toIntTest.fs | 8 - test/fsharpTests/BoolTest/toStringTest.fs | 8 - test/fsharpTests/BoolTest/xorTest.fs | 16 - test/fsharpTests/CharTest.fs | 10 +- test/fsharpTests/CharTest/fromCodeTest.fs | 12 - test/fsharpTests/CharTest/fromStringTest.fs | 12 - .../CharTest/isAlphanumericTest.fs | 8 - test/fsharpTests/CharTest/isDigitTest.fs | 44 -- test/fsharpTests/CharTest/isLetterTest.fs | 24 - test/fsharpTests/CharTest/isLowercaseTest.fs | 12 - test/fsharpTests/CharTest/isPrintableTest.fs | 8 - test/fsharpTests/CharTest/isUppercaseTest.fs | 12 - test/fsharpTests/CharTest/isWhitespaceTest.fs | 8 - test/fsharpTests/CharTest/toCodeTest.fs | 4 - test/fsharpTests/CharTest/toDigitTest.fs | 12 - test/fsharpTests/CharTest/toLowercaseTest.fs | 16 - test/fsharpTests/CharTest/toStringTest.fs | 4 - test/fsharpTests/CharTest/toUppercaseTest.fs | 16 - test/fsharpTests/FloatTest.fs | 313 ------------- test/fsharpTests/IntTest.fs | 423 ++++++++---------- test/fsharpTests/IntTest/absoluteTest.fs | 12 - test/fsharpTests/IntTest/addTest.fs | 8 - test/fsharpTests/IntTest/clampTest.fs | 23 - test/fsharpTests/IntTest/divideFloatTest.fs | 20 - test/fsharpTests/IntTest/divideTest.fs | 11 - test/fsharpTests/IntTest/fromStringTest.fs | 52 --- test/fsharpTests/IntTest/inRangeTest.fs | 23 - test/fsharpTests/IntTest/isEvenTest.fs | 12 - test/fsharpTests/IntTest/isOddTest.fs | 12 - test/fsharpTests/IntTest/maximumTest.fs | 12 - test/fsharpTests/IntTest/minimumTest.fs | 12 - test/fsharpTests/IntTest/moduloTest.fs | 36 -- test/fsharpTests/IntTest/multiplyTest.fs | 4 - test/fsharpTests/IntTest/negateTest.fs | 12 - test/fsharpTests/IntTest/powerTest.fs | 12 - test/fsharpTests/IntTest/remainderTest.fs | 32 -- test/fsharpTests/IntTest/subtractTest.fs | 4 - test/fsharpTests/IntTest/toFloatTest.fs | 12 - test/fsharpTests/IntTest/toStringTest.fs | 8 - test/ocamlTests/BoolTest.ml | 8 +- test/ocamlTests/BoolTest/compareTest.ml | 4 - test/ocamlTests/BoolTest/equalTest.ml | 3 - test/ocamlTests/BoolTest/fromIntTest.ml | 7 - test/ocamlTests/BoolTest/fromStringTest.ml | 4 - test/ocamlTests/BoolTest/toIntTest.ml | 2 - test/ocamlTests/BoolTest/toStringTest.ml | 2 - test/ocamlTests/BoolTest/xorTest.ml | 4 - test/ocamlTests/CharTest.ml | 8 +- test/ocamlTests/CharTest/fromCodeTest.ml | 3 - test/ocamlTests/CharTest/fromStringTest.ml | 3 - .../ocamlTests/CharTest/isAlphanumericTest.ml | 2 - test/ocamlTests/CharTest/isDigitTest.ml | 11 - test/ocamlTests/CharTest/isLetterTest.ml | 6 - test/ocamlTests/CharTest/isLowercaseTest.ml | 3 - test/ocamlTests/CharTest/isPrintableTest.ml | 2 - test/ocamlTests/CharTest/isUppercaseTest.ml | 3 - test/ocamlTests/CharTest/isWhitespaceTest.ml | 2 - test/ocamlTests/CharTest/toCodeTest.ml | 1 - test/ocamlTests/CharTest/toDigitTest.ml | 3 - test/ocamlTests/CharTest/toLowercaseTest.ml | 4 - test/ocamlTests/CharTest/toStringTest.ml | 1 - test/ocamlTests/CharTest/toUppercaseTest.ml | 4 - test/ocamlTests/FloatTest.ml | 78 ---- test/ocamlTests/IntTest.ml | 15 +- test/ocamlTests/IntTest/absoluteTest.ml | 3 - test/ocamlTests/IntTest/addTest.ml | 2 - test/ocamlTests/IntTest/clampTest.ml | 6 - test/ocamlTests/IntTest/divideFloatTest.ml | 5 - test/ocamlTests/IntTest/divideTest.ml | 3 - test/ocamlTests/IntTest/fromStringTest.ml | 13 - test/ocamlTests/IntTest/inRangeTest.ml | 6 - test/ocamlTests/IntTest/isEvenTest.ml | 3 - test/ocamlTests/IntTest/isOddTest.ml | 3 - test/ocamlTests/IntTest/maximumTest.ml | 3 - test/ocamlTests/IntTest/minimumTest.ml | 3 - test/ocamlTests/IntTest/moduloTest.ml | 9 - test/ocamlTests/IntTest/multiplyTest.ml | 1 - test/ocamlTests/IntTest/negateTest.ml | 3 - test/ocamlTests/IntTest/powerTest.ml | 3 - test/ocamlTests/IntTest/remainderTest.ml | 8 - test/ocamlTests/IntTest/subtractTest.ml | 1 - test/ocamlTests/IntTest/toFloatTest.ml | 3 - test/ocamlTests/IntTest/toStringTest.ml | 2 - test/rescriptTests/BoolTest.res | 7 +- test/rescriptTests/BoolTest/compareTest.res | 4 - test/rescriptTests/BoolTest/equalTest.res | 3 - test/rescriptTests/BoolTest/fromIntTest.res | 14 - .../rescriptTests/BoolTest/fromStringTest.res | 8 - test/rescriptTests/BoolTest/toIntTest.res | 2 - test/rescriptTests/BoolTest/toStringTest.res | 2 - test/rescriptTests/BoolTest/xorTest.res | 4 - test/rescriptTests/CharTest.res | 7 +- test/rescriptTests/CharTest/fromCodeTest.res | 6 - .../rescriptTests/CharTest/fromStringTest.res | 6 - .../CharTest/isAlphanumericTest.res | 3 - test/rescriptTests/CharTest/isDigitTest.res | 12 - test/rescriptTests/CharTest/isLetterTest.res | 6 - .../CharTest/isLowercaseTest.res | 3 - .../CharTest/isPrintableTest.res | 3 - .../CharTest/isUppercaseTest.res | 3 - .../CharTest/isWhitespaceTest.res | 2 - test/rescriptTests/CharTest/toCodeTest.res | 1 - test/rescriptTests/CharTest/toDigitTest.res | 6 - .../CharTest/toLowercaseTest.res | 4 - test/rescriptTests/CharTest/toStringTest.res | 1 - .../CharTest/toUppercaseTest.res | 4 - test/rescriptTests/FloatTest.res | 92 ---- test/rescriptTests/IntTest.res | 13 +- test/rescriptTests/IntTest/absoluteTest.res | 3 - test/rescriptTests/IntTest/addTest.res | 2 - test/rescriptTests/IntTest/clampTest.res | 6 - .../rescriptTests/IntTest/divideFloatTest.res | 5 - test/rescriptTests/IntTest/divideTest.res | 3 - test/rescriptTests/IntTest/fromStringTest.res | 26 -- test/rescriptTests/IntTest/inRangeTest.res | 6 - test/rescriptTests/IntTest/isEvenTest.res | 3 - test/rescriptTests/IntTest/isOddTest.res | 3 - test/rescriptTests/IntTest/maximumTest.res | 3 - test/rescriptTests/IntTest/minimumTest.res | 3 - test/rescriptTests/IntTest/moduloTest.res | 9 - test/rescriptTests/IntTest/multiplyTest.res | 1 - test/rescriptTests/IntTest/negateTest.res | 3 - test/rescriptTests/IntTest/powerTest.res | 3 - test/rescriptTests/IntTest/remainderTest.res | 8 - test/rescriptTests/IntTest/subtractTest.res | 1 - test/rescriptTests/IntTest/toFloatTest.res | 3 - test/rescriptTests/IntTest/toStringTest.res | 2 - 133 files changed, 411 insertions(+), 1808 deletions(-) delete mode 100644 test/fsharpTests/BoolTest/compareTest.fs delete mode 100644 test/fsharpTests/BoolTest/equalTest.fs delete mode 100644 test/fsharpTests/BoolTest/fromIntTest.fs delete mode 100644 test/fsharpTests/BoolTest/fromStringTest.fs delete mode 100644 test/fsharpTests/BoolTest/toIntTest.fs delete mode 100644 test/fsharpTests/BoolTest/toStringTest.fs delete mode 100644 test/fsharpTests/BoolTest/xorTest.fs delete mode 100644 test/fsharpTests/CharTest/fromCodeTest.fs delete mode 100644 test/fsharpTests/CharTest/fromStringTest.fs delete mode 100644 test/fsharpTests/CharTest/isAlphanumericTest.fs delete mode 100644 test/fsharpTests/CharTest/isDigitTest.fs delete mode 100644 test/fsharpTests/CharTest/isLetterTest.fs delete mode 100644 test/fsharpTests/CharTest/isLowercaseTest.fs delete mode 100644 test/fsharpTests/CharTest/isPrintableTest.fs delete mode 100644 test/fsharpTests/CharTest/isUppercaseTest.fs delete mode 100644 test/fsharpTests/CharTest/isWhitespaceTest.fs delete mode 100644 test/fsharpTests/CharTest/toCodeTest.fs delete mode 100644 test/fsharpTests/CharTest/toDigitTest.fs delete mode 100644 test/fsharpTests/CharTest/toLowercaseTest.fs delete mode 100644 test/fsharpTests/CharTest/toStringTest.fs delete mode 100644 test/fsharpTests/CharTest/toUppercaseTest.fs delete mode 100644 test/fsharpTests/FloatTest.fs delete mode 100644 test/fsharpTests/IntTest/absoluteTest.fs delete mode 100644 test/fsharpTests/IntTest/addTest.fs delete mode 100644 test/fsharpTests/IntTest/clampTest.fs delete mode 100644 test/fsharpTests/IntTest/divideFloatTest.fs delete mode 100644 test/fsharpTests/IntTest/divideTest.fs delete mode 100644 test/fsharpTests/IntTest/fromStringTest.fs delete mode 100644 test/fsharpTests/IntTest/inRangeTest.fs delete mode 100644 test/fsharpTests/IntTest/isEvenTest.fs delete mode 100644 test/fsharpTests/IntTest/isOddTest.fs delete mode 100644 test/fsharpTests/IntTest/maximumTest.fs delete mode 100644 test/fsharpTests/IntTest/minimumTest.fs delete mode 100644 test/fsharpTests/IntTest/moduloTest.fs delete mode 100644 test/fsharpTests/IntTest/multiplyTest.fs delete mode 100644 test/fsharpTests/IntTest/negateTest.fs delete mode 100644 test/fsharpTests/IntTest/powerTest.fs delete mode 100644 test/fsharpTests/IntTest/remainderTest.fs delete mode 100644 test/fsharpTests/IntTest/subtractTest.fs delete mode 100644 test/fsharpTests/IntTest/toFloatTest.fs delete mode 100644 test/fsharpTests/IntTest/toStringTest.fs delete mode 100644 test/ocamlTests/BoolTest/compareTest.ml delete mode 100644 test/ocamlTests/BoolTest/equalTest.ml delete mode 100644 test/ocamlTests/BoolTest/fromIntTest.ml delete mode 100644 test/ocamlTests/BoolTest/fromStringTest.ml delete mode 100644 test/ocamlTests/BoolTest/toIntTest.ml delete mode 100644 test/ocamlTests/BoolTest/toStringTest.ml delete mode 100644 test/ocamlTests/BoolTest/xorTest.ml delete mode 100644 test/ocamlTests/CharTest/fromCodeTest.ml delete mode 100644 test/ocamlTests/CharTest/fromStringTest.ml delete mode 100644 test/ocamlTests/CharTest/isAlphanumericTest.ml delete mode 100644 test/ocamlTests/CharTest/isDigitTest.ml delete mode 100644 test/ocamlTests/CharTest/isLetterTest.ml delete mode 100644 test/ocamlTests/CharTest/isLowercaseTest.ml delete mode 100644 test/ocamlTests/CharTest/isPrintableTest.ml delete mode 100644 test/ocamlTests/CharTest/isUppercaseTest.ml delete mode 100644 test/ocamlTests/CharTest/isWhitespaceTest.ml delete mode 100644 test/ocamlTests/CharTest/toCodeTest.ml delete mode 100644 test/ocamlTests/CharTest/toDigitTest.ml delete mode 100644 test/ocamlTests/CharTest/toLowercaseTest.ml delete mode 100644 test/ocamlTests/CharTest/toStringTest.ml delete mode 100644 test/ocamlTests/CharTest/toUppercaseTest.ml delete mode 100644 test/ocamlTests/FloatTest.ml delete mode 100644 test/ocamlTests/IntTest/absoluteTest.ml delete mode 100644 test/ocamlTests/IntTest/addTest.ml delete mode 100644 test/ocamlTests/IntTest/clampTest.ml delete mode 100644 test/ocamlTests/IntTest/divideFloatTest.ml delete mode 100644 test/ocamlTests/IntTest/divideTest.ml delete mode 100644 test/ocamlTests/IntTest/fromStringTest.ml delete mode 100644 test/ocamlTests/IntTest/inRangeTest.ml delete mode 100644 test/ocamlTests/IntTest/isEvenTest.ml delete mode 100644 test/ocamlTests/IntTest/isOddTest.ml delete mode 100644 test/ocamlTests/IntTest/maximumTest.ml delete mode 100644 test/ocamlTests/IntTest/minimumTest.ml delete mode 100644 test/ocamlTests/IntTest/moduloTest.ml delete mode 100644 test/ocamlTests/IntTest/multiplyTest.ml delete mode 100644 test/ocamlTests/IntTest/negateTest.ml delete mode 100644 test/ocamlTests/IntTest/powerTest.ml delete mode 100644 test/ocamlTests/IntTest/remainderTest.ml delete mode 100644 test/ocamlTests/IntTest/subtractTest.ml delete mode 100644 test/ocamlTests/IntTest/toFloatTest.ml delete mode 100644 test/ocamlTests/IntTest/toStringTest.ml delete mode 100644 test/rescriptTests/BoolTest/compareTest.res delete mode 100644 test/rescriptTests/BoolTest/equalTest.res delete mode 100644 test/rescriptTests/BoolTest/fromIntTest.res delete mode 100644 test/rescriptTests/BoolTest/fromStringTest.res delete mode 100644 test/rescriptTests/BoolTest/toIntTest.res delete mode 100644 test/rescriptTests/BoolTest/toStringTest.res delete mode 100644 test/rescriptTests/BoolTest/xorTest.res delete mode 100644 test/rescriptTests/CharTest/fromCodeTest.res delete mode 100644 test/rescriptTests/CharTest/fromStringTest.res delete mode 100644 test/rescriptTests/CharTest/isAlphanumericTest.res delete mode 100644 test/rescriptTests/CharTest/isDigitTest.res delete mode 100644 test/rescriptTests/CharTest/isLetterTest.res delete mode 100644 test/rescriptTests/CharTest/isLowercaseTest.res delete mode 100644 test/rescriptTests/CharTest/isPrintableTest.res delete mode 100644 test/rescriptTests/CharTest/isUppercaseTest.res delete mode 100644 test/rescriptTests/CharTest/isWhitespaceTest.res delete mode 100644 test/rescriptTests/CharTest/toCodeTest.res delete mode 100644 test/rescriptTests/CharTest/toDigitTest.res delete mode 100644 test/rescriptTests/CharTest/toLowercaseTest.res delete mode 100644 test/rescriptTests/CharTest/toStringTest.res delete mode 100644 test/rescriptTests/CharTest/toUppercaseTest.res delete mode 100644 test/rescriptTests/FloatTest.res delete mode 100644 test/rescriptTests/IntTest/absoluteTest.res delete mode 100644 test/rescriptTests/IntTest/addTest.res delete mode 100644 test/rescriptTests/IntTest/clampTest.res delete mode 100644 test/rescriptTests/IntTest/divideFloatTest.res delete mode 100644 test/rescriptTests/IntTest/divideTest.res delete mode 100644 test/rescriptTests/IntTest/fromStringTest.res delete mode 100644 test/rescriptTests/IntTest/inRangeTest.res delete mode 100644 test/rescriptTests/IntTest/isEvenTest.res delete mode 100644 test/rescriptTests/IntTest/isOddTest.res delete mode 100644 test/rescriptTests/IntTest/maximumTest.res delete mode 100644 test/rescriptTests/IntTest/minimumTest.res delete mode 100644 test/rescriptTests/IntTest/moduloTest.res delete mode 100644 test/rescriptTests/IntTest/multiplyTest.res delete mode 100644 test/rescriptTests/IntTest/negateTest.res delete mode 100644 test/rescriptTests/IntTest/powerTest.res delete mode 100644 test/rescriptTests/IntTest/remainderTest.res delete mode 100644 test/rescriptTests/IntTest/subtractTest.res delete mode 100644 test/rescriptTests/IntTest/toFloatTest.res delete mode 100644 test/rescriptTests/IntTest/toStringTest.res diff --git a/src/generateTest.res b/src/generateTest.res index bc7be4ac..d2fa22ed 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -21,118 +21,186 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" +let finalresultR = ref("") +let finalresultRR = ref("") +let finalresultOO = ref("") +let finalresultFF = ref("") +let finalresultF = ref("") +let finalresultO = ref("") +let \"module" = ref("") +let resultsRS = [] +let resultsFS = [] +let resultsOR = [] +// 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 file = readFileSync(~name="../json-files/Float.turns.json", #utf8) -let myData = parseIntoMyData(file) -let name = myData.name -let returnType = myData.returnType -let \"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 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# ([||]) - } + 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 type int + 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) + newInput := Js.Array.toString(test.inputs) + newInputR := Js.Array.toString(test.inputs) + newInputOF := Js.Array.toString(test.inputs) + } + } else { + //param length > 1 type + newInput := Js_array.joinWith(",", test.inputs) + newInputOF := Js_array.joinWith(" ", test.inputs) + newInputR := Js_array.joinWith(",", test.inputs) } - } else { - //param length > 1 type int - newInput := Js_array.joinWith(",", test.inputs) - newInputOF := Js_array.joinWith(" ", test.inputs) - newInputR := Js_array.joinWith(",", test.inputs) - } - let resultRescript = `test ("${name}(${newInputR.contents})", () => expect(${output.contents != "exception" - ? `${\"module"}.${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"}.${name}(${newInput.contents})) |> toThrow)`} \n` - resultsR->Belt.Array.push(resultRescript) + 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 resultOcaml = `test "${name}(${newInput.contents})" (fun () -> expect (${output.contents != "exception" - ? `${\"module"}.${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) + }) - let resultFSharp = `testCase "${name}(${newInput.contents})" \n<| fun _ -> \n ${output.contents != "exception" - ? `let expected = ${output.contents}\n Expect.equal expected (${\"module"}.${name} ${newInputOF.contents}) "error"` - : `Expect.equal (${\"module"}.${name} ${newInputOF.contents}) |> failwith "error"`}\n` - resultsF->Belt.Array.push(resultFSharp) + finalresultR := Js.Array.joinWith("", resultsR) + resultsRS->Belt.Array.push(finalresultR.contents) + finalresultF := Js.Array.joinWith("", resultsF) + resultsFS->Belt.Array.push(finalresultF.contents) + finalresultO := Js.Array.joinWith("", resultsO) + resultsOR->Belt.Array.push(finalresultO.contents) }) -let finalresultR = Js.Array.joinWith("", resultsR) -let finalresultF = Js.Array.joinWith("", resultsF) -let finalresultO = Js.Array.joinWith("", resultsO) -%raw("Fs.appendFileSync(`../test/rescriptTests/FloatTest.res`, finalresultR, 'utf8')") -%raw("Fs.appendFileSync(`../test/ocamlTests/FloatTest.ml`, finalresultO, 'utf8')") -%raw("Fs.appendFileSync(`../test/fsharpTests/FloatTest.fs`, finalresultF, 'utf8')") -// Node.Fs.writeFileSync( -// `../test/rescriptTests/CharTest/${name}Test.res`, -// finalresultR, -// #utf8, -// ) -// Node.Fs.writeFileSync( -// `../test/ocamlTests/CharTest/${name}Test.ml`, -// finalresultO, -// #utf8, -// ) -// Node.Fs.writeFileSync( -// `../test/fsharpTests/CharTest/${name}Test.fs`, -// finalresultF, -// #utf8, -// ) +finalresultRR := Js.Array.joinWith("", resultsRS) +let testHeaderR = `open Tablecloth\nopen AlcoJest\n\nlet suite= suite("${\"module".contents}", () => {\n` +let testCasesR = `${testHeaderR} ${finalresultRR.contents}})` +finalresultOO := Js.Array.joinWith("", resultsOR) +let testHeaderO = `open Tablecloth\nopen AlcoJest\n\nlet suite =\n suite "${\"module".contents}" (fun () ->\n` +let testCasesO = `${testHeaderO} ${finalresultOO.contents})` +finalresultFF := Js.Array.joinWith("", resultsFS) +let testHeaderF = `open Tablecloth\nopen Expecto\n\n[]\nlet tests =\n testList\n "${\"module".contents}"\n[` +let testCasesF = `${testHeaderF} ${finalresultFF.contents}]` +Node.Fs.writeFileSync( + `../test/rescriptTests/${\"module".contents}Test.res`, + testCasesR, + #utf8, +) +Node.Fs.writeFileSync( + `../test/ocamlTests/${\"module".contents}Test.ml`, + testCasesO, + #utf8, +) +Node.Fs.writeFileSync( + `../test/fsharpTests/${\"module".contents}Test.fs`, + testCasesF, + #utf8, +) diff --git a/test/fsharpTests/BoolTest.fs b/test/fsharpTests/BoolTest.fs index de494db4..2020929b 100644 --- a/test/fsharpTests/BoolTest.fs +++ b/test/fsharpTests/BoolTest.fs @@ -1,4 +1,11 @@ -testCase "compare(true,true)" +open Tablecloth +open Expecto + +[] +let tests = + testList + "Bool" +[ testCase "compare(true,true)" <| fun _ -> let expected = 0 Expect.equal expected (Bool.compare true true) "error" @@ -102,3 +109,4 @@ 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/BoolTest/compareTest.fs b/test/fsharpTests/BoolTest/compareTest.fs deleted file mode 100644 index 1652bbba..00000000 --- a/test/fsharpTests/BoolTest/compareTest.fs +++ /dev/null @@ -1,16 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/equalTest.fs b/test/fsharpTests/BoolTest/equalTest.fs deleted file mode 100644 index b4f53fc3..00000000 --- a/test/fsharpTests/BoolTest/equalTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/fromIntTest.fs b/test/fsharpTests/BoolTest/fromIntTest.fs deleted file mode 100644 index 61d11273..00000000 --- a/test/fsharpTests/BoolTest/fromIntTest.fs +++ /dev/null @@ -1,28 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/fromStringTest.fs b/test/fsharpTests/BoolTest/fromStringTest.fs deleted file mode 100644 index 44dcdb72..00000000 --- a/test/fsharpTests/BoolTest/fromStringTest.fs +++ /dev/null @@ -1,16 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/toIntTest.fs b/test/fsharpTests/BoolTest/toIntTest.fs deleted file mode 100644 index 766d7956..00000000 --- a/test/fsharpTests/BoolTest/toIntTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/toStringTest.fs b/test/fsharpTests/BoolTest/toStringTest.fs deleted file mode 100644 index 179dc9c1..00000000 --- a/test/fsharpTests/BoolTest/toStringTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/fsharpTests/BoolTest/xorTest.fs b/test/fsharpTests/BoolTest/xorTest.fs deleted file mode 100644 index 1d7856f9..00000000 --- a/test/fsharpTests/BoolTest/xorTest.fs +++ /dev/null @@ -1,16 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest.fs b/test/fsharpTests/CharTest.fs index 1b83910a..f398474f 100644 --- a/test/fsharpTests/CharTest.fs +++ b/test/fsharpTests/CharTest.fs @@ -1,4 +1,11 @@ -testCase "fromCode(97)" +open Tablecloth +open Expecto + +[] +let tests = + testList + "Char" +[ testCase "fromCode(97)" <| fun _ -> let expected = Some('a') Expect.equal expected (Char.fromCode 97) "error" @@ -190,3 +197,4 @@ 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/CharTest/fromCodeTest.fs b/test/fsharpTests/CharTest/fromCodeTest.fs deleted file mode 100644 index e98bcdd9..00000000 --- a/test/fsharpTests/CharTest/fromCodeTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/fromStringTest.fs b/test/fsharpTests/CharTest/fromStringTest.fs deleted file mode 100644 index be259a53..00000000 --- a/test/fsharpTests/CharTest/fromStringTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isAlphanumericTest.fs b/test/fsharpTests/CharTest/isAlphanumericTest.fs deleted file mode 100644 index 781ec02a..00000000 --- a/test/fsharpTests/CharTest/isAlphanumericTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isDigitTest.fs b/test/fsharpTests/CharTest/isDigitTest.fs deleted file mode 100644 index 6ce7ca7a..00000000 --- a/test/fsharpTests/CharTest/isDigitTest.fs +++ /dev/null @@ -1,44 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isLetterTest.fs b/test/fsharpTests/CharTest/isLetterTest.fs deleted file mode 100644 index 7325c539..00000000 --- a/test/fsharpTests/CharTest/isLetterTest.fs +++ /dev/null @@ -1,24 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isLowercaseTest.fs b/test/fsharpTests/CharTest/isLowercaseTest.fs deleted file mode 100644 index dd11a502..00000000 --- a/test/fsharpTests/CharTest/isLowercaseTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isPrintableTest.fs b/test/fsharpTests/CharTest/isPrintableTest.fs deleted file mode 100644 index 94a898d4..00000000 --- a/test/fsharpTests/CharTest/isPrintableTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -testCase "isPrintable('~')" -<| fun _ -> - let expected = true - Expect.equal expected (Char.isPrintable '~') "error" -testCase "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" -<| fun _ -> - let expected = Some(false) - Expect.equal expected (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) "error" diff --git a/test/fsharpTests/CharTest/isUppercaseTest.fs b/test/fsharpTests/CharTest/isUppercaseTest.fs deleted file mode 100644 index b46385a6..00000000 --- a/test/fsharpTests/CharTest/isUppercaseTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/isWhitespaceTest.fs b/test/fsharpTests/CharTest/isWhitespaceTest.fs deleted file mode 100644 index e1123438..00000000 --- a/test/fsharpTests/CharTest/isWhitespaceTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/toCodeTest.fs b/test/fsharpTests/CharTest/toCodeTest.fs deleted file mode 100644 index 1c06c903..00000000 --- a/test/fsharpTests/CharTest/toCodeTest.fs +++ /dev/null @@ -1,4 +0,0 @@ -testCase "toCode('a')" -<| fun _ -> - let expected = 97 - Expect.equal expected (Char.toCode 'a') "error" diff --git a/test/fsharpTests/CharTest/toDigitTest.fs b/test/fsharpTests/CharTest/toDigitTest.fs deleted file mode 100644 index 4922c697..00000000 --- a/test/fsharpTests/CharTest/toDigitTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/toLowercaseTest.fs b/test/fsharpTests/CharTest/toLowercaseTest.fs deleted file mode 100644 index efb285c0..00000000 --- a/test/fsharpTests/CharTest/toLowercaseTest.fs +++ /dev/null @@ -1,16 +0,0 @@ -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" diff --git a/test/fsharpTests/CharTest/toStringTest.fs b/test/fsharpTests/CharTest/toStringTest.fs deleted file mode 100644 index 5f568646..00000000 --- a/test/fsharpTests/CharTest/toStringTest.fs +++ /dev/null @@ -1,4 +0,0 @@ -testCase "toString('a')" -<| fun _ -> - let expected = "a" - Expect.equal expected (Char.toString 'a') "error" diff --git a/test/fsharpTests/CharTest/toUppercaseTest.fs b/test/fsharpTests/CharTest/toUppercaseTest.fs deleted file mode 100644 index f375c492..00000000 --- a/test/fsharpTests/CharTest/toUppercaseTest.fs +++ /dev/null @@ -1,16 +0,0 @@ -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" diff --git a/test/fsharpTests/FloatTest.fs b/test/fsharpTests/FloatTest.fs deleted file mode 100644 index cb387844..00000000 --- a/test/fsharpTests/FloatTest.fs +++ /dev/null @@ -1,313 +0,0 @@ -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 "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 "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 "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 "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 "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 "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 "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" diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs index bf7c3566..7534e6e3 100644 --- a/test/fsharpTests/IntTest.fs +++ b/test/fsharpTests/IntTest.fs @@ -1,398 +1,325 @@ -testCase "absolute(8)" -<| fun _ -> +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 _ -> +testCase "absolute(-7)" +<| fun _ -> let expected = 7 Expect.equal expected (Int.absolute -7) "error" - -testCase "absolute(0)" -<| fun _ -> +testCase "absolute(0)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.absolute 0) "error" - -testCase "add(1,2)" -<| fun _ -> +testCase "add(1,2)" +<| fun _ -> let expected = 3 Expect.equal expected (Int.add 1 2) "error" - -testCase "add(1,1)" -<| fun _ -> +testCase "add(1,1)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.add 1 1) "error" - -testCase "clamp(5,0,8)" -<| fun _ -> +testCase "clamp(5,0,8)" +<| fun _ -> let expected = 5 Expect.equal expected (Int.clamp 5 0 8) "error" - -testCase "clamp(9,0,8)" -<| fun _ -> +testCase "clamp(9,0,8)" +<| fun _ -> let expected = 8 Expect.equal expected (Int.clamp 9 0 8) "error" - -testCase "clamp(1,2,8)" -<| fun _ -> +testCase "clamp(1,2,8)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.clamp 1 2 8) "error" - -testCase "clamp(5,-10,-5)" -<| fun _ -> +testCase "clamp(5,-10,-5)" +<| fun _ -> let expected = -5 Expect.equal expected (Int.clamp 5 -10 -5) "error" - -testCase "clamp(-15,-10,-5)" -<| fun _ -> +testCase "clamp(-15,-10,-5)" +<| fun _ -> let expected = -10 Expect.equal expected (Int.clamp -15 -10 -5) "error" - -testCase "clamp(3,7,1)" -<| fun _ -> Expect.equal (Int.clamp 3 7 1) |> failwith "error" - -testCase "divideFloat(3,2)" -<| fun _ -> +testCase "clamp(3,7,1)" +<| fun _ -> + Expect.equal (Int.clamp 3 7 1) |> failwith "error" +testCase "divide(3,2)" +<| fun _ -> + let expected = 1 + Expect.equal expected (Int.divide 3 2) "error" +testCase "divide(3,0)" +<| fun _ -> + Expect.equal (Int.divide 3 0) |> failwith "error" +testCase "divide(27,5)" +<| fun _ -> + let expected = 5 + Expect.equal expected (Int.divide 27 5) "error" +testCase "divideFloat(3,2)" +<| fun _ -> let expected = 1.5 Expect.equal expected (Int.divideFloat 3 2) "error" - -testCase "divideFloat(27,5)" -<| fun _ -> +testCase "divideFloat(27,5)" +<| fun _ -> let expected = 5.4 Expect.equal expected (Int.divideFloat 27 5) "error" - -testCase "divideFloat(8,4)" -<| fun _ -> +testCase "divideFloat(8,4)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.divideFloat 8 4) "error" - -testCase "divideFloat(8,0)" -<| fun _ -> +testCase "divideFloat(8,0)" +<| fun _ -> let expected = Float.infinity Expect.equal expected (Int.divideFloat 8 0) "error" - -testCase "divideFloat(-8,0)" -<| fun _ -> +testCase "divideFloat(-8,0)" +<| fun _ -> let expected = Float.negativeInfinity Expect.equal expected (Int.divideFloat -8 0) "error" - -testCase "divide(3,2)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.divide 3 2) "error" - -testCase "divide(3,0)" -<| fun _ -> Expect.equal (Int.divide 3 0) |> failwith "error" - -testCase "divide(27,5)" -<| fun _ -> - let expected = 5 - Expect.equal expected (Int.divide 27 5) "error" - -testCase "fromString(" 0 ")" -<| fun _ -> +testCase "fromString("0")" +<| fun _ -> let expected = Some(0) Expect.equal expected (Int.fromString "0") "error" - -testCase "fromString(" - 0 ")" -<| fun _ -> +testCase "fromString("-0")" +<| fun _ -> let expected = Some(-0) Expect.equal expected (Int.fromString "-0") "error" - -testCase "fromString(" 42 ")" -<| fun _ -> +testCase "fromString("42")" +<| fun _ -> let expected = Some(42) Expect.equal expected (Int.fromString "42") "error" - -testCase "fromString(" 123_456 ")" -<| fun _ -> +testCase "fromString("123_456")" +<| fun _ -> let expected = Some(123_456) Expect.equal expected (Int.fromString "123_456") "error" - -testCase "fromString(" - 42 ")" -<| fun _ -> +testCase "fromString("-42")" +<| fun _ -> let expected = Some(-42) Expect.equal expected (Int.fromString "-42") "error" - -testCase "fromString(" 0XFF ")" -<| fun _ -> +testCase "fromString("0XFF")" +<| fun _ -> let expected = Some(255) Expect.equal expected (Int.fromString "0XFF") "error" - -testCase "fromString(" 0X000A ")" -<| fun _ -> +testCase "fromString("0X000A")" +<| fun _ -> let expected = Some(10) Expect.equal expected (Int.fromString "0X000A") "error" - -testCase "fromString(" Infinity ")" -<| fun _ -> +testCase "fromString("Infinity")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString "Infinity") "error" - -testCase "fromString(" - Infinity ")" -<| fun _ -> +testCase "fromString("-Infinity")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString "-Infinity") "error" - -testCase "fromString(" NaN ")" -<| fun _ -> +testCase "fromString("NaN")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString "NaN") "error" - -testCase "fromString(" abc ")" -<| fun _ -> +testCase "fromString("abc")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString "abc") "error" - -testCase "fromString(" -- 4 ")" -<| fun _ -> +testCase "fromString("--4")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString "--4") "error" - -testCase "fromString(" ")" -<| fun _ -> +testCase "fromString(" ")" +<| fun _ -> let expected = None Expect.equal expected (Int.fromString " ") "error" - -testCase "inRange(3,2,4)" -<| fun _ -> +testCase "inRange(3,2,4)" +<| fun _ -> let expected = true Expect.equal expected (Int.inRange 3 2 4) "error" - -testCase "inRange(8,2,4)" -<| fun _ -> +testCase "inRange(8,2,4)" +<| fun _ -> let expected = false Expect.equal expected (Int.inRange 8 2 4) "error" - -testCase "inRange(1,2,4)" -<| fun _ -> +testCase "inRange(1,2,4)" +<| fun _ -> let expected = false Expect.equal expected (Int.inRange 1 2 4) "error" - -testCase "inRange(2,1,2)" -<| fun _ -> +testCase "inRange(2,1,2)" +<| fun _ -> let expected = false Expect.equal expected (Int.inRange 2 1 2) "error" - -testCase "inRange(-6,-7,-5)" -<| fun _ -> +testCase "inRange(-6,-7,-5)" +<| fun _ -> let expected = true Expect.equal expected (Int.inRange -6 -7 -5) "error" - -testCase "inRange(3,7,1)" -<| fun _ -> Expect.equal (Int.inRange 3 7 1) |> failwith "error" - -testCase "isEven(8)" -<| fun _ -> +testCase "inRange(3,7,1)" +<| fun _ -> + Expect.equal (Int.inRange 3 7 1) |> failwith "error" +testCase "isEven(8)" +<| fun _ -> let expected = true Expect.equal expected (Int.isEven 8) "error" - -testCase "isEven(9)" -<| fun _ -> +testCase "isEven(9)" +<| fun _ -> let expected = false Expect.equal expected (Int.isEven 9) "error" - -testCase "isEven(0)" -<| fun _ -> +testCase "isEven(0)" +<| fun _ -> let expected = true Expect.equal expected (Int.isEven 0) "error" - -testCase "isOdd(8)" -<| fun _ -> +testCase "isOdd(8)" +<| fun _ -> let expected = false Expect.equal expected (Int.isOdd 8) "error" - -testCase "isOdd(9)" -<| fun _ -> +testCase "isOdd(9)" +<| fun _ -> let expected = true Expect.equal expected (Int.isOdd 9) "error" - -testCase "isOdd(0)" -<| fun _ -> +testCase "isOdd(0)" +<| fun _ -> let expected = false Expect.equal expected (Int.isOdd 0) "error" - -testCase "maximum(8,18)" -<| fun _ -> +testCase "maximum(8,18)" +<| fun _ -> let expected = 18 Expect.equal expected (Int.maximum 8 18) "error" - -testCase "maximum(5,0)" -<| fun _ -> +testCase "maximum(5,0)" +<| fun _ -> let expected = 5 Expect.equal expected (Int.maximum 5 0) "error" - -testCase "maximum(-4,-1)" -<| fun _ -> +testCase "maximum(-4,-1)" +<| fun _ -> let expected = -1 Expect.equal expected (Int.maximum -4 -1) "error" - -testCase "minimum(8,18)" -<| fun _ -> +testCase "minimum(8,18)" +<| fun _ -> let expected = 8 Expect.equal expected (Int.minimum 8 18) "error" - -testCase "minimum(5,0)" -<| fun _ -> +testCase "minimum(5,0)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.minimum 5 0) "error" - -testCase "minimum(-4,-1)" -<| fun _ -> +testCase "minimum(-4,-1)" +<| fun _ -> let expected = -4 Expect.equal expected (Int.minimum -4 -1) "error" - -testCase "modulo(-4,3)" -<| fun _ -> +testCase "modulo(-4,3)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.modulo -4 3) "error" - -testCase "modulo(-3,3)" -<| fun _ -> +testCase "modulo(-3,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.modulo -3 3) "error" - -testCase "modulo(-2,3)" -<| fun _ -> +testCase "modulo(-2,3)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.modulo -2 3) "error" - -testCase "modulo(-1,3)" -<| fun _ -> +testCase "modulo(-1,3)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.modulo -1 3) "error" - -testCase "modulo(0,3)" -<| fun _ -> +testCase "modulo(0,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.modulo 0 3) "error" - -testCase "modulo(1,3)" -<| fun _ -> +testCase "modulo(1,3)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.modulo 1 3) "error" - -testCase "modulo(2,3)" -<| fun _ -> +testCase "modulo(2,3)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.modulo 2 3) "error" - -testCase "modulo(3,3)" -<| fun _ -> +testCase "modulo(3,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.modulo 3 3) "error" - -testCase "modulo(4,3)" -<| fun _ -> +testCase "modulo(4,3)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.modulo 4 3) "error" - -testCase "multiply(2,7)" -<| fun _ -> +testCase "multiply(2,7)" +<| fun _ -> let expected = 14 Expect.equal expected (Int.multiply 2 7) "error" - -testCase "negate(8)" -<| fun _ -> +testCase "negate(8)" +<| fun _ -> let expected = -8 Expect.equal expected (Int.negate 8) "error" - -testCase "negate(-7)" -<| fun _ -> +testCase "negate(-7)" +<| fun _ -> let expected = 7 Expect.equal expected (Int.negate -7) "error" - -testCase "negate(0)" -<| fun _ -> +testCase "negate(0)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.negate 0) "error" - -testCase "power(7,3)" -<| fun _ -> +testCase "power(7,3)" +<| fun _ -> let expected = 343 Expect.equal expected (Int.power 7 3) "error" - -testCase "power(0,3)" -<| fun _ -> +testCase "power(0,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.power 0 3) "error" - -testCase "power(7,0)" -<| fun _ -> +testCase "power(7,0)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.power 7 0) "error" - -testCase "remainder(-4,3)" -<| fun _ -> +testCase "remainder(-4,3)" +<| fun _ -> let expected = -1 Expect.equal expected (Int.remainder -4 3) "error" - -testCase "remainder(-2,3)" -<| fun _ -> +testCase "remainder(-2,3)" +<| fun _ -> let expected = -2 Expect.equal expected (Int.remainder -2 3) "error" - -testCase "remainder(-1,3)" -<| fun _ -> +testCase "remainder(-1,3)" +<| fun _ -> let expected = -1 Expect.equal expected (Int.remainder -1 3) "error" - -testCase "remainder(0,3)" -<| fun _ -> +testCase "remainder(0,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.remainder 0 3) "error" - -testCase "remainder(1,3)" -<| fun _ -> +testCase "remainder(1,3)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.remainder 1 3) "error" - -testCase "remainder(2,3)" -<| fun _ -> +testCase "remainder(2,3)" +<| fun _ -> let expected = 2 Expect.equal expected (Int.remainder 2 3) "error" - -testCase "remainder(3,3)" -<| fun _ -> +testCase "remainder(3,3)" +<| fun _ -> let expected = 0 Expect.equal expected (Int.remainder 3 3) "error" - -testCase "remainder(4,3)" -<| fun _ -> +testCase "remainder(4,3)" +<| fun _ -> let expected = 1 Expect.equal expected (Int.remainder 4 3) "error" - -testCase "subtract(4,3)" -<| fun _ -> +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(5)" -<| fun _ -> +testCase "toFloat(5)" +<| fun _ -> let expected = 5. Expect.equal expected (Int.toFloat 5) "error" - -testCase "toFloat(0)" -<| fun _ -> +testCase "toFloat(0)" +<| fun _ -> let expected = 0. Expect.equal expected (Int.toFloat 0) "error" - -testCase "toFloat(-7)" -<| fun _ -> +testCase "toFloat(-7)" +<| fun _ -> let expected = -7. Expect.equal expected (Int.toFloat -7) "error" - -testCase "toString(1)" -<| fun _ -> +testCase "toString(1)" +<| fun _ -> let expected = "1" Expect.equal expected (Int.toString 1) "error" - -testCase "toString(-1)" -<| fun _ -> +testCase "toString(-1)" +<| fun _ -> let expected = "-1" Expect.equal expected (Int.toString -1) "error" +] \ No newline at end of file diff --git a/test/fsharpTests/IntTest/absoluteTest.fs b/test/fsharpTests/IntTest/absoluteTest.fs deleted file mode 100644 index 550d5297..00000000 --- a/test/fsharpTests/IntTest/absoluteTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/addTest.fs b/test/fsharpTests/IntTest/addTest.fs deleted file mode 100644 index 65f200bc..00000000 --- a/test/fsharpTests/IntTest/addTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/clampTest.fs b/test/fsharpTests/IntTest/clampTest.fs deleted file mode 100644 index a1b8e1be..00000000 --- a/test/fsharpTests/IntTest/clampTest.fs +++ /dev/null @@ -1,23 +0,0 @@ -testCase "clamp(5,0,8)" -<| fun _ -> - let expected = 5 - Expect.equal expected (Int.clamp 5 0 8) "error" -testCase "clamp(9,0,8)" -<| fun _ -> - let expected = 8 - Expect.equal expected (Int.clamp 9 0 8) "error" -testCase "clamp(1,2,8)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.clamp 1 2 8) "error" -testCase "clamp(5,-10,-5)" -<| fun _ -> - let expected = -5 - Expect.equal expected (Int.clamp 5 -10 -5) "error" -testCase "clamp(-15,-10,-5)" -<| fun _ -> - let expected = -10 - Expect.equal expected (Int.clamp -15 -10 -5) "error" -testCase "clamp(3,7,1)" -<| fun _ -> - Expect.equal (Int.clamp 3 7 1) |> failwith "error" diff --git a/test/fsharpTests/IntTest/divideFloatTest.fs b/test/fsharpTests/IntTest/divideFloatTest.fs deleted file mode 100644 index 7ffac9b2..00000000 --- a/test/fsharpTests/IntTest/divideFloatTest.fs +++ /dev/null @@ -1,20 +0,0 @@ -testCase "divideFloat(3,2)" -<| fun _ -> - let expected = 1.5 - Expect.equal expected (Int.divideFloat 3 2) "error" -testCase "divideFloat(27,5)" -<| fun _ -> - let expected = 5.4 - Expect.equal expected (Int.divideFloat 27 5) "error" -testCase "divideFloat(8,4)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.divideFloat 8 4) "error" -testCase "divideFloat(8,0)" -<| fun _ -> - let expected = Float.infinity - Expect.equal expected (Int.divideFloat 8 0) "error" -testCase "divideFloat(-8,0)" -<| fun _ -> - let expected = Float.negativeInfinity - Expect.equal expected (Int.divideFloat -8 0) "error" diff --git a/test/fsharpTests/IntTest/divideTest.fs b/test/fsharpTests/IntTest/divideTest.fs deleted file mode 100644 index 5600256e..00000000 --- a/test/fsharpTests/IntTest/divideTest.fs +++ /dev/null @@ -1,11 +0,0 @@ -testCase "divide(3,2)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.divide 3 2) "error" -testCase "divide(3,0)" -<| fun _ -> - Expect.equal (Int.divide 3 0) |> failwith "error" -testCase "divide(27,5)" -<| fun _ -> - let expected = 5 - Expect.equal expected (Int.divide 27 5) "error" diff --git a/test/fsharpTests/IntTest/fromStringTest.fs b/test/fsharpTests/IntTest/fromStringTest.fs deleted file mode 100644 index 8806c092..00000000 --- a/test/fsharpTests/IntTest/fromStringTest.fs +++ /dev/null @@ -1,52 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/inRangeTest.fs b/test/fsharpTests/IntTest/inRangeTest.fs deleted file mode 100644 index ad25f7c5..00000000 --- a/test/fsharpTests/IntTest/inRangeTest.fs +++ /dev/null @@ -1,23 +0,0 @@ -testCase "inRange(3,2,4)" -<| fun _ -> - let expected = true - Expect.equal expected (Int.inRange 3 2 4) "error" -testCase "inRange(8,2,4)" -<| fun _ -> - let expected = false - Expect.equal expected (Int.inRange 8 2 4) "error" -testCase "inRange(1,2,4)" -<| fun _ -> - let expected = false - Expect.equal expected (Int.inRange 1 2 4) "error" -testCase "inRange(2,1,2)" -<| fun _ -> - let expected = false - Expect.equal expected (Int.inRange 2 1 2) "error" -testCase "inRange(-6,-7,-5)" -<| fun _ -> - let expected = true - Expect.equal expected (Int.inRange -6 -7 -5) "error" -testCase "inRange(3,7,1)" -<| fun _ -> - Expect.equal (Int.inRange 3 7 1) |> failwith "error" diff --git a/test/fsharpTests/IntTest/isEvenTest.fs b/test/fsharpTests/IntTest/isEvenTest.fs deleted file mode 100644 index e37bc618..00000000 --- a/test/fsharpTests/IntTest/isEvenTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/isOddTest.fs b/test/fsharpTests/IntTest/isOddTest.fs deleted file mode 100644 index aafb3d80..00000000 --- a/test/fsharpTests/IntTest/isOddTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/maximumTest.fs b/test/fsharpTests/IntTest/maximumTest.fs deleted file mode 100644 index 9a1e4d3f..00000000 --- a/test/fsharpTests/IntTest/maximumTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/minimumTest.fs b/test/fsharpTests/IntTest/minimumTest.fs deleted file mode 100644 index d7a579ab..00000000 --- a/test/fsharpTests/IntTest/minimumTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/moduloTest.fs b/test/fsharpTests/IntTest/moduloTest.fs deleted file mode 100644 index 18efe51c..00000000 --- a/test/fsharpTests/IntTest/moduloTest.fs +++ /dev/null @@ -1,36 +0,0 @@ -testCase "modulo(-4,3)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.modulo -4 3) "error" -testCase "modulo(-3,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.modulo -3 3) "error" -testCase "modulo(-2,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.modulo -2 3) "error" -testCase "modulo(-1,3)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.modulo -1 3) "error" -testCase "modulo(0,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.modulo 0 3) "error" -testCase "modulo(1,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.modulo 1 3) "error" -testCase "modulo(2,3)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.modulo 2 3) "error" -testCase "modulo(3,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.modulo 3 3) "error" -testCase "modulo(4,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.modulo 4 3) "error" diff --git a/test/fsharpTests/IntTest/multiplyTest.fs b/test/fsharpTests/IntTest/multiplyTest.fs deleted file mode 100644 index 1d996419..00000000 --- a/test/fsharpTests/IntTest/multiplyTest.fs +++ /dev/null @@ -1,4 +0,0 @@ -testCase "multiply(2,7)" -<| fun _ -> - let expected = 14 - Expect.equal expected (Int.multiply 2 7) "error" diff --git a/test/fsharpTests/IntTest/negateTest.fs b/test/fsharpTests/IntTest/negateTest.fs deleted file mode 100644 index 819b6fed..00000000 --- a/test/fsharpTests/IntTest/negateTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/powerTest.fs b/test/fsharpTests/IntTest/powerTest.fs deleted file mode 100644 index 63c8d031..00000000 --- a/test/fsharpTests/IntTest/powerTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -testCase "power(7,3)" -<| fun _ -> - let expected = 343 - Expect.equal expected (Int.power 7 3) "error" -testCase "power(0,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.power 0 3) "error" -testCase "power(7,0)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.power 7 0) "error" diff --git a/test/fsharpTests/IntTest/remainderTest.fs b/test/fsharpTests/IntTest/remainderTest.fs deleted file mode 100644 index 1bc443d3..00000000 --- a/test/fsharpTests/IntTest/remainderTest.fs +++ /dev/null @@ -1,32 +0,0 @@ -testCase "remainder(-4,3)" -<| fun _ -> - let expected = -1 - Expect.equal expected (Int.remainder -4 3) "error" -testCase "remainder(-2,3)" -<| fun _ -> - let expected = -2 - Expect.equal expected (Int.remainder -2 3) "error" -testCase "remainder(-1,3)" -<| fun _ -> - let expected = -1 - Expect.equal expected (Int.remainder -1 3) "error" -testCase "remainder(0,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.remainder 0 3) "error" -testCase "remainder(1,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.remainder 1 3) "error" -testCase "remainder(2,3)" -<| fun _ -> - let expected = 2 - Expect.equal expected (Int.remainder 2 3) "error" -testCase "remainder(3,3)" -<| fun _ -> - let expected = 0 - Expect.equal expected (Int.remainder 3 3) "error" -testCase "remainder(4,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.remainder 4 3) "error" diff --git a/test/fsharpTests/IntTest/subtractTest.fs b/test/fsharpTests/IntTest/subtractTest.fs deleted file mode 100644 index 5932c51e..00000000 --- a/test/fsharpTests/IntTest/subtractTest.fs +++ /dev/null @@ -1,4 +0,0 @@ -testCase "subtract(4,3)" -<| fun _ -> - let expected = 1 - Expect.equal expected (Int.subtract 4 3) "error" diff --git a/test/fsharpTests/IntTest/toFloatTest.fs b/test/fsharpTests/IntTest/toFloatTest.fs deleted file mode 100644 index acf151dc..00000000 --- a/test/fsharpTests/IntTest/toFloatTest.fs +++ /dev/null @@ -1,12 +0,0 @@ -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" diff --git a/test/fsharpTests/IntTest/toStringTest.fs b/test/fsharpTests/IntTest/toStringTest.fs deleted file mode 100644 index 615e0209..00000000 --- a/test/fsharpTests/IntTest/toStringTest.fs +++ /dev/null @@ -1,8 +0,0 @@ -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" diff --git a/test/ocamlTests/BoolTest.ml b/test/ocamlTests/BoolTest.ml index 95657d4a..b82473fc 100644 --- a/test/ocamlTests/BoolTest.ml +++ b/test/ocamlTests/BoolTest.ml @@ -1,4 +1,9 @@ -test "compare(true,true)" (fun () -> expect (Bool.compare true true) |> toEqual Eq.int 0) ; +open Tablecloth +open AlcoJest + +let suite = + suite "Bool" (fun () -> + 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) ; @@ -24,3 +29,4 @@ test "xor(true,true)" (fun () -> expect (Bool.xor true true) |> toEqual Eq.bool 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/BoolTest/compareTest.ml b/test/ocamlTests/BoolTest/compareTest.ml deleted file mode 100644 index 88b7bde8..00000000 --- a/test/ocamlTests/BoolTest/compareTest.ml +++ /dev/null @@ -1,4 +0,0 @@ -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) ; diff --git a/test/ocamlTests/BoolTest/equalTest.ml b/test/ocamlTests/BoolTest/equalTest.ml deleted file mode 100644 index 39bc0f4f..00000000 --- a/test/ocamlTests/BoolTest/equalTest.ml +++ /dev/null @@ -1,3 +0,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) ; diff --git a/test/ocamlTests/BoolTest/fromIntTest.ml b/test/ocamlTests/BoolTest/fromIntTest.ml deleted file mode 100644 index fd267959..00000000 --- a/test/ocamlTests/BoolTest/fromIntTest.ml +++ /dev/null @@ -1,7 +0,0 @@ -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) ; diff --git a/test/ocamlTests/BoolTest/fromStringTest.ml b/test/ocamlTests/BoolTest/fromStringTest.ml deleted file mode 100644 index b90c6bf1..00000000 --- a/test/ocamlTests/BoolTest/fromStringTest.ml +++ /dev/null @@ -1,4 +0,0 @@ -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) ; diff --git a/test/ocamlTests/BoolTest/toIntTest.ml b/test/ocamlTests/BoolTest/toIntTest.ml deleted file mode 100644 index bf8da42e..00000000 --- a/test/ocamlTests/BoolTest/toIntTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "toInt(true)" (fun () -> expect (Bool.toInt true) |> toEqual Eq.int 1) ; -test "toInt(false)" (fun () -> expect (Bool.toInt false) |> toEqual Eq.int 0) ; diff --git a/test/ocamlTests/BoolTest/toStringTest.ml b/test/ocamlTests/BoolTest/toStringTest.ml deleted file mode 100644 index c92fcf06..00000000 --- a/test/ocamlTests/BoolTest/toStringTest.ml +++ /dev/null @@ -1,2 +0,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") ; diff --git a/test/ocamlTests/BoolTest/xorTest.ml b/test/ocamlTests/BoolTest/xorTest.ml deleted file mode 100644 index 64945658..00000000 --- a/test/ocamlTests/BoolTest/xorTest.ml +++ /dev/null @@ -1,4 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml index 32ba1854..83634219 100644 --- a/test/ocamlTests/CharTest.ml +++ b/test/ocamlTests/CharTest.ml @@ -1,4 +1,9 @@ -test "fromCode(97)" (fun () -> expect (Char.fromCode 97) |> toEqual (let open Eq in option char) Some('a')) ; +open Tablecloth +open AlcoJest + +let suite = + suite "Char" (fun () -> + 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')) ; @@ -46,3 +51,4 @@ test "toUppercase('a')" (fun () -> expect (Char.toUppercase 'a') |> toEqual Eq.c 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/CharTest/fromCodeTest.ml b/test/ocamlTests/CharTest/fromCodeTest.ml deleted file mode 100644 index 29ecd80b..00000000 --- a/test/ocamlTests/CharTest/fromCodeTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/fromStringTest.ml b/test/ocamlTests/CharTest/fromStringTest.ml deleted file mode 100644 index 2edd6514..00000000 --- a/test/ocamlTests/CharTest/fromStringTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/isAlphanumericTest.ml b/test/ocamlTests/CharTest/isAlphanumericTest.ml deleted file mode 100644 index 786836e3..00000000 --- a/test/ocamlTests/CharTest/isAlphanumericTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "isAlphanumeric('A')" (fun () -> expect (Char.isAlphanumeric 'A') |> toEqual Eq.bool true) ; -test "isAlphanumeric('?')" (fun () -> expect (Char.isAlphanumeric '?') |> toEqual Eq.bool false) ; diff --git a/test/ocamlTests/CharTest/isDigitTest.ml b/test/ocamlTests/CharTest/isDigitTest.ml deleted file mode 100644 index c1efc307..00000000 --- a/test/ocamlTests/CharTest/isDigitTest.ml +++ /dev/null @@ -1,11 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/isLetterTest.ml b/test/ocamlTests/CharTest/isLetterTest.ml deleted file mode 100644 index 5d6be160..00000000 --- a/test/ocamlTests/CharTest/isLetterTest.ml +++ /dev/null @@ -1,6 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/isLowercaseTest.ml b/test/ocamlTests/CharTest/isLowercaseTest.ml deleted file mode 100644 index 99f07767..00000000 --- a/test/ocamlTests/CharTest/isLowercaseTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/isPrintableTest.ml b/test/ocamlTests/CharTest/isPrintableTest.ml deleted file mode 100644 index 8abe46ed..00000000 --- a/test/ocamlTests/CharTest/isPrintableTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "isPrintable('~')" (fun () -> expect (Char.isPrintable '~') |> toEqual Eq.bool true) ; -test "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" (fun () -> expect (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) |> toEqual (let open Eq in bool ) Some(false)) ; diff --git a/test/ocamlTests/CharTest/isUppercaseTest.ml b/test/ocamlTests/CharTest/isUppercaseTest.ml deleted file mode 100644 index c81af2c6..00000000 --- a/test/ocamlTests/CharTest/isUppercaseTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/isWhitespaceTest.ml b/test/ocamlTests/CharTest/isWhitespaceTest.ml deleted file mode 100644 index 33ac3f2d..00000000 --- a/test/ocamlTests/CharTest/isWhitespaceTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "isWhitespace(' ')" (fun () -> expect (Char.isWhitespace ' ') |> toEqual Eq.bool true) ; -test "isWhitespace('a')" (fun () -> expect (Char.isWhitespace 'a') |> toEqual Eq.bool false) ; diff --git a/test/ocamlTests/CharTest/toCodeTest.ml b/test/ocamlTests/CharTest/toCodeTest.ml deleted file mode 100644 index 347c51d1..00000000 --- a/test/ocamlTests/CharTest/toCodeTest.ml +++ /dev/null @@ -1 +0,0 @@ -test "toCode('a')" (fun () -> expect (Char.toCode 'a') |> toEqual Eq.int 97) ; diff --git a/test/ocamlTests/CharTest/toDigitTest.ml b/test/ocamlTests/CharTest/toDigitTest.ml deleted file mode 100644 index a0413df8..00000000 --- a/test/ocamlTests/CharTest/toDigitTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/CharTest/toLowercaseTest.ml b/test/ocamlTests/CharTest/toLowercaseTest.ml deleted file mode 100644 index e07f04ff..00000000 --- a/test/ocamlTests/CharTest/toLowercaseTest.ml +++ /dev/null @@ -1,4 +0,0 @@ -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') ; diff --git a/test/ocamlTests/CharTest/toStringTest.ml b/test/ocamlTests/CharTest/toStringTest.ml deleted file mode 100644 index 2a1108a9..00000000 --- a/test/ocamlTests/CharTest/toStringTest.ml +++ /dev/null @@ -1 +0,0 @@ -test "toString('a')" (fun () -> expect (Char.toString 'a') |> toEqual Eq.string "a") ; diff --git a/test/ocamlTests/CharTest/toUppercaseTest.ml b/test/ocamlTests/CharTest/toUppercaseTest.ml deleted file mode 100644 index 66bc2db1..00000000 --- a/test/ocamlTests/CharTest/toUppercaseTest.ml +++ /dev/null @@ -1,4 +0,0 @@ -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') ; diff --git a/test/ocamlTests/FloatTest.ml b/test/ocamlTests/FloatTest.ml deleted file mode 100644 index 81174373..00000000 --- a/test/ocamlTests/FloatTest.ml +++ /dev/null @@ -1,78 +0,0 @@ -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 "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 "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 "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 "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 "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 "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 "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) ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml index eeae2805..2ae067e4 100644 --- a/test/ocamlTests/IntTest.ml +++ b/test/ocamlTests/IntTest.ml @@ -1,4 +1,9 @@ -test "absolute(8)" (fun () -> expect (Int.absolute 8) |> toEqual Eq.int 8) ; +open Tablecloth +open AlcoJest + +let suite = + suite "Int" (fun () -> + 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) ; @@ -9,14 +14,14 @@ test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); +test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; +test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); +test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.float 1.5) ; test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.float 5.4) ; test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.float 2) ; test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.float Float.infinity) ; test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.float Float.negativeInfinity) ; -test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; 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)) ; @@ -73,9 +78,9 @@ test "remainder(2,3)" (fun () -> expect (Int.remainder 2 3) |> toEqual Eq.int 2) test "remainder(3,3)" (fun () -> expect (Int.remainder 3 3) |> toEqual Eq.int 0) ; test "remainder(4,3)" (fun () -> expect (Int.remainder 4 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(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/ocamlTests/IntTest/absoluteTest.ml b/test/ocamlTests/IntTest/absoluteTest.ml deleted file mode 100644 index e468c983..00000000 --- a/test/ocamlTests/IntTest/absoluteTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/addTest.ml b/test/ocamlTests/IntTest/addTest.ml deleted file mode 100644 index 94b28e0c..00000000 --- a/test/ocamlTests/IntTest/addTest.ml +++ /dev/null @@ -1,2 +0,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) ; diff --git a/test/ocamlTests/IntTest/clampTest.ml b/test/ocamlTests/IntTest/clampTest.ml deleted file mode 100644 index 74bbe095..00000000 --- a/test/ocamlTests/IntTest/clampTest.ml +++ /dev/null @@ -1,6 +0,0 @@ -test "clamp(5,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; -test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; -test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; -test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); diff --git a/test/ocamlTests/IntTest/divideFloatTest.ml b/test/ocamlTests/IntTest/divideFloatTest.ml deleted file mode 100644 index e0f39b67..00000000 --- a/test/ocamlTests/IntTest/divideFloatTest.ml +++ /dev/null @@ -1,5 +0,0 @@ -test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.float 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.float 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.float 2) ; -test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.float Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.float Float.negativeInfinity) ; diff --git a/test/ocamlTests/IntTest/divideTest.ml b/test/ocamlTests/IntTest/divideTest.ml deleted file mode 100644 index dae7917d..00000000 --- a/test/ocamlTests/IntTest/divideTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; diff --git a/test/ocamlTests/IntTest/fromStringTest.ml b/test/ocamlTests/IntTest/fromStringTest.ml deleted file mode 100644 index b7829f58..00000000 --- a/test/ocamlTests/IntTest/fromStringTest.ml +++ /dev/null @@ -1,13 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/inRangeTest.ml b/test/ocamlTests/IntTest/inRangeTest.ml deleted file mode 100644 index 29b35d23..00000000 --- a/test/ocamlTests/IntTest/inRangeTest.ml +++ /dev/null @@ -1,6 +0,0 @@ -test "inRange(3,2,4)" (fun () -> expect (Int.inRange 3 2 4) |> toEqual Eq.bool true) ; -test "inRange(8,2,4)" (fun () -> expect (Int.inRange 8 2 4) |> toEqual Eq.bool false) ; -test "inRange(1,2,4)" (fun () -> expect (Int.inRange 1 2 4) |> toEqual Eq.bool false) ; -test "inRange(2,1,2)" (fun () -> expect (Int.inRange 2 1 2) |> toEqual Eq.bool false) ; -test "inRange(-6,-7,-5)" (fun () -> expect (Int.inRange -6 -7 -5) |> toEqual Eq.bool true) ; -test "inRange(3,7,1)" (fun () -> expect (fun () -> inRange 3 7 1) |> toThrow); diff --git a/test/ocamlTests/IntTest/isEvenTest.ml b/test/ocamlTests/IntTest/isEvenTest.ml deleted file mode 100644 index db5c9de2..00000000 --- a/test/ocamlTests/IntTest/isEvenTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/isOddTest.ml b/test/ocamlTests/IntTest/isOddTest.ml deleted file mode 100644 index 85977b04..00000000 --- a/test/ocamlTests/IntTest/isOddTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/maximumTest.ml b/test/ocamlTests/IntTest/maximumTest.ml deleted file mode 100644 index 3679da05..00000000 --- a/test/ocamlTests/IntTest/maximumTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/minimumTest.ml b/test/ocamlTests/IntTest/minimumTest.ml deleted file mode 100644 index f453371b..00000000 --- a/test/ocamlTests/IntTest/minimumTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/moduloTest.ml b/test/ocamlTests/IntTest/moduloTest.ml deleted file mode 100644 index 11b1b2ee..00000000 --- a/test/ocamlTests/IntTest/moduloTest.ml +++ /dev/null @@ -1,9 +0,0 @@ -test "modulo(-4,3)" (fun () -> expect (Int.modulo -4 3) |> toEqual Eq.int 2) ; -test "modulo(-3,3)" (fun () -> expect (Int.modulo -3 3) |> toEqual Eq.int 0) ; -test "modulo(-2,3)" (fun () -> expect (Int.modulo -2 3) |> toEqual Eq.int 1) ; -test "modulo(-1,3)" (fun () -> expect (Int.modulo -1 3) |> toEqual Eq.int 2) ; -test "modulo(0,3)" (fun () -> expect (Int.modulo 0 3) |> toEqual Eq.int 0) ; -test "modulo(1,3)" (fun () -> expect (Int.modulo 1 3) |> toEqual Eq.int 1) ; -test "modulo(2,3)" (fun () -> expect (Int.modulo 2 3) |> toEqual Eq.int 2) ; -test "modulo(3,3)" (fun () -> expect (Int.modulo 3 3) |> toEqual Eq.int 0) ; -test "modulo(4,3)" (fun () -> expect (Int.modulo 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/multiplyTest.ml b/test/ocamlTests/IntTest/multiplyTest.ml deleted file mode 100644 index 87543b72..00000000 --- a/test/ocamlTests/IntTest/multiplyTest.ml +++ /dev/null @@ -1 +0,0 @@ -test "multiply(2,7)" (fun () -> expect (Int.multiply 2 7) |> toEqual Eq.int 14) ; diff --git a/test/ocamlTests/IntTest/negateTest.ml b/test/ocamlTests/IntTest/negateTest.ml deleted file mode 100644 index c955b79e..00000000 --- a/test/ocamlTests/IntTest/negateTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/powerTest.ml b/test/ocamlTests/IntTest/powerTest.ml deleted file mode 100644 index c771ca1a..00000000 --- a/test/ocamlTests/IntTest/powerTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -test "power(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; -test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; -test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/remainderTest.ml b/test/ocamlTests/IntTest/remainderTest.ml deleted file mode 100644 index 52def45c..00000000 --- a/test/ocamlTests/IntTest/remainderTest.ml +++ /dev/null @@ -1,8 +0,0 @@ -test "remainder(-4,3)" (fun () -> expect (Int.remainder -4 3) |> toEqual Eq.int -1) ; -test "remainder(-2,3)" (fun () -> expect (Int.remainder -2 3) |> toEqual Eq.int -2) ; -test "remainder(-1,3)" (fun () -> expect (Int.remainder -1 3) |> toEqual Eq.int -1) ; -test "remainder(0,3)" (fun () -> expect (Int.remainder 0 3) |> toEqual Eq.int 0) ; -test "remainder(1,3)" (fun () -> expect (Int.remainder 1 3) |> toEqual Eq.int 1) ; -test "remainder(2,3)" (fun () -> expect (Int.remainder 2 3) |> toEqual Eq.int 2) ; -test "remainder(3,3)" (fun () -> expect (Int.remainder 3 3) |> toEqual Eq.int 0) ; -test "remainder(4,3)" (fun () -> expect (Int.remainder 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/subtractTest.ml b/test/ocamlTests/IntTest/subtractTest.ml deleted file mode 100644 index f3a7d695..00000000 --- a/test/ocamlTests/IntTest/subtractTest.ml +++ /dev/null @@ -1 +0,0 @@ -test "subtract(4,3)" (fun () -> expect (Int.subtract 4 3) |> toEqual Eq.int 1) ; diff --git a/test/ocamlTests/IntTest/toFloatTest.ml b/test/ocamlTests/IntTest/toFloatTest.ml deleted file mode 100644 index 0336688f..00000000 --- a/test/ocamlTests/IntTest/toFloatTest.ml +++ /dev/null @@ -1,3 +0,0 @@ -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) ; diff --git a/test/ocamlTests/IntTest/toStringTest.ml b/test/ocamlTests/IntTest/toStringTest.ml deleted file mode 100644 index fc99f7ed..00000000 --- a/test/ocamlTests/IntTest/toStringTest.ml +++ /dev/null @@ -1,2 +0,0 @@ -test "toString(1)" (fun () -> expect (Int.toString 1) |> toEqual Eq.string "1") ; -test "toString(-1)" (fun () -> expect (Int.toString -1) |> toEqual Eq.string "-1") ; diff --git a/test/rescriptTests/BoolTest.res b/test/rescriptTests/BoolTest.res index 7f2cf745..8362e020 100644 --- a/test/rescriptTests/BoolTest.res +++ b/test/rescriptTests/BoolTest.res @@ -1,4 +1,8 @@ -test ("compare(true,true)", () => expect(Bool.compare(true,true)) |> toEqual(Eq.int, 0)) +open Tablecloth +open AlcoJest + +let suite= suite("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)) @@ -35,3 +39,4 @@ test ("xor(true,true)", () => expect(Bool.xor(true,true)) |> toEqual(Eq.bool, fa 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/BoolTest/compareTest.res b/test/rescriptTests/BoolTest/compareTest.res deleted file mode 100644 index 7d6b2259..00000000 --- a/test/rescriptTests/BoolTest/compareTest.res +++ /dev/null @@ -1,4 +0,0 @@ -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)) diff --git a/test/rescriptTests/BoolTest/equalTest.res b/test/rescriptTests/BoolTest/equalTest.res deleted file mode 100644 index e16f0d9b..00000000 --- a/test/rescriptTests/BoolTest/equalTest.res +++ /dev/null @@ -1,3 +0,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)) diff --git a/test/rescriptTests/BoolTest/fromIntTest.res b/test/rescriptTests/BoolTest/fromIntTest.res deleted file mode 100644 index 6d49a5e4..00000000 --- a/test/rescriptTests/BoolTest/fromIntTest.res +++ /dev/null @@ -1,14 +0,0 @@ -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)) diff --git a/test/rescriptTests/BoolTest/fromStringTest.res b/test/rescriptTests/BoolTest/fromStringTest.res deleted file mode 100644 index 5ad7ba15..00000000 --- a/test/rescriptTests/BoolTest/fromStringTest.res +++ /dev/null @@ -1,8 +0,0 @@ -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)) diff --git a/test/rescriptTests/BoolTest/toIntTest.res b/test/rescriptTests/BoolTest/toIntTest.res deleted file mode 100644 index 7203c693..00000000 --- a/test/rescriptTests/BoolTest/toIntTest.res +++ /dev/null @@ -1,2 +0,0 @@ -test ("toInt(true)", () => expect(Bool.toInt(true)) |> toEqual(Eq.int, 1)) -test ("toInt(false)", () => expect(Bool.toInt(false)) |> toEqual(Eq.int, 0)) diff --git a/test/rescriptTests/BoolTest/toStringTest.res b/test/rescriptTests/BoolTest/toStringTest.res deleted file mode 100644 index b83c3799..00000000 --- a/test/rescriptTests/BoolTest/toStringTest.res +++ /dev/null @@ -1,2 +0,0 @@ -test ("toString(true)", () => expect(Bool.toString(true)) |> toEqual(Eq.string, "true")) -test ("toString(false)", () => expect(Bool.toString(false)) |> toEqual(Eq.string, "false")) diff --git a/test/rescriptTests/BoolTest/xorTest.res b/test/rescriptTests/BoolTest/xorTest.res deleted file mode 100644 index 8950ff26..00000000 --- a/test/rescriptTests/BoolTest/xorTest.res +++ /dev/null @@ -1,4 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res index 3d253b85..c14cee25 100644 --- a/test/rescriptTests/CharTest.res +++ b/test/rescriptTests/CharTest.res @@ -1,4 +1,8 @@ -test ("fromCode(97)", () => expect(Char.fromCode(97)) |> toEqual({open Eq +open Tablecloth +open AlcoJest + +let suite= suite("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)) @@ -56,3 +60,4 @@ test ("toUppercase('a')", () => expect(Char.toUppercase('a')) |> toEqual(Eq.char 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/CharTest/fromCodeTest.res b/test/rescriptTests/CharTest/fromCodeTest.res deleted file mode 100644 index 1b26348c..00000000 --- a/test/rescriptTests/CharTest/fromCodeTest.res +++ /dev/null @@ -1,6 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/fromStringTest.res b/test/rescriptTests/CharTest/fromStringTest.res deleted file mode 100644 index daffb601..00000000 --- a/test/rescriptTests/CharTest/fromStringTest.res +++ /dev/null @@ -1,6 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/isAlphanumericTest.res b/test/rescriptTests/CharTest/isAlphanumericTest.res deleted file mode 100644 index 453028d9..00000000 --- a/test/rescriptTests/CharTest/isAlphanumericTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("isAlphanumeric('A')", () => expect(Char.isAlphanumeric('A')) |> toEqual(Eq.bool, true)) -test ("isAlphanumeric('?')", () => expect(Char.isAlphanumeric('?')) |> toEqual(Eq.bool, false)) - diff --git a/test/rescriptTests/CharTest/isDigitTest.res b/test/rescriptTests/CharTest/isDigitTest.res deleted file mode 100644 index ab1ac091..00000000 --- a/test/rescriptTests/CharTest/isDigitTest.res +++ /dev/null @@ -1,12 +0,0 @@ -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)) - diff --git a/test/rescriptTests/CharTest/isLetterTest.res b/test/rescriptTests/CharTest/isLetterTest.res deleted file mode 100644 index baee0141..00000000 --- a/test/rescriptTests/CharTest/isLetterTest.res +++ /dev/null @@ -1,6 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/isLowercaseTest.res b/test/rescriptTests/CharTest/isLowercaseTest.res deleted file mode 100644 index 5ca09d57..00000000 --- a/test/rescriptTests/CharTest/isLowercaseTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/isPrintableTest.res b/test/rescriptTests/CharTest/isPrintableTest.res deleted file mode 100644 index 5ef6c67d..00000000 --- a/test/rescriptTests/CharTest/isPrintableTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("isPrintable('~')", () => expect(Char.isPrintable('~')) |> toEqual(Eq.bool, true)) -test ("isPrintable(fromCode(31) |> Option.map(~f=isPrintable))", () => expect(Char.isPrintable(fromCode(31) |> Option.map(~f=isPrintable))) |> toEqual({open Eq -bool()}, Some(false))) diff --git a/test/rescriptTests/CharTest/isUppercaseTest.res b/test/rescriptTests/CharTest/isUppercaseTest.res deleted file mode 100644 index 4fa2a48d..00000000 --- a/test/rescriptTests/CharTest/isUppercaseTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/isWhitespaceTest.res b/test/rescriptTests/CharTest/isWhitespaceTest.res deleted file mode 100644 index fb3ff619..00000000 --- a/test/rescriptTests/CharTest/isWhitespaceTest.res +++ /dev/null @@ -1,2 +0,0 @@ -test ("isWhitespace(' ')", () => expect(Char.isWhitespace(' ')) |> toEqual(Eq.bool, true)) -test ("isWhitespace('a')", () => expect(Char.isWhitespace('a')) |> toEqual(Eq.bool, false)) diff --git a/test/rescriptTests/CharTest/toCodeTest.res b/test/rescriptTests/CharTest/toCodeTest.res deleted file mode 100644 index 232e8a18..00000000 --- a/test/rescriptTests/CharTest/toCodeTest.res +++ /dev/null @@ -1 +0,0 @@ -test ("toCode('a')", () => expect(Char.toCode('a')) |> toEqual(Eq.int, 97)) diff --git a/test/rescriptTests/CharTest/toDigitTest.res b/test/rescriptTests/CharTest/toDigitTest.res deleted file mode 100644 index f3a2fac2..00000000 --- a/test/rescriptTests/CharTest/toDigitTest.res +++ /dev/null @@ -1,6 +0,0 @@ -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)) diff --git a/test/rescriptTests/CharTest/toLowercaseTest.res b/test/rescriptTests/CharTest/toLowercaseTest.res deleted file mode 100644 index 47c608c8..00000000 --- a/test/rescriptTests/CharTest/toLowercaseTest.res +++ /dev/null @@ -1,4 +0,0 @@ -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')) diff --git a/test/rescriptTests/CharTest/toStringTest.res b/test/rescriptTests/CharTest/toStringTest.res deleted file mode 100644 index 35906376..00000000 --- a/test/rescriptTests/CharTest/toStringTest.res +++ /dev/null @@ -1 +0,0 @@ -test ("toString('a')", () => expect(Char.toString('a')) |> toEqual(Eq.string, "a")) diff --git a/test/rescriptTests/CharTest/toUppercaseTest.res b/test/rescriptTests/CharTest/toUppercaseTest.res deleted file mode 100644 index 6a9a540a..00000000 --- a/test/rescriptTests/CharTest/toUppercaseTest.res +++ /dev/null @@ -1,4 +0,0 @@ -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')) diff --git a/test/rescriptTests/FloatTest.res b/test/rescriptTests/FloatTest.res deleted file mode 100644 index 0d8332c0..00000000 --- a/test/rescriptTests/FloatTest.res +++ /dev/null @@ -1,92 +0,0 @@ -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 ("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 ("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 ("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 ("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 ("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 ("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 ("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)) diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res index e6392ff0..a98f16c1 100644 --- a/test/rescriptTests/IntTest.res +++ b/test/rescriptTests/IntTest.res @@ -1,4 +1,8 @@ -test ("absolute(8)", () => expect(Int.absolute(8)) |> toEqual(Eq.int, 8)) +open Tablecloth +open AlcoJest + +let suite= suite("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)) @@ -9,14 +13,14 @@ test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) +test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) +test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) +test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.float, 1.5)) test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.float, 5.4)) test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.float, 2)) test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.float, Float.infinity)) test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.float, Float.negativeInfinity)) -test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) test ("fromString(0)", () => expect(Int.fromString("0")) |> toEqual({open Eq option(int)}, Some(0))) test ("fromString(-0)", () => expect(Int.fromString("-0")) |> toEqual({open Eq @@ -91,3 +95,4 @@ 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/test/rescriptTests/IntTest/absoluteTest.res b/test/rescriptTests/IntTest/absoluteTest.res deleted file mode 100644 index 51be18ea..00000000 --- a/test/rescriptTests/IntTest/absoluteTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/addTest.res b/test/rescriptTests/IntTest/addTest.res deleted file mode 100644 index 11abb562..00000000 --- a/test/rescriptTests/IntTest/addTest.res +++ /dev/null @@ -1,2 +0,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)) diff --git a/test/rescriptTests/IntTest/clampTest.res b/test/rescriptTests/IntTest/clampTest.res deleted file mode 100644 index d434277d..00000000 --- a/test/rescriptTests/IntTest/clampTest.res +++ /dev/null @@ -1,6 +0,0 @@ -test ("clamp(5,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) -test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) -test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) -test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) -test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) diff --git a/test/rescriptTests/IntTest/divideFloatTest.res b/test/rescriptTests/IntTest/divideFloatTest.res deleted file mode 100644 index a280a9e7..00000000 --- a/test/rescriptTests/IntTest/divideFloatTest.res +++ /dev/null @@ -1,5 +0,0 @@ -test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.float, 1.5)) -test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.float, 5.4)) -test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.float, 2)) -test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.float, Float.infinity)) -test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.float, Float.negativeInfinity)) diff --git a/test/rescriptTests/IntTest/divideTest.res b/test/rescriptTests/IntTest/divideTest.res deleted file mode 100644 index 1d8af7b8..00000000 --- a/test/rescriptTests/IntTest/divideTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) diff --git a/test/rescriptTests/IntTest/fromStringTest.res b/test/rescriptTests/IntTest/fromStringTest.res deleted file mode 100644 index 3eca2907..00000000 --- a/test/rescriptTests/IntTest/fromStringTest.res +++ /dev/null @@ -1,26 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/inRangeTest.res b/test/rescriptTests/IntTest/inRangeTest.res deleted file mode 100644 index f79a5ae1..00000000 --- a/test/rescriptTests/IntTest/inRangeTest.res +++ /dev/null @@ -1,6 +0,0 @@ -test ("inRange(3,2,4)", () => expect(Int.inRange(3,2,4)) |> toEqual(Eq.bool, true)) -test ("inRange(8,2,4)", () => expect(Int.inRange(8,2,4)) |> toEqual(Eq.bool, false)) -test ("inRange(1,2,4)", () => expect(Int.inRange(1,2,4)) |> toEqual(Eq.bool, false)) -test ("inRange(2,1,2)", () => expect(Int.inRange(2,1,2)) |> toEqual(Eq.bool, false)) -test ("inRange(-6,-7,-5)", () => expect(Int.inRange(-6,-7,-5)) |> toEqual(Eq.bool, true)) -test ("inRange(3,7,1)", () => expect(() => Int.inRange(3,7,1)) |> toThrow) diff --git a/test/rescriptTests/IntTest/isEvenTest.res b/test/rescriptTests/IntTest/isEvenTest.res deleted file mode 100644 index a5e272d5..00000000 --- a/test/rescriptTests/IntTest/isEvenTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/isOddTest.res b/test/rescriptTests/IntTest/isOddTest.res deleted file mode 100644 index d06425d6..00000000 --- a/test/rescriptTests/IntTest/isOddTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/maximumTest.res b/test/rescriptTests/IntTest/maximumTest.res deleted file mode 100644 index 61f46c30..00000000 --- a/test/rescriptTests/IntTest/maximumTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/minimumTest.res b/test/rescriptTests/IntTest/minimumTest.res deleted file mode 100644 index acdd501d..00000000 --- a/test/rescriptTests/IntTest/minimumTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/moduloTest.res b/test/rescriptTests/IntTest/moduloTest.res deleted file mode 100644 index ca0a9821..00000000 --- a/test/rescriptTests/IntTest/moduloTest.res +++ /dev/null @@ -1,9 +0,0 @@ -test ("modulo(-4,3)", () => expect(Int.modulo(-4,3)) |> toEqual(Eq.int, 2)) -test ("modulo(-3,3)", () => expect(Int.modulo(-3,3)) |> toEqual(Eq.int, 0)) -test ("modulo(-2,3)", () => expect(Int.modulo(-2,3)) |> toEqual(Eq.int, 1)) -test ("modulo(-1,3)", () => expect(Int.modulo(-1,3)) |> toEqual(Eq.int, 2)) -test ("modulo(0,3)", () => expect(Int.modulo(0,3)) |> toEqual(Eq.int, 0)) -test ("modulo(1,3)", () => expect(Int.modulo(1,3)) |> toEqual(Eq.int, 1)) -test ("modulo(2,3)", () => expect(Int.modulo(2,3)) |> toEqual(Eq.int, 2)) -test ("modulo(3,3)", () => expect(Int.modulo(3,3)) |> toEqual(Eq.int, 0)) -test ("modulo(4,3)", () => expect(Int.modulo(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/multiplyTest.res b/test/rescriptTests/IntTest/multiplyTest.res deleted file mode 100644 index 898853b9..00000000 --- a/test/rescriptTests/IntTest/multiplyTest.res +++ /dev/null @@ -1 +0,0 @@ -test ("multiply(2,7)", () => expect(Int.multiply(2,7)) |> toEqual(Eq.int, 14)) diff --git a/test/rescriptTests/IntTest/negateTest.res b/test/rescriptTests/IntTest/negateTest.res deleted file mode 100644 index cddf9366..00000000 --- a/test/rescriptTests/IntTest/negateTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/powerTest.res b/test/rescriptTests/IntTest/powerTest.res deleted file mode 100644 index 3ffb6d9a..00000000 --- a/test/rescriptTests/IntTest/powerTest.res +++ /dev/null @@ -1,3 +0,0 @@ -test ("power(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) -test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) -test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/remainderTest.res b/test/rescriptTests/IntTest/remainderTest.res deleted file mode 100644 index 1dafae54..00000000 --- a/test/rescriptTests/IntTest/remainderTest.res +++ /dev/null @@ -1,8 +0,0 @@ -test ("remainder(-4,3)", () => expect(Int.remainder(-4,3)) |> toEqual(Eq.int, -1)) -test ("remainder(-2,3)", () => expect(Int.remainder(-2,3)) |> toEqual(Eq.int, -2)) -test ("remainder(-1,3)", () => expect(Int.remainder(-1,3)) |> toEqual(Eq.int, -1)) -test ("remainder(0,3)", () => expect(Int.remainder(0,3)) |> toEqual(Eq.int, 0)) -test ("remainder(1,3)", () => expect(Int.remainder(1,3)) |> toEqual(Eq.int, 1)) -test ("remainder(2,3)", () => expect(Int.remainder(2,3)) |> toEqual(Eq.int, 2)) -test ("remainder(3,3)", () => expect(Int.remainder(3,3)) |> toEqual(Eq.int, 0)) -test ("remainder(4,3)", () => expect(Int.remainder(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/subtractTest.res b/test/rescriptTests/IntTest/subtractTest.res deleted file mode 100644 index d8585c6d..00000000 --- a/test/rescriptTests/IntTest/subtractTest.res +++ /dev/null @@ -1 +0,0 @@ -test ("subtract(4,3)", () => expect(Int.subtract(4,3)) |> toEqual(Eq.int, 1)) diff --git a/test/rescriptTests/IntTest/toFloatTest.res b/test/rescriptTests/IntTest/toFloatTest.res deleted file mode 100644 index a7a2ec59..00000000 --- a/test/rescriptTests/IntTest/toFloatTest.res +++ /dev/null @@ -1,3 +0,0 @@ -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)) diff --git a/test/rescriptTests/IntTest/toStringTest.res b/test/rescriptTests/IntTest/toStringTest.res deleted file mode 100644 index 0bfcaf31..00000000 --- a/test/rescriptTests/IntTest/toStringTest.res +++ /dev/null @@ -1,2 +0,0 @@ -test ("toString(1)", () => expect(Int.toString(1)) |> toEqual(Eq.string, "1")) -test ("toString(-1)", () => expect(Int.toString(-1)) |> toEqual(Eq.string, "-1")) From b2693b01af49141aa822e2d18eb1fa250a712005 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Nov 2022 19:17:18 +0100 Subject: [PATCH 27/31] Remove unnecessary variables + rename some variables --- src/generateTest.res | 38 +++++++++++---------------------- test/fsharpTests/BoolTest.fs | 2 +- test/fsharpTests/CharTest.fs | 2 +- test/fsharpTests/IntTest.fs | 2 +- test/ocamlTests/BoolTest.ml | 2 +- test/ocamlTests/CharTest.ml | 2 +- test/ocamlTests/IntTest.ml | 2 +- test/rescriptTests/BoolTest.res | 2 +- test/rescriptTests/CharTest.res | 2 +- test/rescriptTests/IntTest.res | 2 +- 10 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/generateTest.res b/src/generateTest.res index d2fa22ed..bf4ad923 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -21,16 +21,10 @@ type data = { @scope("JSON") @val external parseIntoMyData: string => data = "parse" -let finalresultR = ref("") -let finalresultRR = ref("") -let finalresultOO = ref("") -let finalresultFF = ref("") -let finalresultF = ref("") -let finalresultO = ref("") let \"module" = ref("") -let resultsRS = [] -let resultsFS = [] -let resultsOR = [] +let testCasesR = [] +let testCasesF = [] +let testCasesO = [] // let files = [ // "Bool.compare.json", // "Bool.equal.json", @@ -76,7 +70,6 @@ let files = [ "Int.subtract.json", "Int.toFloat.json", "Int.toString.json", - ] let generateAllTests = Belt.Array.map(files, file => { let file = readFileSync(~name="../json-files/" ++ file, #utf8) @@ -172,35 +165,30 @@ let generateAllTests = Belt.Array.map(files, file => { resultsF->Belt.Array.push(resultFSharp) }) - finalresultR := Js.Array.joinWith("", resultsR) - resultsRS->Belt.Array.push(finalresultR.contents) - finalresultF := Js.Array.joinWith("", resultsF) - resultsFS->Belt.Array.push(finalresultF.contents) - finalresultO := Js.Array.joinWith("", resultsO) - resultsOR->Belt.Array.push(finalresultO.contents) + testCasesR->Belt.Array.push(Js.Array.joinWith("", resultsR)) + testCasesF->Belt.Array.push(Js.Array.joinWith("", resultsF)) + testCasesO->Belt.Array.push(Js.Array.joinWith("", resultsO)) }) -finalresultRR := Js.Array.joinWith("", resultsRS) + let testHeaderR = `open Tablecloth\nopen AlcoJest\n\nlet suite= suite("${\"module".contents}", () => {\n` -let testCasesR = `${testHeaderR} ${finalresultRR.contents}})` -finalresultOO := Js.Array.joinWith("", resultsOR) +let combineTestsR = `${testHeaderR}${Js.Array.joinWith("", testCasesR)}})` let testHeaderO = `open Tablecloth\nopen AlcoJest\n\nlet suite =\n suite "${\"module".contents}" (fun () ->\n` -let testCasesO = `${testHeaderO} ${finalresultOO.contents})` -finalresultFF := Js.Array.joinWith("", resultsFS) +let combineTestsO = `${testHeaderO}${Js.Array.joinWith("", testCasesO)})` let testHeaderF = `open Tablecloth\nopen Expecto\n\n[]\nlet tests =\n testList\n "${\"module".contents}"\n[` -let testCasesF = `${testHeaderF} ${finalresultFF.contents}]` +let combineTestsF = `${testHeaderF}${Js.Array.joinWith("", testCasesF)}]` Node.Fs.writeFileSync( `../test/rescriptTests/${\"module".contents}Test.res`, - testCasesR, + combineTestsR, #utf8, ) Node.Fs.writeFileSync( `../test/ocamlTests/${\"module".contents}Test.ml`, - testCasesO, + combineTestsO, #utf8, ) Node.Fs.writeFileSync( `../test/fsharpTests/${\"module".contents}Test.fs`, - testCasesF, + combineTestsF, #utf8, ) diff --git a/test/fsharpTests/BoolTest.fs b/test/fsharpTests/BoolTest.fs index 2020929b..5316e203 100644 --- a/test/fsharpTests/BoolTest.fs +++ b/test/fsharpTests/BoolTest.fs @@ -5,7 +5,7 @@ open Expecto let tests = testList "Bool" -[ testCase "compare(true,true)" +[testCase "compare(true,true)" <| fun _ -> let expected = 0 Expect.equal expected (Bool.compare true true) "error" diff --git a/test/fsharpTests/CharTest.fs b/test/fsharpTests/CharTest.fs index f398474f..2c3d234b 100644 --- a/test/fsharpTests/CharTest.fs +++ b/test/fsharpTests/CharTest.fs @@ -5,7 +5,7 @@ open Expecto let tests = testList "Char" -[ testCase "fromCode(97)" +[testCase "fromCode(97)" <| fun _ -> let expected = Some('a') Expect.equal expected (Char.fromCode 97) "error" diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs index 7534e6e3..f749c6f2 100644 --- a/test/fsharpTests/IntTest.fs +++ b/test/fsharpTests/IntTest.fs @@ -5,7 +5,7 @@ open Expecto let tests = testList "Int" -[ testCase "absolute(8)" +[testCase "absolute(8)" <| fun _ -> let expected = 8 Expect.equal expected (Int.absolute 8) "error" diff --git a/test/ocamlTests/BoolTest.ml b/test/ocamlTests/BoolTest.ml index b82473fc..75b3ca7b 100644 --- a/test/ocamlTests/BoolTest.ml +++ b/test/ocamlTests/BoolTest.ml @@ -3,7 +3,7 @@ open AlcoJest let suite = suite "Bool" (fun () -> - test "compare(true,true)" (fun () -> expect (Bool.compare true true) |> toEqual Eq.int 0) ; +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) ; diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml index 83634219..b29e295a 100644 --- a/test/ocamlTests/CharTest.ml +++ b/test/ocamlTests/CharTest.ml @@ -3,7 +3,7 @@ open AlcoJest let suite = suite "Char" (fun () -> - test "fromCode(97)" (fun () -> expect (Char.fromCode 97) |> toEqual (let open Eq in option char) Some('a')) ; +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')) ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml index 2ae067e4..2c664f48 100644 --- a/test/ocamlTests/IntTest.ml +++ b/test/ocamlTests/IntTest.ml @@ -3,7 +3,7 @@ open AlcoJest let suite = suite "Int" (fun () -> - test "absolute(8)" (fun () -> expect (Int.absolute 8) |> toEqual Eq.int 8) ; +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) ; diff --git a/test/rescriptTests/BoolTest.res b/test/rescriptTests/BoolTest.res index 8362e020..ffc480a0 100644 --- a/test/rescriptTests/BoolTest.res +++ b/test/rescriptTests/BoolTest.res @@ -2,7 +2,7 @@ open Tablecloth open AlcoJest let suite= suite("Bool", () => { - test ("compare(true,true)", () => expect(Bool.compare(true,true)) |> toEqual(Eq.int, 0)) +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)) diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res index c14cee25..d996e93b 100644 --- a/test/rescriptTests/CharTest.res +++ b/test/rescriptTests/CharTest.res @@ -2,7 +2,7 @@ open Tablecloth open AlcoJest let suite= suite("Char", () => { - test ("fromCode(97)", () => expect(Char.fromCode(97)) |> toEqual({open Eq +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)) diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res index a98f16c1..0e585b1e 100644 --- a/test/rescriptTests/IntTest.res +++ b/test/rescriptTests/IntTest.res @@ -2,7 +2,7 @@ open Tablecloth open AlcoJest let suite= suite("Int", () => { - test ("absolute(8)", () => expect(Int.absolute(8)) |> toEqual(Eq.int, 8)) +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)) From ed9939dc6e77f585988c2e463d4db15e63680755 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Nov 2022 21:39:41 +0100 Subject: [PATCH 28/31] Minor fixes --- src/generateTest.res | 4 ++-- test/ocamlTests/BoolTest.ml | 1 + test/ocamlTests/CharTest.ml | 1 + test/ocamlTests/IntTest.ml | 1 + test/rescriptTests/BoolTest.res | 1 + test/rescriptTests/CharTest.res | 1 + test/rescriptTests/IntTest.res | 1 + 7 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/generateTest.res b/src/generateTest.res index bf4ad923..a882d555 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -171,9 +171,9 @@ let generateAllTests = Belt.Array.map(files, file => { }) -let testHeaderR = `open Tablecloth\nopen AlcoJest\n\nlet suite= suite("${\"module".contents}", () => {\n` +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 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)}]` diff --git a/test/ocamlTests/BoolTest.ml b/test/ocamlTests/BoolTest.ml index 75b3ca7b..660d92af 100644 --- a/test/ocamlTests/BoolTest.ml +++ b/test/ocamlTests/BoolTest.ml @@ -3,6 +3,7 @@ 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) ; diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml index b29e295a..4b5918e9 100644 --- a/test/ocamlTests/CharTest.ml +++ b/test/ocamlTests/CharTest.ml @@ -3,6 +3,7 @@ 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) ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml index 2c664f48..bb983c05 100644 --- a/test/ocamlTests/IntTest.ml +++ b/test/ocamlTests/IntTest.ml @@ -3,6 +3,7 @@ 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) ; diff --git a/test/rescriptTests/BoolTest.res b/test/rescriptTests/BoolTest.res index ffc480a0..ffcdcf4a 100644 --- a/test/rescriptTests/BoolTest.res +++ b/test/rescriptTests/BoolTest.res @@ -2,6 +2,7 @@ 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)) diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res index d996e93b..d208fe93 100644 --- a/test/rescriptTests/CharTest.res +++ b/test/rescriptTests/CharTest.res @@ -2,6 +2,7 @@ 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 diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res index 0e585b1e..c247cd9f 100644 --- a/test/rescriptTests/IntTest.res +++ b/test/rescriptTests/IntTest.res @@ -2,6 +2,7 @@ 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)) From e5e7a9e781064c09bd970ad159c0234433014fc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Nov 2022 22:04:49 +0100 Subject: [PATCH 29/31] Add FloatTest and fix FloatTest yaml files --- test/fsharpTests/FloatTest.fs | 738 +++++++++++++++++++++++++++++++ test/ocamlTests/FloatTest.ml | 190 ++++++++ test/rescriptTests/FloatTest.res | 203 +++++++++ yaml-files/Float.absolute.yaml | 36 +- yaml-files/Float.atan.yaml | 12 +- yaml-files/Float.atan2.yaml | 36 +- yaml-files/Float.ceiling.yaml | 36 +- yaml-files/Float.clamp.yaml | 78 ++-- yaml-files/Float.degrees.yaml | 6 +- yaml-files/Float.divide.yaml | 18 +- yaml-files/Float.floor.yaml | 36 +- yaml-files/Float.fromInt.yaml | 18 +- yaml-files/Float.hypotenuse.yaml | 12 +- yaml-files/Float.inRange.yaml | 42 +- yaml-files/Float.isFinite.yaml | 12 +- yaml-files/Float.isInfinite.yaml | 12 +- yaml-files/Float.isInteger.yaml | 6 +- yaml-files/Float.log.yaml | 30 +- yaml-files/Float.maximum.yaml | 48 +- yaml-files/Float.minimum.yaml | 48 +- yaml-files/Float.multiply.yaml | 12 +- yaml-files/Float.negate.yaml | 36 +- yaml-files/Float.power.yaml | 36 +- yaml-files/Float.round.yaml | 718 ++++++++++-------------------- yaml-files/Float.squareRoot.yaml | 18 +- yaml-files/Float.subtract.yaml | 12 +- yaml-files/Float.tan.yaml | 12 +- yaml-files/Float.toInt.yaml | 18 +- yaml-files/Float.truncate.yaml | 36 +- yaml-files/Float.turns.yaml | 6 +- yaml-files/Option.andThen.yaml | 11 +- yaml-files/Option.map.yaml | 5 +- yaml-files/Option.toList.yaml | 8 +- 33 files changed, 1607 insertions(+), 938 deletions(-) create mode 100644 test/fsharpTests/FloatTest.fs create mode 100644 test/ocamlTests/FloatTest.ml create mode 100644 test/rescriptTests/FloatTest.res diff --git a/test/fsharpTests/FloatTest.fs b/test/fsharpTests/FloatTest.fs new file mode 100644 index 00000000..bcae1997 --- /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.,0.,8.)" +<| fun _ -> + let expected = 5. + Expect.equal expected (Float.clamp 5. 0. 8.) "error" +testCase "clamp(9.,0.,8.)" +<| fun _ -> + let expected = 8. + Expect.equal expected (Float.clamp 9. 0. 8.) "error" +testCase "clamp(1.,2.,8.)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.clamp 1. 2. 8.) "error" +testCase "clamp(5.,-10.,-5.)" +<| fun _ -> + let expected = -5. + Expect.equal expected (Float.clamp 5. -10. -5.) "error" +testCase "clamp(-15.,-10.,-5.)" +<| fun _ -> + let expected = -10. + Expect.equal expected (Float.clamp -15. -10. -5.) "error" +testCase "clamp(-6.6,-7.9,nan)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp -6.6 -7.9 nan) "error" +testCase "clamp(-6.6,nan,0.)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp -6.6 nan 0.) "error" +testCase "clamp(nan,2.,8.)" +<| fun _ -> + let expected = NaN + Expect.equal expected (Float.clamp nan 2. 8.) "error" +testCase "clamp(3.,7., 1.)" +<| fun _ -> + Expect.equal (Float.clamp 3. 7. 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(0.,0.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.atan2 0. 0.) "error" +testCase "atan2(1.,1.)" +<| fun _ -> + let expected = 0.7853981633974483 + Expect.equal expected (Float.atan2 1. 1.) "error" +testCase "atan2(1.,-1.)" +<| fun _ -> + let expected = 2.356194490192345 + Expect.equal expected (Float.atan2 1. -1.) "error" +testCase "atan2(-1.,-1.)" +<| fun _ -> + let expected = -2.356194490192345 + Expect.equal expected (Float.atan2 -1. -1.) "error" +testCase "atan2(-1.,1.)" +<| fun _ -> + let expected = -0.7853981633974483 + Expect.equal expected (Float.atan2 -1. 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,2.)" +<| fun _ -> + let expected = 1.57 + Expect.equal expected (Float.divide 3.14 2.) "error" +testCase "divide(3.14,0.)" +<| fun _ -> + let expected = infinity + Expect.equal expected (Float.divide 3.14 0.) "error" +testCase "divide(3.14,-0.)" +<| fun _ -> + let expected = negativeInfinity + Expect.equal expected (Float.divide 3.14 -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.,2.,4.)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.inRange 3. 2. 4.) "error" +testCase "inRange(8.,2.,4.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 8. 2. 4.) "error" +testCase "inRange(1., 2.,4.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 1. 2. 4.) "error" +testCase "inRange(2.,1.,2.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange 2. 1. 2.) "error" +testCase "inRange(-6.6,-7.9,-5.2)" +<| fun _ -> + let expected = true + Expect.equal expected (Float.inRange -6.6 -7.9 -5.2) "error" +testCase "inRange(-6.6,-7.9,nan)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange -6.6 -7.9 nan) "error" +testCase "inRange(-6.6,nan,0.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange -6.6 nan 0.) "error" +testCase "inRange(nan,2.,8.)" +<| fun _ -> + let expected = false + Expect.equal expected (Float.inRange nan 2. 8.) "error" +testCase "inRange(3.,7.,1.)" +<| fun _ -> + Expect.equal (Float.inRange 3. 7. 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.,10.)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.log 100. 10.) "error" +testCase "log(256.,2.)" +<| fun _ -> + let expected = 8. + Expect.equal expected (Float.log 256. 2.) "error" +testCase "log(0.,10.)" +<| fun _ -> + let expected = negativeInfinity + Expect.equal expected (Float.log 0. 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(7.,3.)" +<| fun _ -> + let expected = 343. + Expect.equal expected (Float.power 7. 3.) "error" +testCase "power(0.,3.)" +<| fun _ -> + let expected = 0. + Expect.equal expected (Float.power 0. 3.) "error" +testCase "power(7.,0.)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.power 7. 0.) "error" +testCase "round(#Zero,1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Zero 1.2) "error" +testCase "round(#Zero,1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Zero 1.5) "error" +testCase "round(#Zero,1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Zero 1.8) "error" +testCase "round(#Zero,-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Zero -1.2) "error" +testCase "round(#Zero,-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Zero -1.5) "error" +testCase "round(#Zero,-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Zero -1.8) "error" +testCase "round(#AwayFromZero,1.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #AwayFromZero 1.2) "error" +testCase "round(#AwayFromZero,1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #AwayFromZero 1.5) "error" +testCase "round(#AwayFromZero,1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #AwayFromZero 1.8) "error" +testCase "round(#AwayFromZero,-1.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #AwayFromZero -1.2) "error" +testCase "round(#AwayFromZero,-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #AwayFromZero -1.5) "error" +testCase "round(#AwayFromZero,-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #AwayFromZero -1.8) "error" +testCase "round(#Up,1.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Up 1.2) "error" +testCase "round(#Up,1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Up 1.5) "error" +testCase "round(#Up,1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Up 1.8) "error" +testCase "round(#Up,-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Up -1.2) "error" +testCase "round(#Up,-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Up -1.5) "error" +testCase "round(#Up,-1.8)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Up -1.8) "error" +testCase "round(#Down,1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Down 1.2) "error" +testCase "round(#Down,1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Down 1.5) "error" +testCase "round(#Down,1.8)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Down 1.8) "error" +testCase "round(#Down,-1.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Down -1.2) "error" +testCase "round(#Down,-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Down -1.5) "error" +testCase "round(#Down,-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Down -1.8) "error" +testCase "round(#Closest(#Zero),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#Zero) 1.2) "error" +testCase "round(#Closest(#Zero),1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#Zero) 1.5) "error" +testCase "round(#Closest(#Zero),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#Zero) 1.8) "error" +testCase "round(#Closest(#Zero),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#Zero) -1.2) "error" +testCase "round(#Closest(#Zero),-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#Zero) -1.5) "error" +testCase "round(#Closest(#Zero),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#Zero) -1.8) "error" +testCase "round(#Closest(#AwayFromZero),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#AwayFromZero) 1.2) "error" +testCase "round(#Closest(#AwayFromZero),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#AwayFromZero) 1.5) "error" +testCase "round(#Closest(#AwayFromZero),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#AwayFromZero) 1.8) "error" +testCase "round(#Closest(#AwayFromZero),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#AwayFromZero) -1.2) "error" +testCase "round(#Closest(#AwayFromZero),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#AwayFromZero) -1.5) "error" +testCase "round(#Closest(#AwayFromZero),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#AwayFromZero) -1.8) "error" +testCase "round(#Closest(#Up),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#Up) 1.2) "error" +testCase "round(#Closest(#Up),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#Up) 1.5) "error" +testCase "round(#Closest(#Up),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#Up) 1.8) "error" +testCase "round(#Closest(#Up),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#Up) -1.2) "error" +testCase "round(#Closest(#Up),-1.5)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#Up) -1.5) "error" +testCase "round(#Closest(#Up),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#Up) -1.8) "error" +testCase "round(#Closest(#Down),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#Down) 1.2) "error" +testCase "round(#Closest(#Down),1.5)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#Down) 1.5) "error" +testCase "round(#Closest(#Down),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#Down) 1.8) "error" +testCase "round(#Closest(#Down),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#Down) -1.2) "error" +testCase "round(#Closest(#Down),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#Down) -1.5) "error" +testCase "round(#Closest(#Down),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#Down) -1.8) "error" +testCase "round(#Closest(#ToEven),1.2)" +<| fun _ -> + let expected = 1. + Expect.equal expected (Float.round #Closest(#ToEven) 1.2) "error" +testCase "round(#Closest(#ToEven),1.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#ToEven) 1.5) "error" +testCase "round(#Closest(#ToEven),1.8)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#ToEven) 1.8) "error" +testCase "round(#Closest(#ToEven),2.2)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#ToEven) 2.2) "error" +testCase "round(#Closest(#ToEven),2.5)" +<| fun _ -> + let expected = 2. + Expect.equal expected (Float.round #Closest(#ToEven) 2.5) "error" +testCase "round(#Closest(#ToEven),2.8)" +<| fun _ -> + let expected = 3. + Expect.equal expected (Float.round #Closest(#ToEven) 2.8) "error" +testCase "round(#Closest(#ToEven),-1.2)" +<| fun _ -> + let expected = -1. + Expect.equal expected (Float.round #Closest(#ToEven) -1.2) "error" +testCase "round(#Closest(#ToEven),-1.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#ToEven) -1.5) "error" +testCase "round(#Closest(#ToEven),-1.8)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#ToEven) -1.8) "error" +testCase "round(#Closest(#ToEven),-2.2)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#ToEven) -2.2) "error" +testCase "round(#Closest(#ToEven),-2.5)" +<| fun _ -> + let expected = -2. + Expect.equal expected (Float.round #Closest(#ToEven) -2.5) "error" +testCase "round(#Closest(#ToEven),-2.8)" +<| fun _ -> + let expected = -3. + Expect.equal expected (Float.round #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/ocamlTests/FloatTest.ml b/test/ocamlTests/FloatTest.ml new file mode 100644 index 00000000..f6c81173 --- /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.,0.,8.)" (fun () -> expect (Float.clamp 5. 0. 8.) |> toEqual Eq.float 5.) ; +test "clamp(9.,0.,8.)" (fun () -> expect (Float.clamp 9. 0. 8.) |> toEqual Eq.float 8.) ; +test "clamp(1.,2.,8.)" (fun () -> expect (Float.clamp 1. 2. 8.) |> toEqual Eq.float 2.) ; +test "clamp(5.,-10.,-5.)" (fun () -> expect (Float.clamp 5. -10. -5.) |> toEqual Eq.float -5.) ; +test "clamp(-15.,-10.,-5.)" (fun () -> expect (Float.clamp -15. -10. -5.) |> toEqual Eq.float -10.) ; +test "clamp(-6.6,-7.9,nan)" (fun () -> expect (Float.clamp -6.6 -7.9 nan) |> toEqual Eq.float NaN) ; +test "clamp(-6.6,nan,0.)" (fun () -> expect (Float.clamp -6.6 nan 0.) |> toEqual Eq.float NaN) ; +test "clamp(nan,2.,8.)" (fun () -> expect (Float.clamp nan 2. 8.) |> toEqual Eq.float NaN) ; +test "clamp(3.,7., 1.)" (fun () -> expect (fun () -> clamp 3. 7. 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(0.,0.)" (fun () -> expect (Float.atan2 0. 0.) |> toEqual Eq.radians 0.) ; +test "atan2(1.,1.)" (fun () -> expect (Float.atan2 1. 1.) |> toEqual Eq.radians 0.7853981633974483) ; +test "atan2(1.,-1.)" (fun () -> expect (Float.atan2 1. -1.) |> toEqual Eq.radians 2.356194490192345) ; +test "atan2(-1.,-1.)" (fun () -> expect (Float.atan2 -1. -1.) |> toEqual Eq.radians -2.356194490192345) ; +test "atan2(-1.,1.)" (fun () -> expect (Float.atan2 -1. 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,2.)" (fun () -> expect (Float.divide 3.14 2.) |> toEqual Eq.float 1.57) ; +test "divide(3.14,0.)" (fun () -> expect (Float.divide 3.14 0.) |> toEqual Eq.float infinity) ; +test "divide(3.14,-0.)" (fun () -> expect (Float.divide 3.14 -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.,2.,4.)" (fun () -> expect (Float.inRange 3. 2. 4.) |> toEqual Eq.bool true) ; +test "inRange(8.,2.,4.)" (fun () -> expect (Float.inRange 8. 2. 4.) |> toEqual Eq.bool false) ; +test "inRange(1., 2.,4.)" (fun () -> expect (Float.inRange 1. 2. 4.) |> toEqual Eq.bool false) ; +test "inRange(2.,1.,2.)" (fun () -> expect (Float.inRange 2. 1. 2.) |> toEqual Eq.bool false) ; +test "inRange(-6.6,-7.9,-5.2)" (fun () -> expect (Float.inRange -6.6 -7.9 -5.2) |> toEqual Eq.bool true) ; +test "inRange(-6.6,-7.9,nan)" (fun () -> expect (Float.inRange -6.6 -7.9 nan) |> toEqual Eq.bool false) ; +test "inRange(-6.6,nan,0.)" (fun () -> expect (Float.inRange -6.6 nan 0.) |> toEqual Eq.bool false) ; +test "inRange(nan,2.,8.)" (fun () -> expect (Float.inRange nan 2. 8.) |> toEqual Eq.bool false) ; +test "inRange(3.,7.,1.)" (fun () -> expect (fun () -> inRange 3. 7. 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.,10.)" (fun () -> expect (Float.log 100. 10.) |> toEqual Eq.float 2.) ; +test "log(256.,2.)" (fun () -> expect (Float.log 256. 2.) |> toEqual Eq.float 8.) ; +test "log(0.,10.)" (fun () -> expect (Float.log 0. 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(7.,3.)" (fun () -> expect (Float.power 7. 3.) |> toEqual Eq.float 343.) ; +test "power(0.,3.)" (fun () -> expect (Float.power 0. 3.) |> toEqual Eq.float 0.) ; +test "power(7.,0.)" (fun () -> expect (Float.power 7. 0.) |> toEqual Eq.float 1.) ; +test "round(#Zero,1.2)" (fun () -> expect (Float.round #Zero 1.2) |> toEqual Eq.float 1.) ; +test "round(#Zero,1.5)" (fun () -> expect (Float.round #Zero 1.5) |> toEqual Eq.float 1.) ; +test "round(#Zero,1.8)" (fun () -> expect (Float.round #Zero 1.8) |> toEqual Eq.float 1.) ; +test "round(#Zero,-1.2)" (fun () -> expect (Float.round #Zero -1.2) |> toEqual Eq.float -1.) ; +test "round(#Zero,-1.5)" (fun () -> expect (Float.round #Zero -1.5) |> toEqual Eq.float -1.) ; +test "round(#Zero,-1.8)" (fun () -> expect (Float.round #Zero -1.8) |> toEqual Eq.float -1.) ; +test "round(#AwayFromZero,1.2)" (fun () -> expect (Float.round #AwayFromZero 1.2) |> toEqual Eq.float 2.) ; +test "round(#AwayFromZero,1.5)" (fun () -> expect (Float.round #AwayFromZero 1.5) |> toEqual Eq.float 2.) ; +test "round(#AwayFromZero,1.8)" (fun () -> expect (Float.round #AwayFromZero 1.8) |> toEqual Eq.float 2.) ; +test "round(#AwayFromZero,-1.2)" (fun () -> expect (Float.round #AwayFromZero -1.2) |> toEqual Eq.float -2.) ; +test "round(#AwayFromZero,-1.5)" (fun () -> expect (Float.round #AwayFromZero -1.5) |> toEqual Eq.float -2.) ; +test "round(#AwayFromZero,-1.8)" (fun () -> expect (Float.round #AwayFromZero -1.8) |> toEqual Eq.float -2.) ; +test "round(#Up,1.2)" (fun () -> expect (Float.round #Up 1.2) |> toEqual Eq.float 2.) ; +test "round(#Up,1.5)" (fun () -> expect (Float.round #Up 1.5) |> toEqual Eq.float 2.) ; +test "round(#Up,1.8)" (fun () -> expect (Float.round #Up 1.8) |> toEqual Eq.float 2.) ; +test "round(#Up,-1.2)" (fun () -> expect (Float.round #Up -1.2) |> toEqual Eq.float -1.) ; +test "round(#Up,-1.5)" (fun () -> expect (Float.round #Up -1.5) |> toEqual Eq.float -1.) ; +test "round(#Up,-1.8)" (fun () -> expect (Float.round #Up -1.8) |> toEqual Eq.float -1.) ; +test "round(#Down,1.2)" (fun () -> expect (Float.round #Down 1.2) |> toEqual Eq.float 1.) ; +test "round(#Down,1.5)" (fun () -> expect (Float.round #Down 1.5) |> toEqual Eq.float 1.) ; +test "round(#Down,1.8)" (fun () -> expect (Float.round #Down 1.8) |> toEqual Eq.float 1.) ; +test "round(#Down,-1.2)" (fun () -> expect (Float.round #Down -1.2) |> toEqual Eq.float -2.) ; +test "round(#Down,-1.5)" (fun () -> expect (Float.round #Down -1.5) |> toEqual Eq.float -2.) ; +test "round(#Down,-1.8)" (fun () -> expect (Float.round #Down -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#Zero),1.2)" (fun () -> expect (Float.round #Closest(#Zero) 1.2) |> toEqual Eq.float 1.) ; +test "round(#Closest(#Zero),1.5)" (fun () -> expect (Float.round #Closest(#Zero) 1.5) |> toEqual Eq.float 1.) ; +test "round(#Closest(#Zero),1.8)" (fun () -> expect (Float.round #Closest(#Zero) 1.8) |> toEqual Eq.float 2.) ; +test "round(#Closest(#Zero),-1.2)" (fun () -> expect (Float.round #Closest(#Zero) -1.2) |> toEqual Eq.float -1.) ; +test "round(#Closest(#Zero),-1.5)" (fun () -> expect (Float.round #Closest(#Zero) -1.5) |> toEqual Eq.float -1.) ; +test "round(#Closest(#Zero),-1.8)" (fun () -> expect (Float.round #Closest(#Zero) -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#AwayFromZero),1.2)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.2) |> toEqual Eq.float 1.) ; +test "round(#Closest(#AwayFromZero),1.5)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.5) |> toEqual Eq.float 2.) ; +test "round(#Closest(#AwayFromZero),1.8)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.8) |> toEqual Eq.float 2.) ; +test "round(#Closest(#AwayFromZero),-1.2)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.2) |> toEqual Eq.float -1.) ; +test "round(#Closest(#AwayFromZero),-1.5)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.5) |> toEqual Eq.float -2.) ; +test "round(#Closest(#AwayFromZero),-1.8)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#Up),1.2)" (fun () -> expect (Float.round #Closest(#Up) 1.2) |> toEqual Eq.float 1.) ; +test "round(#Closest(#Up),1.5)" (fun () -> expect (Float.round #Closest(#Up) 1.5) |> toEqual Eq.float 2.) ; +test "round(#Closest(#Up),1.8)" (fun () -> expect (Float.round #Closest(#Up) 1.8) |> toEqual Eq.float 2.) ; +test "round(#Closest(#Up),-1.2)" (fun () -> expect (Float.round #Closest(#Up) -1.2) |> toEqual Eq.float -1.) ; +test "round(#Closest(#Up),-1.5)" (fun () -> expect (Float.round #Closest(#Up) -1.5) |> toEqual Eq.float -1.) ; +test "round(#Closest(#Up),-1.8)" (fun () -> expect (Float.round #Closest(#Up) -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#Down),1.2)" (fun () -> expect (Float.round #Closest(#Down) 1.2) |> toEqual Eq.float 1.) ; +test "round(#Closest(#Down),1.5)" (fun () -> expect (Float.round #Closest(#Down) 1.5) |> toEqual Eq.float 1.) ; +test "round(#Closest(#Down),1.8)" (fun () -> expect (Float.round #Closest(#Down) 1.8) |> toEqual Eq.float 2.) ; +test "round(#Closest(#Down),-1.2)" (fun () -> expect (Float.round #Closest(#Down) -1.2) |> toEqual Eq.float -1.) ; +test "round(#Closest(#Down),-1.5)" (fun () -> expect (Float.round #Closest(#Down) -1.5) |> toEqual Eq.float -2.) ; +test "round(#Closest(#Down),-1.8)" (fun () -> expect (Float.round #Closest(#Down) -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#ToEven),1.2)" (fun () -> expect (Float.round #Closest(#ToEven) 1.2) |> toEqual Eq.float 1.) ; +test "round(#Closest(#ToEven),1.5)" (fun () -> expect (Float.round #Closest(#ToEven) 1.5) |> toEqual Eq.float 2.) ; +test "round(#Closest(#ToEven),1.8)" (fun () -> expect (Float.round #Closest(#ToEven) 1.8) |> toEqual Eq.float 2.) ; +test "round(#Closest(#ToEven),2.2)" (fun () -> expect (Float.round #Closest(#ToEven) 2.2) |> toEqual Eq.float 2.) ; +test "round(#Closest(#ToEven),2.5)" (fun () -> expect (Float.round #Closest(#ToEven) 2.5) |> toEqual Eq.float 2.) ; +test "round(#Closest(#ToEven),2.8)" (fun () -> expect (Float.round #Closest(#ToEven) 2.8) |> toEqual Eq.float 3.) ; +test "round(#Closest(#ToEven),-1.2)" (fun () -> expect (Float.round #Closest(#ToEven) -1.2) |> toEqual Eq.float -1.) ; +test "round(#Closest(#ToEven),-1.5)" (fun () -> expect (Float.round #Closest(#ToEven) -1.5) |> toEqual Eq.float -2.) ; +test "round(#Closest(#ToEven),-1.8)" (fun () -> expect (Float.round #Closest(#ToEven) -1.8) |> toEqual Eq.float -2.) ; +test "round(#Closest(#ToEven),-2.2)" (fun () -> expect (Float.round #Closest(#ToEven) -2.2) |> toEqual Eq.float -2.) ; +test "round(#Closest(#ToEven),-2.5)" (fun () -> expect (Float.round #Closest(#ToEven) -2.5) |> toEqual Eq.float -2.) ; +test "round(#Closest(#ToEven),-2.8)" (fun () -> expect (Float.round #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/rescriptTests/FloatTest.res b/test/rescriptTests/FloatTest.res new file mode 100644 index 00000000..699ac76c --- /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.,0.,8.)", () => expect(Float.clamp(5.,0.,8.)) |> toEqual(Eq.float, 5.)) +test ("clamp(9.,0.,8.)", () => expect(Float.clamp(9.,0.,8.)) |> toEqual(Eq.float, 8.)) +test ("clamp(1.,2.,8.)", () => expect(Float.clamp(1.,2.,8.)) |> toEqual(Eq.float, 2.)) +test ("clamp(5.,-10.,-5.)", () => expect(Float.clamp(5.,-10.,-5.)) |> toEqual(Eq.float, -5.)) +test ("clamp(-15.,-10.,-5.)", () => expect(Float.clamp(-15.,-10.,-5.)) |> toEqual(Eq.float, -10.)) +test ("clamp(-6.6,-7.9,nan)", () => expect(Float.clamp(-6.6,-7.9,nan)) |> toEqual(Eq.float, NaN)) +test ("clamp(-6.6,nan,0.)", () => expect(Float.clamp(-6.6,nan,0.)) |> toEqual(Eq.float, NaN)) +test ("clamp(nan,2.,8.)", () => expect(Float.clamp(nan,2.,8.)) |> toEqual(Eq.float, NaN)) +test ("clamp(3.,7., 1.)", () => expect(() => Float.clamp(3.,7., 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(0.,0.)", () => expect(Float.atan2(0.,0.)) |> toEqual(Eq.radians, 0.)) +test ("atan2(1.,1.)", () => expect(Float.atan2(1.,1.)) |> toEqual(Eq.radians, 0.7853981633974483)) +test ("atan2(1.,-1.)", () => expect(Float.atan2(1.,-1.)) |> toEqual(Eq.radians, 2.356194490192345)) +test ("atan2(-1.,-1.)", () => expect(Float.atan2(-1.,-1.)) |> toEqual(Eq.radians, -2.356194490192345)) +test ("atan2(-1.,1.)", () => expect(Float.atan2(-1.,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,2.)", () => expect(Float.divide(3.14,2.)) |> toEqual(Eq.float, 1.57)) +test ("divide(3.14,0.)", () => expect(Float.divide(3.14,0.)) |> toEqual(Eq.float, infinity)) +test ("divide(3.14,-0.)", () => expect(Float.divide(3.14,-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.,2.,4.)", () => expect(Float.inRange(3.,2.,4.)) |> toEqual(Eq.bool, true)) +test ("inRange(8.,2.,4.)", () => expect(Float.inRange(8.,2.,4.)) |> toEqual(Eq.bool, false)) +test ("inRange(1., 2.,4.)", () => expect(Float.inRange(1., 2.,4.)) |> toEqual(Eq.bool, false)) +test ("inRange(2.,1.,2.)", () => expect(Float.inRange(2.,1.,2.)) |> toEqual(Eq.bool, false)) +test ("inRange(-6.6,-7.9,-5.2)", () => expect(Float.inRange(-6.6,-7.9,-5.2)) |> toEqual(Eq.bool, true)) +test ("inRange(-6.6,-7.9,nan)", () => expect(Float.inRange(-6.6,-7.9,nan)) |> toEqual(Eq.bool, false)) +test ("inRange(-6.6,nan,0.)", () => expect(Float.inRange(-6.6,nan,0.)) |> toEqual(Eq.bool, false)) +test ("inRange(nan,2.,8.)", () => expect(Float.inRange(nan,2.,8.)) |> toEqual(Eq.bool, false)) +test ("inRange(3.,7.,1.)", () => expect(() => Float.inRange(3.,7.,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.,10.)", () => expect(Float.log(100.,10.)) |> toEqual(Eq.float, 2.)) +test ("log(256.,2.)", () => expect(Float.log(256.,2.)) |> toEqual(Eq.float, 8.)) +test ("log(0.,10.)", () => expect(Float.log(0.,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(7.,3.)", () => expect(Float.power(7.,3.)) |> toEqual(Eq.float, 343.)) +test ("power(0.,3.)", () => expect(Float.power(0.,3.)) |> toEqual(Eq.float, 0.)) +test ("power(7.,0.)", () => expect(Float.power(7.,0.)) |> toEqual(Eq.float, 1.)) +test ("round(#Zero,1.2)", () => expect(Float.round(#Zero,1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Zero,1.5)", () => expect(Float.round(#Zero,1.5)) |> toEqual(Eq.float, 1.)) +test ("round(#Zero,1.8)", () => expect(Float.round(#Zero,1.8)) |> toEqual(Eq.float, 1.)) +test ("round(#Zero,-1.2)", () => expect(Float.round(#Zero,-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Zero,-1.5)", () => expect(Float.round(#Zero,-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(#Zero,-1.8)", () => expect(Float.round(#Zero,-1.8)) |> toEqual(Eq.float, -1.)) +test ("round(#AwayFromZero,1.2)", () => expect(Float.round(#AwayFromZero,1.2)) |> toEqual(Eq.float, 2.)) +test ("round(#AwayFromZero,1.5)", () => expect(Float.round(#AwayFromZero,1.5)) |> toEqual(Eq.float, 2.)) +test ("round(#AwayFromZero,1.8)", () => expect(Float.round(#AwayFromZero,1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#AwayFromZero,-1.2)", () => expect(Float.round(#AwayFromZero,-1.2)) |> toEqual(Eq.float, -2.)) +test ("round(#AwayFromZero,-1.5)", () => expect(Float.round(#AwayFromZero,-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(#AwayFromZero,-1.8)", () => expect(Float.round(#AwayFromZero,-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Up,1.2)", () => expect(Float.round(#Up,1.2)) |> toEqual(Eq.float, 2.)) +test ("round(#Up,1.5)", () => expect(Float.round(#Up,1.5)) |> toEqual(Eq.float, 2.)) +test ("round(#Up,1.8)", () => expect(Float.round(#Up,1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Up,-1.2)", () => expect(Float.round(#Up,-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Up,-1.5)", () => expect(Float.round(#Up,-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(#Up,-1.8)", () => expect(Float.round(#Up,-1.8)) |> toEqual(Eq.float, -1.)) +test ("round(#Down,1.2)", () => expect(Float.round(#Down,1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Down,1.5)", () => expect(Float.round(#Down,1.5)) |> toEqual(Eq.float, 1.)) +test ("round(#Down,1.8)", () => expect(Float.round(#Down,1.8)) |> toEqual(Eq.float, 1.)) +test ("round(#Down,-1.2)", () => expect(Float.round(#Down,-1.2)) |> toEqual(Eq.float, -2.)) +test ("round(#Down,-1.5)", () => expect(Float.round(#Down,-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(#Down,-1.8)", () => expect(Float.round(#Down,-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#Zero),1.2)", () => expect(Float.round(#Closest(#Zero),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#Zero),1.5)", () => expect(Float.round(#Closest(#Zero),1.5)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#Zero),1.8)", () => expect(Float.round(#Closest(#Zero),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#Zero),-1.2)", () => expect(Float.round(#Closest(#Zero),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#Zero),-1.5)", () => expect(Float.round(#Closest(#Zero),-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#Zero),-1.8)", () => expect(Float.round(#Closest(#Zero),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#AwayFromZero),1.2)", () => expect(Float.round(#Closest(#AwayFromZero),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#AwayFromZero),1.5)", () => expect(Float.round(#Closest(#AwayFromZero),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#AwayFromZero),1.8)", () => expect(Float.round(#Closest(#AwayFromZero),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#AwayFromZero),-1.2)", () => expect(Float.round(#Closest(#AwayFromZero),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#AwayFromZero),-1.5)", () => expect(Float.round(#Closest(#AwayFromZero),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#AwayFromZero),-1.8)", () => expect(Float.round(#Closest(#AwayFromZero),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#Up),1.2)", () => expect(Float.round(#Closest(#Up),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#Up),1.5)", () => expect(Float.round(#Closest(#Up),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#Up),1.8)", () => expect(Float.round(#Closest(#Up),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#Up),-1.2)", () => expect(Float.round(#Closest(#Up),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#Up),-1.5)", () => expect(Float.round(#Closest(#Up),-1.5)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#Up),-1.8)", () => expect(Float.round(#Closest(#Up),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#Down),1.2)", () => expect(Float.round(#Closest(#Down),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#Down),1.5)", () => expect(Float.round(#Closest(#Down),1.5)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#Down),1.8)", () => expect(Float.round(#Closest(#Down),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#Down),-1.2)", () => expect(Float.round(#Closest(#Down),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#Down),-1.5)", () => expect(Float.round(#Closest(#Down),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#Down),-1.8)", () => expect(Float.round(#Closest(#Down),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#ToEven),1.2)", () => expect(Float.round(#Closest(#ToEven),1.2)) |> toEqual(Eq.float, 1.)) +test ("round(#Closest(#ToEven),1.5)", () => expect(Float.round(#Closest(#ToEven),1.5)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#ToEven),1.8)", () => expect(Float.round(#Closest(#ToEven),1.8)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#ToEven),2.2)", () => expect(Float.round(#Closest(#ToEven),2.2)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#ToEven),2.5)", () => expect(Float.round(#Closest(#ToEven),2.5)) |> toEqual(Eq.float, 2.)) +test ("round(#Closest(#ToEven),2.8)", () => expect(Float.round(#Closest(#ToEven),2.8)) |> toEqual(Eq.float, 3.)) +test ("round(#Closest(#ToEven),-1.2)", () => expect(Float.round(#Closest(#ToEven),-1.2)) |> toEqual(Eq.float, -1.)) +test ("round(#Closest(#ToEven),-1.5)", () => expect(Float.round(#Closest(#ToEven),-1.5)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#ToEven),-1.8)", () => expect(Float.round(#Closest(#ToEven),-1.8)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#ToEven),-2.2)", () => expect(Float.round(#Closest(#ToEven),-2.2)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#ToEven),-2.5)", () => expect(Float.round(#Closest(#ToEven),-2.5)) |> toEqual(Eq.float, -2.)) +test ("round(#Closest(#ToEven),-2.8)", () => expect(Float.round(#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/yaml-files/Float.absolute.yaml b/yaml-files/Float.absolute.yaml index 227f4241..62451d05 100644 --- a/yaml-files/Float.absolute.yaml +++ b/yaml-files/Float.absolute.yaml @@ -10,29 +10,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 8. - output: >- - 8. - - inputs: >- - -7. - output: >- - 7. - - inputs: >- - 0. - output: >- - 0. + - 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. + - inputs: "8." + output: "8." + - inputs: "-7." + output: "7." + - inputs: "0." + output: "0." added: 0.1.0 diff --git a/yaml-files/Float.atan.yaml b/yaml-files/Float.atan.yaml index 6a8c55c5..de2daa1d 100644 --- a/yaml-files/Float.atan.yaml +++ b/yaml-files/Float.atan.yaml @@ -10,10 +10,8 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 0. - output: >- - 0. + - inputs: "0." + output: "0." - inputs: 1. /. 1. output: 0.7853981633974483 - inputs: 1. /. -1. @@ -23,10 +21,8 @@ tests: - inputs: -1. /. 1. output: -0.7853981633974483 examples: - - inputs: >- - 0. - output: >- - 0. + - inputs: "0." + output: "0." - inputs: 1. /. 1. output: 0.7853981633974483 - inputs: 1. /. -1. diff --git a/yaml-files/Float.atan2.yaml b/yaml-files/Float.atan2.yaml index 1de68cc2..ccd2f6d4 100644 --- a/yaml-files/Float.atan2.yaml +++ b/yaml-files/Float.atan2.yaml @@ -12,37 +12,25 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [0., 0.] - output: >- - 0. - - inputs: >- - [1., 1.] + - inputs: ["0.", "0."] + output: "0." + - inputs: ["1.", "1."] output: 0.7853981633974483 - - inputs: >- - [1., -1.] + - inputs: ["1.", "-1."] output: 2.3561944901923449 - - inputs: >- - [-1., -1.] + - inputs: ["-1.", "-1."] output: -2.3561944901923449 - - inputs: >- - [-1., 1.] + - inputs: ["-1.", "1."] output: -0.7853981633974483 examples: - - inputs: >- - [0., 0.] - output: >- - 0. - - inputs: >- - [1., 1.] + - inputs: ["0.", "0."] + output: "0." + - inputs: ["1.", "1."] output: 0.7853981633974483 - - inputs: >- - [1., -1.] + - inputs: ["1.", "-1."] output: 2.3561944901923449 - - inputs: >- - [-1., -1.] + - inputs: ["-1.", "-1."] output: -2.3561944901923449 - - inputs: >- - [-1., 1.] + - inputs: ["-1.", "1."] output: -0.7853981633974483 added: 0.1.0 diff --git a/yaml-files/Float.ceiling.yaml b/yaml-files/Float.ceiling.yaml index ef0edd9a..50f730c0 100644 --- a/yaml-files/Float.ceiling.yaml +++ b/yaml-files/Float.ceiling.yaml @@ -11,40 +11,28 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: >- - 2. + output: "2." - inputs: 1.5 - output: >- - 2. + output: "2." - inputs: 1.8 - output: >- - 2. + output: "2." - inputs: -1.2 - output: >- - -1. + output: "-1." - inputs: -1.5 - output: >- - -1. + output: "-1." - inputs: -1.8 - output: >- - -1. + output: "-1." examples: - inputs: 1.2 - output: >- - 2. + output: "2." - inputs: 1.5 - output: >- - 2. + output: "2." - inputs: 1.8 - output: >- - 2. + output: "2." - inputs: -1.2 - output: >- - -1. + output: "-1." - inputs: -1.5 - output: >- - -1. + output: "-1." - inputs: -1.8 - output: >- - -1. + output: "-1." added: 0.1.0 diff --git a/yaml-files/Float.clamp.yaml b/yaml-files/Float.clamp.yaml index 3114d0e6..9d2a9f0f 100644 --- a/yaml-files/Float.clamp.yaml +++ b/yaml-files/Float.clamp.yaml @@ -14,67 +14,41 @@ 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: ["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.] + - inputs: [-6.6, nan, "0."] output: NaN - - inputs: >- - [nan, 2., 8.] + - inputs: [nan, "2.", "8."] output: NaN - - inputs: >- - [3., 7., 1.] + - 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: ["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.] + - inputs: [-6.6, nan, "0."] output: NaN - - inputs: >- - [nan, 2., 8.] + - inputs: [nan, "2.", "8."] output: NaN - - inputs: >- - [3., 7., 1.] + - inputs: ["3.", "7.", " 1."] output: exception added: 0.1.0 diff --git a/yaml-files/Float.degrees.yaml b/yaml-files/Float.degrees.yaml index fc896f27..31f3e9dd 100644 --- a/yaml-files/Float.degrees.yaml +++ b/yaml-files/Float.degrees.yaml @@ -10,11 +10,9 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 180. + - inputs: "180." output: pi examples: - - inputs: >- - 180. + - inputs: "180." output: pi added: 0.1.0 diff --git a/yaml-files/Float.divide.yaml b/yaml-files/Float.divide.yaml index 7ad606af..2a1385ff 100644 --- a/yaml-files/Float.divide.yaml +++ b/yaml-files/Float.divide.yaml @@ -12,23 +12,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [3.14, 2.] + - inputs: [3.14, "2."] output: 1.57 - - inputs: >- - [3.14, 0.] + - inputs: [3.14, "0."] output: infinity - - inputs: >- - [3.14, -0.] + - inputs: [3.14, "-0."] output: negativeInfinity examples: - - inputs: >- - [3.14, 2.] + - inputs: [3.14, "2."] output: 1.57 - - inputs: >- - [3.14, 0.] + - inputs: [3.14, "0."] output: infinity - - inputs: >- - [3.14, -0.] + - inputs: [3.14, "-0."] output: negativeInfinity added: 0.1.0 diff --git a/yaml-files/Float.floor.yaml b/yaml-files/Float.floor.yaml index 1628e43f..3aff9187 100644 --- a/yaml-files/Float.floor.yaml +++ b/yaml-files/Float.floor.yaml @@ -11,40 +11,28 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: >- - 1. + output: "1." - inputs: 1.5 - output: >- - 1. + output: "1." - inputs: 1.8 - output: >- - 1. + output: "1." - inputs: -1.2 - output: >- - -2. + output: "-2." - inputs: -1.5 - output: >- - -2. + output: "-2." - inputs: -1.8 - output: >- - -2. + output: "-2." examples: - inputs: 1.2 - output: >- - 1. + output: "1." - inputs: 1.5 - output: >- - 1. + output: "1." - inputs: 1.8 - output: >- - 1. + output: "1." - inputs: -1.2 - output: >- - -2. + output: "-2." - inputs: -1.5 - output: >- - -2. + output: "-2." - inputs: -1.8 - output: >- - -2. + output: "-2." added: 0.1.0 diff --git a/yaml-files/Float.fromInt.yaml b/yaml-files/Float.fromInt.yaml index 4c15238f..d8e19ab6 100644 --- a/yaml-files/Float.fromInt.yaml +++ b/yaml-files/Float.fromInt.yaml @@ -11,22 +11,16 @@ constraints: - no-rescript tests: - inputs: 5 - output: >- - 5.0 + output: "5.0" - inputs: 0 - output: >- - 0.0 + output: "0.0" - inputs: -7 - output: >- - -7.0 + output: "-7.0" examples: - inputs: 5 - output: >- - 5.0 + output: "5.0" - inputs: 0 - output: >- - 0.0 + output: "0.0" - inputs: -7 - output: >- - -7.0 + output: "-7.0" added: 0.1.0 diff --git a/yaml-files/Float.hypotenuse.yaml b/yaml-files/Float.hypotenuse.yaml index e39eed74..bee880a2 100644 --- a/yaml-files/Float.hypotenuse.yaml +++ b/yaml-files/Float.hypotenuse.yaml @@ -12,13 +12,9 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [3., 4.] - output: >- - 5. + - inputs: ["3.", "4."] + output: "5." examples: - - inputs: >- - [3., 4.] - output: >- - 5. + - inputs: ["3.", "4."] + output: "5." added: 0.1.0 diff --git a/yaml-files/Float.inRange.yaml b/yaml-files/Float.inRange.yaml index 48d4bb46..3748250a 100644 --- a/yaml-files/Float.inRange.yaml +++ b/yaml-files/Float.inRange.yaml @@ -14,55 +14,41 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [3., 2., 4.] + - inputs: ["3.", "2.", "4."] output: true - - inputs: >- - [8., 2., 4.] + - inputs: ["8.", "2.", "4."] output: false - - inputs: >- - [1., 2., 4.] + - inputs: ["1.", " 2.", "4."] output: false - - inputs: >- - [2., 1., 2.] + - 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.] + - inputs: [-6.6, nan, "0."] output: false - - inputs: >- - [nan, 2., 8.] + - inputs: [nan, "2.", "8."] output: false - - inputs: >- - [3., 7., 1.] + - inputs: ["3.", "7.", "1."] output: exception examples: - - inputs: >- - [3., 2., 4.] + - inputs: ["3.", "2.", "4."] output: true - - inputs: >- - [8., 2., 4.] + - inputs: ["8.", "2.", "4."] output: false - - inputs: >- - [1., 2., 4.] + - inputs: ["1.", " 2.", "4."] output: false - - inputs: >- - [2., 1., 2.] + - 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.] + - inputs: [-6.6, nan, "0."] output: false - - inputs: >- - [nan, 2., 8.] + - inputs: [nan, "2.", "8."] output: false - - inputs: >- - [3., 7., 1.] + - inputs: ["3.", "7.", "1."] output: exception added: 0.1.0 diff --git a/yaml-files/Float.isFinite.yaml b/yaml-files/Float.isFinite.yaml index b47362c9..a3693a4f 100644 --- a/yaml-files/Float.isFinite.yaml +++ b/yaml-files/Float.isFinite.yaml @@ -16,13 +16,11 @@ tests: output: false - inputs: nan output: false - - inputs: >- - -5. + - inputs: "-5." output: true - inputs: -0.314 output: true - - inputs: >- - 0. + - inputs: "0." output: true - inputs: 3.14 output: true @@ -33,13 +31,11 @@ examples: output: false - inputs: nan output: false - - inputs: >- - -5. + - inputs: "-5." output: true - inputs: -0.314 output: true - - inputs: >- - 0. + - inputs: "0." output: true - inputs: 3.14 output: true diff --git a/yaml-files/Float.isInfinite.yaml b/yaml-files/Float.isInfinite.yaml index 9dc264c3..595c5ae8 100644 --- a/yaml-files/Float.isInfinite.yaml +++ b/yaml-files/Float.isInfinite.yaml @@ -16,13 +16,11 @@ tests: output: true - inputs: nan output: false - - inputs: >- - -5. + - inputs: "-5." output: false - inputs: -0.314 output: false - - inputs: >- - 0. + - inputs: "0." output: false - inputs: 3.14 output: false @@ -33,13 +31,11 @@ examples: output: true - inputs: nan output: false - - inputs: >- - -5. + - inputs: "-5." output: false - inputs: -0.314 output: false - - inputs: >- - 0. + - inputs: "0." output: false - inputs: 3.14 output: false diff --git a/yaml-files/Float.isInteger.yaml b/yaml-files/Float.isInteger.yaml index f1c0f1b9..fbab6ccc 100644 --- a/yaml-files/Float.isInteger.yaml +++ b/yaml-files/Float.isInteger.yaml @@ -10,14 +10,12 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 5.0 + - inputs: "5.0" output: true - inputs: pi output: false examples: - - inputs: >- - 5.0 + - inputs: "5.0" output: true - inputs: pi output: false diff --git a/yaml-files/Float.log.yaml b/yaml-files/Float.log.yaml index b6b711d5..adf1770d 100644 --- a/yaml-files/Float.log.yaml +++ b/yaml-files/Float.log.yaml @@ -12,27 +12,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [100., 10.] - output: >- - 2. - - inputs: >- - [256., 2.] - output: >- - 8. - - inputs: >- - [0., 10.] + - 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.] + - 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 index 550ce4e1..c75015ac 100644 --- a/yaml-files/Float.maximum.yaml +++ b/yaml-files/Float.maximum.yaml @@ -12,41 +12,25 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [7., 9.] - output: >- - 9. - - inputs: >- - [-4., -1.] - output: >- - -1. - - inputs: >- - [7., nan] + - inputs: ["7.", "9."] + output: "9." + - inputs: ["-4.", "-1."] + output: "-1." + - inputs: ["7.", nan] output: NaN - - inputs: >- - [7., infinity] + - inputs: ["7.", infinity] output: infinity - - inputs: >- - [7., negativeInfinity] - output: >- - 7. + - inputs: ["7.", negativeInfinity] + output: "7." examples: - - inputs: >- - [7., 9.] - output: >- - 9. - - inputs: >- - [-4., -1.] - output: >- - -1. - - inputs: >- - [7., nan] + - inputs: ["7.", "9."] + output: "9." + - inputs: ["-4.", "-1."] + output: "-1." + - inputs: ["7.", nan] output: NaN - - inputs: >- - [7., infinity] + - inputs: ["7.", infinity] output: infinity - - inputs: >- - [7., negativeInfinity] - output: >- - 7. + - inputs: ["7.", negativeInfinity] + output: "7." added: 0.1.0 diff --git a/yaml-files/Float.minimum.yaml b/yaml-files/Float.minimum.yaml index b1ccbff3..ac0b7c1e 100644 --- a/yaml-files/Float.minimum.yaml +++ b/yaml-files/Float.minimum.yaml @@ -12,41 +12,25 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [7., 9.] - output: >- - 7. - - inputs: >- - [-4., -1.] - output: >- - -4. - - inputs: >- - [7., nan] + - inputs: ["7.", "9."] + output: "7." + - inputs: ["-4.", "-1."] + output: "-4." + - inputs: ["7.", nan] output: NaN - - inputs: >- - [7., infinity] - output: >- - 7. - - inputs: >- - [7., negativeInfinity] + - inputs: ["7.", infinity] + output: "7." + - inputs: ["7.", negativeInfinity] output: negativeInfinity examples: - - inputs: >- - [7., 9.] - output: >- - 7. - - inputs: >- - [-4., -1.] - output: >- - -4. - - inputs: >- - [7., nan] + - inputs: ["7.", "9."] + output: "7." + - inputs: ["-4.", "-1."] + output: "-4." + - inputs: ["7.", nan] output: NaN - - inputs: >- - [7., infinity] - output: >- - 7. - - inputs: >- - [7., negativeInfinity] + - 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 index c7529821..ada13143 100644 --- a/yaml-files/Float.multiply.yaml +++ b/yaml-files/Float.multiply.yaml @@ -12,13 +12,9 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [2., 7.] - output: >- - 14. + - inputs: ["2.", "7."] + output: "14." examples: - - inputs: >- - [2., 7.] - output: >- - 14. + - inputs: ["2.", "7."] + output: "14." added: 0.1.0 diff --git a/yaml-files/Float.negate.yaml b/yaml-files/Float.negate.yaml index c16b42a6..e82d5b49 100644 --- a/yaml-files/Float.negate.yaml +++ b/yaml-files/Float.negate.yaml @@ -10,29 +10,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 8. - output: >- - -8. - - inputs: >- - -7. - output: >- - 7. - - inputs: >- - 0. - output: >- - -0. + - 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. + - 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 index 1a368b7d..4cdffda6 100644 --- a/yaml-files/Float.power.yaml +++ b/yaml-files/Float.power.yaml @@ -12,29 +12,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [7., 3.] - output: >- - 343. - - inputs: >- - [0., 3.] - output: >- - 0. - - inputs: >- - [7., 0.] - output: >- - 1. + - 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. + - 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.round.yaml b/yaml-files/Float.round.yaml index 9710d946..1887f925 100644 --- a/yaml-files/Float.round.yaml +++ b/yaml-files/Float.round.yaml @@ -12,483 +12,245 @@ 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. + - 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. + - 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.squareRoot.yaml b/yaml-files/Float.squareRoot.yaml index daab4b05..f0fc6373 100644 --- a/yaml-files/Float.squareRoot.yaml +++ b/yaml-files/Float.squareRoot.yaml @@ -10,23 +10,17 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 4. - output: >- - 2. + - inputs: "4." + output: "2." - inputs: 20.25 output: 4.5 - - inputs: >- - -1. + - inputs: "-1." output: NaN examples: - - inputs: >- - 4. - output: >- - 2. + - inputs: "4." + output: "2." - inputs: 20.25 output: 4.5 - - inputs: >- - -1. + - inputs: "-1." output: NaN added: 0.1.0 diff --git a/yaml-files/Float.subtract.yaml b/yaml-files/Float.subtract.yaml index f566b487..05f640c0 100644 --- a/yaml-files/Float.subtract.yaml +++ b/yaml-files/Float.subtract.yaml @@ -12,13 +12,9 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - [4., 3.] - output: >- - 1. + - inputs: ["4.", "3."] + output: "1." examples: - - inputs: >- - [4., 3.] - output: >- - 1. + - inputs: ["4.", "3."] + output: "1." added: 0.1.0 diff --git a/yaml-files/Float.tan.yaml b/yaml-files/Float.tan.yaml index 5555ba5a..c0b05923 100644 --- a/yaml-files/Float.tan.yaml +++ b/yaml-files/Float.tan.yaml @@ -14,17 +14,13 @@ tests: output: 0.9999999999999999 - inputs: radians(pi /. 4.) output: 0.9999999999999999 - - inputs: >- - 0. - output: >- - 0. + - inputs: "0." + output: "0." examples: - inputs: degrees(45.) output: 0.9999999999999999 - inputs: radians(pi /. 4.) output: 0.9999999999999999 - - inputs: >- - 0. - output: >- - 0. + - inputs: "0." + output: "0." added: 0.1.0 diff --git a/yaml-files/Float.toInt.yaml b/yaml-files/Float.toInt.yaml index 52b5c1d1..0a486287 100644 --- a/yaml-files/Float.toInt.yaml +++ b/yaml-files/Float.toInt.yaml @@ -10,16 +10,13 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 5. + - inputs: "5." output: Some(5) - inputs: 5.3 output: Some(5) - - inputs: >- - 0. + - inputs: "0." output: Some(0) - - inputs: >- - -7. + - inputs: "-7." output: Some(-7) - inputs: nan output: None @@ -28,16 +25,13 @@ tests: - inputs: negativeInfinity output: None examples: - - inputs: >- - 5. + - inputs: "5." output: Some(5) - inputs: 5.3 output: Some(5) - - inputs: >- - 0. + - inputs: "0." output: Some(0) - - inputs: >- - -7. + - inputs: "-7." output: Some(-7) - inputs: nan output: None diff --git a/yaml-files/Float.truncate.yaml b/yaml-files/Float.truncate.yaml index d00423a7..72eef1a3 100644 --- a/yaml-files/Float.truncate.yaml +++ b/yaml-files/Float.truncate.yaml @@ -11,40 +11,28 @@ constraints: - no-rescript tests: - inputs: 1.2 - output: >- - 1. + output: "1." - inputs: 1.5 - output: >- - 1. + output: "1." - inputs: 1.8 - output: >- - 1. + output: "1." - inputs: -1.2 - output: >- - -1. + output: "-1." - inputs: -1.5 - output: >- - -1. + output: "-1." - inputs: -1.8 - output: >- - -1. + output: "-1." examples: - inputs: 1.2 - output: >- - 1. + output: "1." - inputs: 1.5 - output: >- - 1. + output: "1." - inputs: 1.8 - output: >- - 1. + output: "1." - inputs: -1.2 - output: >- - -1. + output: "-1." - inputs: -1.5 - output: >- - -1. + output: "-1." - inputs: -1.8 - output: >- - -1. + output: "-1." added: 0.1.0 diff --git a/yaml-files/Float.turns.yaml b/yaml-files/Float.turns.yaml index fc012c76..340faff7 100644 --- a/yaml-files/Float.turns.yaml +++ b/yaml-files/Float.turns.yaml @@ -10,11 +10,9 @@ constraints: - no-ocaml - no-rescript tests: - - inputs: >- - 1. + - inputs: "1." output: 2. *. pi examples: - - inputs: >- - 1. + - inputs: "1." output: 2. *. pi added: 0.1.0 diff --git a/yaml-files/Option.andThen.yaml b/yaml-files/Option.andThen.yaml index 69c2c7ff..ef40a1cf 100644 --- a/yaml-files/Option.andThen.yaml +++ b/yaml-files/Option.andThen.yaml @@ -5,21 +5,22 @@ parameters: - name: a type: option<'a> - name: f - type: 'a => option<'b> + type: >- + 'a => option<'b> returnType: option<'b> # For compatibility constraints: - no-ocaml - no-rescript tests: - - inputs: [Some(list{1, 2, 3}), List.head] + - inputs: [Some([1,2,3]), List.head] output: Some(1) - - inputs: [Some(list{}), List.head] + - inputs: [Some([]), List.head] output: None examples: - - inputs: [Some(list{1, 2, 3}), List.head] + - inputs: [Some([1,2,3]), List.head] output: Some(1) - - inputs: [Some(list{}), List.head] + - inputs: [Some([]), List.head] output: None added: 0.1.0 diff --git a/yaml-files/Option.map.yaml b/yaml-files/Option.map.yaml index f360f8b9..a72d1d2b 100644 --- a/yaml-files/Option.map.yaml +++ b/yaml-files/Option.map.yaml @@ -5,7 +5,8 @@ parameters: - name: a type: option<'a> - name: f - type: 'a => 'b + type: >- + 'a => 'b returnType: option<'b> # For compatibility constraints: @@ -26,5 +27,3 @@ examples: - inputs: [None, x => x * x] output: None added: 0.1.0 - - diff --git a/yaml-files/Option.toList.yaml b/yaml-files/Option.toList.yaml index ff6fddc5..89f7ae05 100644 --- a/yaml-files/Option.toList.yaml +++ b/yaml-files/Option.toList.yaml @@ -11,12 +11,12 @@ constraints: - no-rescript tests: - inputs: Some(3004) - output: list{3004} + output: [3004] - inputs: None - output: list{} + output: [] examples: - inputs: Some(3004) - output: list{3004} + output: [3004] - inputs: None - output: list{} + output: [] added: 0.1.0 From e192e12649bf6789ececdab4b2370cda440757be Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Nov 2022 13:45:34 +0100 Subject: [PATCH 30/31] Specify whether inputs need labels in the yaml files --- yaml-files/Array.all.yaml | 2 ++ yaml-files/Array.any.yaml | 2 ++ yaml-files/Array.append.yaml | 2 ++ yaml-files/Array.chunksOf.yaml | 2 ++ yaml-files/Array.clone.yaml | 1 + yaml-files/Array.compare.yaml | 3 +++ yaml-files/Array.count.yaml | 2 ++ yaml-files/Array.extent.yaml | 2 ++ yaml-files/Array.filter.yaml | 2 ++ yaml-files/Array.find.yaml | 2 ++ yaml-files/Array.findIndex.yaml | 2 ++ yaml-files/Array.first.yaml | 1 + yaml-files/Array.flatten.yaml | 1 + yaml-files/Array.fromList.yaml | 1 + yaml-files/Array.get.yaml | 2 ++ yaml-files/Array.getAt.yaml | 2 ++ yaml-files/Array.includes.yaml | 3 +++ yaml-files/Array.initialize.yaml | 2 ++ yaml-files/Array.intersperse.yaml | 2 ++ yaml-files/Array.isEmpty.yaml | 1 + yaml-files/Array.join.yaml | 2 ++ yaml-files/Array.last.yaml | 1 + yaml-files/Array.length.yaml | 1 + yaml-files/Array.map.yaml | 2 ++ yaml-files/Array.map2.yaml | 3 +++ yaml-files/Array.map3.yaml | 4 ++++ yaml-files/Array.mapWithIndex.yaml | 2 ++ yaml-files/Array.maximum.yaml | 2 ++ yaml-files/Array.minimum.yaml | 2 ++ yaml-files/Array.partition.yaml | 2 ++ yaml-files/Array.range.yaml | 2 ++ yaml-files/Array.repeat.yaml | 2 ++ yaml-files/Array.reverse.yaml | 1 + yaml-files/Array.setAt.yaml | 3 +++ yaml-files/Array.singleton.yaml | 1 + yaml-files/Array.sliding.yaml | 3 +++ yaml-files/Array.sort.yaml | 2 ++ yaml-files/Array.splitAt.yaml | 2 ++ yaml-files/Array.splitWhen.yaml | 2 ++ yaml-files/Array.swap.yaml | 3 +++ yaml-files/Array.toIndexedList.yaml | 1 + yaml-files/Array.toList.yaml | 1 + yaml-files/Array.unzip.yaml | 1 + yaml-files/Array.values.yaml | 1 + yaml-files/Array.zip.yaml | 2 ++ yaml-files/Bool.compare.yaml | 4 +++- yaml-files/Bool.equal.yaml | 4 +++- yaml-files/Bool.fromInt.yaml | 1 + yaml-files/Bool.fromString.yaml | 1 + yaml-files/Bool.toInt.yaml | 1 + yaml-files/Bool.toString.yaml | 1 + yaml-files/Bool.xor.yaml | 2 ++ yaml-files/Char.fromCode.yaml | 1 + yaml-files/Char.fromString.yaml | 1 + yaml-files/Char.isAlphanumeric.yaml | 1 + yaml-files/Char.isDigit.yaml | 1 + yaml-files/Char.isLetter.yaml | 1 + yaml-files/Char.isLowercase.yaml | 1 + yaml-files/Char.isPrintable.yaml | 1 + yaml-files/Char.isUppercase.yaml | 1 + yaml-files/Char.isWhitespace.yaml | 1 + yaml-files/Char.toCode.yaml | 1 + yaml-files/Char.toDigit.yaml | 1 + yaml-files/Char.toLowercase.yaml | 1 + yaml-files/Char.toString.yaml | 1 + yaml-files/Char.toUppercase.yaml | 1 + yaml-files/Float.absolute.yaml | 1 + yaml-files/Float.add.yaml | 2 ++ yaml-files/Float.atan.yaml | 1 + yaml-files/Float.atan2.yaml | 2 ++ yaml-files/Float.ceiling.yaml | 1 + yaml-files/Float.clamp.yaml | 3 +++ yaml-files/Float.cos.yaml | 1 + yaml-files/Float.degrees.yaml | 1 + yaml-files/Float.divide.yaml | 2 ++ yaml-files/Float.floor.yaml | 1 + yaml-files/Float.fromInt.yaml | 1 + yaml-files/Float.fromString.yaml | 1 + yaml-files/Float.hypotenuse.yaml | 2 ++ yaml-files/Float.inRange.yaml | 3 +++ yaml-files/Float.isFinite.yaml | 1 + yaml-files/Float.isInfinite.yaml | 1 + yaml-files/Float.isInteger.yaml | 1 + yaml-files/Float.isNaN.yaml | 1 + yaml-files/Float.log.yaml | 2 ++ yaml-files/Float.maximum.yaml | 2 ++ yaml-files/Float.minimum.yaml | 2 ++ yaml-files/Float.multiply.yaml | 2 ++ yaml-files/Float.negate.yaml | 1 + yaml-files/Float.power.yaml | 2 ++ yaml-files/Float.radians.yaml | 1 + yaml-files/Float.round.yaml | 2 ++ yaml-files/Float.sin.yaml | 1 + yaml-files/Float.squareRoot.yaml | 1 + yaml-files/Float.subtract.yaml | 2 ++ yaml-files/Float.tan.yaml | 1 + yaml-files/Float.toInt.yaml | 1 + yaml-files/Float.truncate.yaml | 1 + yaml-files/Float.turns.yaml | 1 + yaml-files/Fun.apply.yaml | 2 ++ yaml-files/Fun.compose..yaml | 3 +++ yaml-files/Fun.composeRight.yaml | 3 +++ yaml-files/Fun.constant.yaml | 2 ++ yaml-files/Fun.curry.yaml | 3 +++ yaml-files/Fun.curry3.yaml | 4 ++++ yaml-files/Fun.flip.yaml | 3 +++ yaml-files/Fun.identity.yaml | 1 + yaml-files/Fun.ignore.yaml | 1 + yaml-files/Fun.negate.yaml | 2 ++ yaml-files/Fun.sequence.yaml | 2 ++ yaml-files/Fun.uncurry.yaml | 2 ++ yaml-files/Fun.uncurry3.yaml | 2 ++ yaml-files/Int.absolute.yaml | 1 + yaml-files/Int.add.yaml | 2 ++ yaml-files/Int.clamp.yaml | 3 +++ yaml-files/Int.divide.yaml | 2 ++ yaml-files/Int.divideFloat.yaml | 2 ++ yaml-files/Int.fromString.yaml | 1 + yaml-files/Int.inRange.yaml | 3 +++ yaml-files/Int.isEven.yaml | 1 + yaml-files/Int.isOdd.yaml | 1 + yaml-files/Int.maximum.yaml | 2 ++ yaml-files/Int.minimum..yaml | 2 ++ yaml-files/Int.modulo.yaml | 2 ++ yaml-files/Int.multiply.yaml | 2 ++ yaml-files/Int.negate.yaml | 1 + yaml-files/Int.power.yaml | 2 ++ yaml-files/Int.remainder.yaml | 2 ++ yaml-files/Int.subtract.yaml | 2 ++ yaml-files/Int.toFloat.yaml | 1 + yaml-files/Int.toString.yaml | 1 + yaml-files/List.all.yaml | 2 ++ yaml-files/List.any.yaml | 2 ++ yaml-files/List.append.yaml | 2 ++ yaml-files/List.chunksOf.yaml | 2 ++ yaml-files/List.compare.yaml | 3 +++ yaml-files/List.cons.yaml | 2 ++ yaml-files/List.count.yaml | 2 ++ yaml-files/List.drop.yaml | 2 ++ yaml-files/List.dropWhile.yaml | 2 ++ yaml-files/List.equal.yaml | 3 +++ yaml-files/List.extent.yaml | 2 ++ yaml-files/List.filter.yaml | 2 ++ yaml-files/List.filterMap.yaml | 2 ++ yaml-files/List.filterWithIndex.yaml | 2 ++ yaml-files/List.find.yaml | 2 ++ yaml-files/List.findIndex.yaml | 2 ++ yaml-files/List.flatMap.yaml | 2 ++ yaml-files/List.flatten.yaml | 3 ++- yaml-files/List.fromArray.yaml | 1 + yaml-files/List.getAt.yaml | 2 ++ yaml-files/List.groupWhile.yaml | 2 ++ yaml-files/List.head.yaml | 1 + yaml-files/List.includes.yaml | 3 +++ yaml-files/List.initial.yaml | 1 + yaml-files/List.initialize.yaml | 2 ++ yaml-files/List.insertAt.yaml | 3 +++ yaml-files/List.intersperse.yaml | 2 ++ yaml-files/List.isEmpty.yaml | 1 + yaml-files/List.join.yaml | 2 ++ yaml-files/List.last.yaml | 1 + yaml-files/List.length.yaml | 1 + yaml-files/List.map.yaml | 2 ++ yaml-files/List.map2.yaml | 3 +++ yaml-files/List.map3.yaml | 4 ++++ yaml-files/List.mapWithIndex.yaml | 2 ++ yaml-files/List.maximum.yaml | 2 ++ yaml-files/List.maximumBy.yaml | 2 ++ yaml-files/List.minimum.yaml | 2 ++ yaml-files/List.minimumBy.yaml | 2 ++ yaml-files/List.partition.yaml | 2 ++ yaml-files/List.range.yaml | 2 ++ yaml-files/List.removeAt.yaml | 2 ++ yaml-files/List.repeat.yaml | 2 ++ yaml-files/List.reverse.yaml | 1 + yaml-files/List.singleton.yaml | 1 + yaml-files/List.sliding.yaml | 3 +++ yaml-files/List.sort.yaml | 2 ++ yaml-files/List.splitAt.yaml | 2 ++ yaml-files/List.splitWhen.yaml | 2 ++ yaml-files/List.take.yaml | 2 ++ yaml-files/List.takeWhile.yaml | 2 ++ yaml-files/List.toArray.yaml | 1 + yaml-files/List.uniqueBy.yaml | 2 ++ yaml-files/List.unzip.yaml | 1 + yaml-files/List.updateAt.yaml | 3 +++ yaml-files/List.zip.yaml | 2 ++ yaml-files/Option.andThen.yaml | 2 ++ yaml-files/Option.and_.yaml | 2 ++ yaml-files/Option.both.yaml | 2 ++ yaml-files/Option.compare.yaml | 3 +++ yaml-files/Option.equal.yaml | 3 +++ yaml-files/Option.flatten.yaml | 1 + yaml-files/Option.isNone.yaml | 1 + yaml-files/Option.isSome.yaml | 1 + yaml-files/Option.map.yaml | 2 ++ yaml-files/Option.map2.yaml | 3 +++ yaml-files/Option.orElse.yaml | 2 ++ yaml-files/Option.or_.yaml | 2 ++ yaml-files/Option.toArray.yaml | 1 + yaml-files/Option.toList.yaml | 1 + yaml-files/Option.unwrap.yaml | 2 ++ yaml-files/String.fromArray.yaml | 1 + yaml-files/String.fromChar.yaml | 1 + yaml-files/String.fromList.yaml | 1 + yaml-files/String.indexOf.yaml | 2 ++ yaml-files/String.indexOfRight.yaml | 2 ++ yaml-files/String.initialize.yaml | 2 ++ yaml-files/String.insertAt.yaml | 3 +++ yaml-files/String.isEmpty.yaml | 1 + yaml-files/String.length.yaml | 1 + yaml-files/String.repeat.yaml | 2 ++ yaml-files/String.reverse.yaml | 1 + yaml-files/String.split.yaml | 2 ++ yaml-files/String.toArray.yaml | 1 + yaml-files/String.toList.yaml | 1 + yaml-files/Tuple2.first.yaml | 1 + yaml-files/Tuple2.make.yaml | 2 ++ yaml-files/Tuple2.mapAll.yaml | 2 ++ yaml-files/Tuple2.mapEach.yaml | 3 +++ yaml-files/Tuple2.mapFirst.yaml | 2 ++ yaml-files/Tuple2.mapSecond.yaml | 2 ++ yaml-files/Tuple2.second.yaml | 1 + yaml-files/Tuple2.swap.yaml | 1 + yaml-files/Tuple2.toArray.yaml | 1 + yaml-files/Tuple2.toList.yaml | 1 + yaml-files/Tuple3.first.yaml | 1 + yaml-files/Tuple3.initial.yaml | 1 + yaml-files/Tuple3.make.yaml | 3 +++ yaml-files/Tuple3.mapAll.yaml | 2 ++ yaml-files/Tuple3.mapEach.yaml | 4 ++++ yaml-files/Tuple3.mapFirst.yaml | 2 ++ yaml-files/Tuple3.mapSecond.yaml | 2 ++ yaml-files/Tuple3.mapThird.yaml | 2 ++ yaml-files/Tuple3.rotateLeft.yaml | 1 + yaml-files/Tuple3.rotateRight.yaml | 1 + yaml-files/Tuple3.second.yaml | 1 + yaml-files/Tuple3.tail.yaml | 1 + yaml-files/Tuple3.third.yaml | 1 + yaml-files/Tuple3.toArray.yaml | 1 + yaml-files/Tuple3.toList.yaml | 1 + 241 files changed, 422 insertions(+), 3 deletions(-) diff --git a/yaml-files/Array.all.yaml b/yaml-files/Array.all.yaml index 46c61174..28d2fdf6 100644 --- a/yaml-files/Array.all.yaml +++ b/yaml-files/Array.all.yaml @@ -4,9 +4,11 @@ docstring: Determine if [f] returns true for [all] values in an array. Iteration parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/Array.any.yaml b/yaml-files/Array.any.yaml index 7821ebf4..72af6d29 100644 --- a/yaml-files/Array.any.yaml +++ b/yaml-files/Array.any.yaml @@ -4,9 +4,11 @@ docstring: Determine if [f] returns true for [any] values in an array. Iteration parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/Array.append.yaml b/yaml-files/Array.append.yaml index dee7c873..33a4ad66 100644 --- a/yaml-files/Array.append.yaml +++ b/yaml-files/Array.append.yaml @@ -4,8 +4,10 @@ docstring: Creates a new array which is the result of appending the second array parameters: - name: a type: array<'a> + label: false - name: b type: array<'a> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.chunksOf.yaml b/yaml-files/Array.chunksOf.yaml index 877ca709..765ce4c7 100644 --- a/yaml-files/Array.chunksOf.yaml +++ b/yaml-files/Array.chunksOf.yaml @@ -4,8 +4,10 @@ docstring: Split an array into equally sized chunks. If there aren't enough elem parameters: - name: a type: array<'a> + label: false - name: size type: int + label: true returnType: array> # For compatibility constraints: diff --git a/yaml-files/Array.clone.yaml b/yaml-files/Array.clone.yaml index 90b02ec2..be1ff8b7 100644 --- a/yaml-files/Array.clone.yaml +++ b/yaml-files/Array.clone.yaml @@ -4,6 +4,7 @@ docstring: Create a shallow copy of an array parameters: - name: a type: array<'a> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.compare.yaml b/yaml-files/Array.compare.yaml index af9bece3..40d7d26b 100644 --- a/yaml-files/Array.compare.yaml +++ b/yaml-files/Array.compare.yaml @@ -4,10 +4,13 @@ docstring: Compare two arrays using the provided [f] function to compare pairs o 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: diff --git a/yaml-files/Array.count.yaml b/yaml-files/Array.count.yaml index 2404d8f5..e060a34e 100644 --- a/yaml-files/Array.count.yaml +++ b/yaml-files/Array.count.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Array.extent.yaml b/yaml-files/Array.extent.yaml index e42010f0..5d1e56c7 100644 --- a/yaml-files/Array.extent.yaml +++ b/yaml-files/Array.extent.yaml @@ -4,8 +4,10 @@ docstring: Find a {!Tuple2} of the {!minimum} and {!maximum} in a single pass. R parameters: - name: a type: array<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<('a,'a)> # For compatibility constraints: diff --git a/yaml-files/Array.filter.yaml b/yaml-files/Array.filter.yaml index 1fadd8db..b2c0cf2c 100644 --- a/yaml-files/Array.filter.yaml +++ b/yaml-files/Array.filter.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Array.find.yaml b/yaml-files/Array.find.yaml index 85691c15..75b045ae 100644 --- a/yaml-files/Array.find.yaml +++ b/yaml-files/Array.find.yaml @@ -4,9 +4,11 @@ docstring: Returns, as an {!Option}, the first element for which [f] evaluates t parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.findIndex.yaml b/yaml-files/Array.findIndex.yaml index f11d7f9a..6c0c495d 100644 --- a/yaml-files/Array.findIndex.yaml +++ b/yaml-files/Array.findIndex.yaml @@ -4,8 +4,10 @@ docstring: Similar to {!Array.find} but [f] is also called with the current inde parameters: - name: a type: array<'a> + label: false - name: f type: (int, 'a) => bool + label: true returnType: option<(int, 'a)> # For compatibility constraints: diff --git a/yaml-files/Array.first.yaml b/yaml-files/Array.first.yaml index 8538286c..0ad3fdc2 100644 --- a/yaml-files/Array.first.yaml +++ b/yaml-files/Array.first.yaml @@ -4,6 +4,7 @@ docstring: Get the first element of an array. Returns [None] if the array is emp parameters: - name: a type: array<'a> + label: false returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.flatten.yaml b/yaml-files/Array.flatten.yaml index d6514f37..6645f03a 100644 --- a/yaml-files/Array.flatten.yaml +++ b/yaml-files/Array.flatten.yaml @@ -4,6 +4,7 @@ docstring: Flatten an array of arrays into a single array parameters: - name: a type: array> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.fromList.yaml b/yaml-files/Array.fromList.yaml index 1dbc3456..bc1147b5 100644 --- a/yaml-files/Array.fromList.yaml +++ b/yaml-files/Array.fromList.yaml @@ -4,6 +4,7 @@ docstring: Create an array from a {!List} parameters: - name: a type: list<'a> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.get.yaml b/yaml-files/Array.get.yaml index 290238cc..c16ee453 100644 --- a/yaml-files/Array.get.yaml +++ b/yaml-files/Array.get.yaml @@ -4,8 +4,10 @@ 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 diff --git a/yaml-files/Array.getAt.yaml b/yaml-files/Array.getAt.yaml index 914a7b76..e711e7e6 100644 --- a/yaml-files/Array.getAt.yaml +++ b/yaml-files/Array.getAt.yaml @@ -4,8 +4,10 @@ docstring: Returns, as an {!Option}, the element at index number [n] of array [a parameters: - name: a type: array<'a> + label: false - name: index type: int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.includes.yaml b/yaml-files/Array.includes.yaml index 17e71c9f..18ed9076 100644 --- a/yaml-files/Array.includes.yaml +++ b/yaml-files/Array.includes.yaml @@ -4,11 +4,14 @@ docstring: Test if an array contains the specified element using the provided [e 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: diff --git a/yaml-files/Array.initialize.yaml b/yaml-files/Array.initialize.yaml index 45303b71..de029fd6 100644 --- a/yaml-files/Array.initialize.yaml +++ b/yaml-files/Array.initialize.yaml @@ -4,8 +4,10 @@ docstring: Initialize an array. [Array.initialize n ~f] creates an array of leng parameters: - name: a type: int + label: false - name: f type: int => 'a + label: true returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.intersperse.yaml b/yaml-files/Array.intersperse.yaml index f5adedae..f3667dca 100644 --- a/yaml-files/Array.intersperse.yaml +++ b/yaml-files/Array.intersperse.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Array.isEmpty.yaml b/yaml-files/Array.isEmpty.yaml index 13c75c21..ae91b64a 100644 --- a/yaml-files/Array.isEmpty.yaml +++ b/yaml-files/Array.isEmpty.yaml @@ -4,6 +4,7 @@ docstring: Check if an array is empty parameters: - name: a type: array<'a> + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Array.join.yaml b/yaml-files/Array.join.yaml index fe4541a4..160ca608 100644 --- a/yaml-files/Array.join.yaml +++ b/yaml-files/Array.join.yaml @@ -4,8 +4,10 @@ docstring: Converts an array of strings into a {!String}, placing [sep] between parameters: - name: a type: array + label: false - name: sep type: string + label: true returnType: string # For compatibility constraints: diff --git a/yaml-files/Array.last.yaml b/yaml-files/Array.last.yaml index 6fbd09fd..d24f4e31 100644 --- a/yaml-files/Array.last.yaml +++ b/yaml-files/Array.last.yaml @@ -4,6 +4,7 @@ docstring: Get the last element of an array. Returns [None] if the array is empt parameters: - name: a type: array<'a> + label: false returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.length.yaml b/yaml-files/Array.length.yaml index 360545a3..62cc95c1 100644 --- a/yaml-files/Array.length.yaml +++ b/yaml-files/Array.length.yaml @@ -4,6 +4,7 @@ docstring: Return the length of an array parameters: - name: a type: array<'a> + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Array.map.yaml b/yaml-files/Array.map.yaml index d311c1f7..a4e0d83c 100644 --- a/yaml-files/Array.map.yaml +++ b/yaml-files/Array.map.yaml @@ -4,9 +4,11 @@ docstring: Create a new array which is the result of applying a function [f] to parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => 'b + label: true returnType: array<'b> # For compatibility constraints: diff --git a/yaml-files/Array.map2.yaml b/yaml-files/Array.map2.yaml index 51f4093d..a108660a 100644 --- a/yaml-files/Array.map2.yaml +++ b/yaml-files/Array.map2.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/Array.map3.yaml b/yaml-files/Array.map3.yaml index e9ffddfe..6fa4b8eb 100644 --- a/yaml-files/Array.map3.yaml +++ b/yaml-files/Array.map3.yaml @@ -4,12 +4,16 @@ 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: diff --git a/yaml-files/Array.mapWithIndex.yaml b/yaml-files/Array.mapWithIndex.yaml index e1dcc65f..1e0236f0 100644 --- a/yaml-files/Array.mapWithIndex.yaml +++ b/yaml-files/Array.mapWithIndex.yaml @@ -4,8 +4,10 @@ docstring: Apply a function [f] to every element with its index as the first arg parameters: - name: a type: array<'a> + label: false - name: f type: (int, 'a) => 'b + label: true returnType: array<'b> # For compatibility constraints: diff --git a/yaml-files/Array.maximum.yaml b/yaml-files/Array.maximum.yaml index f67d5160..92694705 100644 --- a/yaml-files/Array.maximum.yaml +++ b/yaml-files/Array.maximum.yaml @@ -4,8 +4,10 @@ docstring: Find the largest element using the provided [compare] function. Retur parameters: - name: a type: array<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.minimum.yaml b/yaml-files/Array.minimum.yaml index 5a955dbe..0f322b16 100644 --- a/yaml-files/Array.minimum.yaml +++ b/yaml-files/Array.minimum.yaml @@ -4,8 +4,10 @@ docstring: Find the smallest element using the provided [compare] function. Retu parameters: - name: a type: array<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Array.partition.yaml b/yaml-files/Array.partition.yaml index c3ef4468..8c8fbcb1 100644 --- a/yaml-files/Array.partition.yaml +++ b/yaml-files/Array.partition.yaml @@ -4,9 +4,11 @@ docstring: Split an array into a {!Tuple2} of arrays. Values which [f] returns t parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: (array<'a>, array<'a>) # For compatibility constraints: diff --git a/yaml-files/Array.range.yaml b/yaml-files/Array.range.yaml index 193a02aa..13780710 100644 --- a/yaml-files/Array.range.yaml +++ b/yaml-files/Array.range.yaml @@ -4,8 +4,10 @@ docstring: Creates an array containing all of the integers from [from] up to but parameters: - name: from type: int + label: true - name: to type: int + label: true returnType: array # For compatibility constraints: diff --git a/yaml-files/Array.repeat.yaml b/yaml-files/Array.repeat.yaml index b61d7a3d..c9afe548 100644 --- a/yaml-files/Array.repeat.yaml +++ b/yaml-files/Array.repeat.yaml @@ -4,8 +4,10 @@ docstring: Create an array of length with the value of parameters: - name: a type: \'a + label: false - name: length type: int + label: true returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.reverse.yaml b/yaml-files/Array.reverse.yaml index 55e3203a..22a510c2 100644 --- a/yaml-files/Array.reverse.yaml +++ b/yaml-files/Array.reverse.yaml @@ -4,6 +4,7 @@ docstring: Reverses an array {b in place}, mutating the existing array parameters: - name: a type: array<'a> + label: false returnType: unit # For compatibility constraints: diff --git a/yaml-files/Array.setAt.yaml b/yaml-files/Array.setAt.yaml index 49ad8a60..c3427b16 100644 --- a/yaml-files/Array.setAt.yaml +++ b/yaml-files/Array.setAt.yaml @@ -4,11 +4,14 @@ docstring: Modifies an array in place, replacing the element at [index] with [va 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: diff --git a/yaml-files/Array.singleton.yaml b/yaml-files/Array.singleton.yaml index 2e86f7ab..69247b66 100644 --- a/yaml-files/Array.singleton.yaml +++ b/yaml-files/Array.singleton.yaml @@ -5,6 +5,7 @@ parameters: - name: a type: >- 'a + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Array.sliding.yaml b/yaml-files/Array.sliding.yaml index 636d9c00..a3ada1e0 100644 --- a/yaml-files/Array.sliding.yaml +++ b/yaml-files/Array.sliding.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/Array.sort.yaml b/yaml-files/Array.sort.yaml index 000af58a..a3999352 100644 --- a/yaml-files/Array.sort.yaml +++ b/yaml-files/Array.sort.yaml @@ -4,8 +4,10 @@ docstring: Sort in place, modifying the existing array, using the provided [comp parameters: - name: a type: array<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: unit # For compatibility constraints: diff --git a/yaml-files/Array.splitAt.yaml b/yaml-files/Array.splitAt.yaml index 0d14a9b3..bb0de814 100644 --- a/yaml-files/Array.splitAt.yaml +++ b/yaml-files/Array.splitAt.yaml @@ -4,8 +4,10 @@ docstring: Divides an array into a {!Tuple2} of arrays. Elements which have ind parameters: - name: a type: array<'a> + label: false - name: index type: int + label: true returnType: (array<'a>, array<'a>) # For compatibility constraints: diff --git a/yaml-files/Array.splitWhen.yaml b/yaml-files/Array.splitWhen.yaml index 79d94d48..7bcc86ea 100644 --- a/yaml-files/Array.splitWhen.yaml +++ b/yaml-files/Array.splitWhen.yaml @@ -4,9 +4,11 @@ docstring: Divides an array at the first element [f] returns [true] for. Returns parameters: - name: a type: array<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: (array<'a>, array<'a>) # For compatibility constraints: diff --git a/yaml-files/Array.swap.yaml b/yaml-files/Array.swap.yaml index 6f1fa88f..c530a60b 100644 --- a/yaml-files/Array.swap.yaml +++ b/yaml-files/Array.swap.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/Array.toIndexedList.yaml b/yaml-files/Array.toIndexedList.yaml index d34a8a44..af922fbc 100644 --- a/yaml-files/Array.toIndexedList.yaml +++ b/yaml-files/Array.toIndexedList.yaml @@ -4,6 +4,7 @@ docstring: Create an indexed {!List} from an array. Each element of the array wi parameters: - name: a type: array<'a> + label: false returnType: list<(int, 'a)> # For compatibility constraints: diff --git a/yaml-files/Array.toList.yaml b/yaml-files/Array.toList.yaml index a6f49b56..7224f6c5 100644 --- a/yaml-files/Array.toList.yaml +++ b/yaml-files/Array.toList.yaml @@ -4,6 +4,7 @@ docstring: Create a {!List} of elements from an array parameters: - name: a type: array<'a> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/Array.unzip.yaml b/yaml-files/Array.unzip.yaml index dbed2639..129c2f35 100644 --- a/yaml-files/Array.unzip.yaml +++ b/yaml-files/Array.unzip.yaml @@ -4,6 +4,7 @@ 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: diff --git a/yaml-files/Array.values.yaml b/yaml-files/Array.values.yaml index bdbce914..dc3f1433 100644 --- a/yaml-files/Array.values.yaml +++ b/yaml-files/Array.values.yaml @@ -4,6 +4,7 @@ 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: diff --git a/yaml-files/Array.zip.yaml b/yaml-files/Array.zip.yaml index b49af9ed..4db7628e 100644 --- a/yaml-files/Array.zip.yaml +++ b/yaml-files/Array.zip.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Bool.compare.yaml b/yaml-files/Bool.compare.yaml index 8e262acd..5b845c1c 100644 --- a/yaml-files/Bool.compare.yaml +++ b/yaml-files/Bool.compare.yaml @@ -4,8 +4,10 @@ docstring: Compare two and . parameters: - name: a type: bool - - name: a + label: false + - name: b type: bool + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Bool.equal.yaml b/yaml-files/Bool.equal.yaml index c05578c2..4c2c7293 100644 --- a/yaml-files/Bool.equal.yaml +++ b/yaml-files/Bool.equal.yaml @@ -4,8 +4,10 @@ docstring: Test for the equality of and parameters: - name: a type: bool - - name: a + label: false + - name: b type: bool + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Bool.fromInt.yaml b/yaml-files/Bool.fromInt.yaml index b6cba8b4..5825577c 100644 --- a/yaml-files/Bool.fromInt.yaml +++ b/yaml-files/Bool.fromInt.yaml @@ -4,6 +4,7 @@ docstring: Convert (Int) into a Boolean parameters: - name: a type: int + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Bool.fromString.yaml b/yaml-files/Bool.fromString.yaml index 995a2a57..29479d02 100644 --- a/yaml-files/Bool.fromString.yaml +++ b/yaml-files/Bool.fromString.yaml @@ -4,6 +4,7 @@ docstring: Convert (String) into a Boolean parameters: - name: a type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Bool.toInt.yaml b/yaml-files/Bool.toInt.yaml index fb736094..8cf3b5a1 100644 --- a/yaml-files/Bool.toInt.yaml +++ b/yaml-files/Bool.toInt.yaml @@ -4,6 +4,7 @@ docstring: Convert (Bool) into an Int parameters: - name: a type: bool + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Bool.toString.yaml b/yaml-files/Bool.toString.yaml index 729d3628..f9d54284 100644 --- a/yaml-files/Bool.toString.yaml +++ b/yaml-files/Bool.toString.yaml @@ -4,6 +4,7 @@ docstring: Convert (Bool) into a String parameters: - name: a type: bool + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/Bool.xor.yaml b/yaml-files/Bool.xor.yaml index 33f67563..970d8883 100644 --- a/yaml-files/Bool.xor.yaml +++ b/yaml-files/Bool.xor.yaml @@ -4,8 +4,10 @@ docstring: Perform the exclusive or operator on and .Returnin parameters: - name: a type: bool + label: false - name: b type: bool + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.fromCode.yaml b/yaml-files/Char.fromCode.yaml index 830e9aaa..09754753 100644 --- a/yaml-files/Char.fromCode.yaml +++ b/yaml-files/Char.fromCode.yaml @@ -4,6 +4,7 @@ docstring: Convert an ASCII code point to a character parameters: - name: a type: int + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Char.fromString.yaml b/yaml-files/Char.fromString.yaml index 293f5ae8..05cd63f3 100644 --- a/yaml-files/Char.fromString.yaml +++ b/yaml-files/Char.fromString.yaml @@ -4,6 +4,7 @@ docstring: Converts a string to character parameters: - name: a type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Char.isAlphanumeric.yaml b/yaml-files/Char.isAlphanumeric.yaml index 4c642f46..68f79049 100644 --- a/yaml-files/Char.isAlphanumeric.yaml +++ b/yaml-files/Char.isAlphanumeric.yaml @@ -4,6 +4,7 @@ docstring: Detect upper case, lower case and digit ASCII characters parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isDigit.yaml b/yaml-files/Char.isDigit.yaml index 5298af88..af8ca1cf 100644 --- a/yaml-files/Char.isDigit.yaml +++ b/yaml-files/Char.isDigit.yaml @@ -4,6 +4,7 @@ docstring: Detect when a character is a number parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isLetter.yaml b/yaml-files/Char.isLetter.yaml index 4a265945..b4703695 100644 --- a/yaml-files/Char.isLetter.yaml +++ b/yaml-files/Char.isLetter.yaml @@ -4,6 +4,7 @@ docstring: Detect upper and lower case ASCII alphabetic characters. parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isLowercase.yaml b/yaml-files/Char.isLowercase.yaml index 63f2fb64..d22bbd55 100644 --- a/yaml-files/Char.isLowercase.yaml +++ b/yaml-files/Char.isLowercase.yaml @@ -4,6 +4,7 @@ docstring: Detect lower case ASCII characters parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isPrintable.yaml b/yaml-files/Char.isPrintable.yaml index ffd7ce88..84a02a5f 100644 --- a/yaml-files/Char.isPrintable.yaml +++ b/yaml-files/Char.isPrintable.yaml @@ -4,6 +4,7 @@ docstring: Detect if a character is a printable character parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isUppercase.yaml b/yaml-files/Char.isUppercase.yaml index a7ec0c1b..04d0039d 100644 --- a/yaml-files/Char.isUppercase.yaml +++ b/yaml-files/Char.isUppercase.yaml @@ -4,6 +4,7 @@ docstring: Detect upper case ASCII characters parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.isWhitespace.yaml b/yaml-files/Char.isWhitespace.yaml index ab49e6d7..18b499ec 100644 --- a/yaml-files/Char.isWhitespace.yaml +++ b/yaml-files/Char.isWhitespace.yaml @@ -4,6 +4,7 @@ docstring: Detect one of the following characters ['\t'] (tab), ['\n'] (newline) parameters: - name: a type: char + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Char.toCode.yaml b/yaml-files/Char.toCode.yaml index 90874551..9b491980 100644 --- a/yaml-files/Char.toCode.yaml +++ b/yaml-files/Char.toCode.yaml @@ -4,6 +4,7 @@ docstring: Convert to the corresponding ASCII code point parameters: - name: a type: char + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Char.toDigit.yaml b/yaml-files/Char.toDigit.yaml index c9443a5d..2b102ee8 100644 --- a/yaml-files/Char.toDigit.yaml +++ b/yaml-files/Char.toDigit.yaml @@ -4,6 +4,7 @@ docstring: Converts a digit character to its corresponding {!Int} parameters: - name: a type: char + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Char.toLowercase.yaml b/yaml-files/Char.toLowercase.yaml index 9349f19f..e1df35a9 100644 --- a/yaml-files/Char.toLowercase.yaml +++ b/yaml-files/Char.toLowercase.yaml @@ -4,6 +4,7 @@ docstring: Converts an ASCII character to lower case, preserving non alphabetic parameters: - name: a type: char + label: false returnType: char # For compatibility constraints: diff --git a/yaml-files/Char.toString.yaml b/yaml-files/Char.toString.yaml index 9f1711e2..e06330e5 100644 --- a/yaml-files/Char.toString.yaml +++ b/yaml-files/Char.toString.yaml @@ -4,6 +4,7 @@ docstring: Convert to a [string] parameters: - name: a type: char + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/Char.toUppercase.yaml b/yaml-files/Char.toUppercase.yaml index 8d07941a..0dffa860 100644 --- a/yaml-files/Char.toUppercase.yaml +++ b/yaml-files/Char.toUppercase.yaml @@ -4,6 +4,7 @@ docstring: Converts an ASCII character to upper case, preserving non alphabetic parameters: - name: a type: char + label: false returnType: char # For compatibility constraints: diff --git a/yaml-files/Float.absolute.yaml b/yaml-files/Float.absolute.yaml index 62451d05..72afbfec 100644 --- a/yaml-files/Float.absolute.yaml +++ b/yaml-files/Float.absolute.yaml @@ -4,6 +4,7 @@ docstring: Get the absolute value of parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.add.yaml b/yaml-files/Float.add.yaml index f5154f86..7da22ac1 100644 --- a/yaml-files/Float.add.yaml +++ b/yaml-files/Float.add.yaml @@ -4,8 +4,10 @@ docstring: Add to , returning their sum parameters: - name: a type: float + label: false - name: b type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.atan.yaml b/yaml-files/Float.atan.yaml index de2daa1d..3132da27 100644 --- a/yaml-files/Float.atan.yaml +++ b/yaml-files/Float.atan.yaml @@ -4,6 +4,7 @@ docstring: Find the angle (in radians) to an [(x, y)] coordinate parameters: - name: a type: float + label: false returnType: radians # For compatibility constraints: diff --git a/yaml-files/Float.atan2.yaml b/yaml-files/Float.atan2.yaml index ccd2f6d4..efb3d065 100644 --- a/yaml-files/Float.atan2.yaml +++ b/yaml-files/Float.atan2.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Float.ceiling.yaml b/yaml-files/Float.ceiling.yaml index 50f730c0..73caebb5 100644 --- a/yaml-files/Float.ceiling.yaml +++ b/yaml-files/Float.ceiling.yaml @@ -4,6 +4,7 @@ docstring: Takes param, and returns the least number greater than or equal to parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.clamp.yaml b/yaml-files/Float.clamp.yaml index 9d2a9f0f..9c1c97aa 100644 --- a/yaml-files/Float.clamp.yaml +++ b/yaml-files/Float.clamp.yaml @@ -4,10 +4,13 @@ docstring: Clamps within the inclusive [lower] and [upper] bounds and parameters: - name: a type: float + label: false - name: lower type: float + label: true - name: upper type: float + label: true returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.cos.yaml b/yaml-files/Float.cos.yaml index 759ee85c..8364509f 100644 --- a/yaml-files/Float.cos.yaml +++ b/yaml-files/Float.cos.yaml @@ -4,6 +4,7 @@ docstring: Takes in radians and figure out its cosine parameters: - name: a type: radians + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.degrees.yaml b/yaml-files/Float.degrees.yaml index 31f3e9dd..b69a420d 100644 --- a/yaml-files/Float.degrees.yaml +++ b/yaml-files/Float.degrees.yaml @@ -4,6 +4,7 @@ docstring: Converts an angle in degrees to radians parameters: - name: a type: float + label: false returnType: radians # For compatibility constraints: diff --git a/yaml-files/Float.divide.yaml b/yaml-files/Float.divide.yaml index 2a1385ff..d7b72a70 100644 --- a/yaml-files/Float.divide.yaml +++ b/yaml-files/Float.divide.yaml @@ -4,8 +4,10 @@ docstring: divide by , returning their quotient parameters: - name: a type: float + label: false - name: by type: float + label: true returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.floor.yaml b/yaml-files/Float.floor.yaml index 3aff9187..cf17a437 100644 --- a/yaml-files/Float.floor.yaml +++ b/yaml-files/Float.floor.yaml @@ -4,6 +4,7 @@ docstring: Takes param, and returns the greatest number less than or equal to parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.fromInt.yaml b/yaml-files/Float.fromInt.yaml index d8e19ab6..4930adf0 100644 --- a/yaml-files/Float.fromInt.yaml +++ b/yaml-files/Float.fromInt.yaml @@ -4,6 +4,7 @@ docstring: Convert into a Float parameters: - name: a type: int + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.fromString.yaml b/yaml-files/Float.fromString.yaml index 80289bba..9c635fa2 100644 --- a/yaml-files/Float.fromString.yaml +++ b/yaml-files/Float.fromString.yaml @@ -4,6 +4,7 @@ docstring: Attempt to parse to a float parameters: - name: a type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Float.hypotenuse.yaml b/yaml-files/Float.hypotenuse.yaml index bee880a2..2729661d 100644 --- a/yaml-files/Float.hypotenuse.yaml +++ b/yaml-files/Float.hypotenuse.yaml @@ -4,8 +4,10 @@ docstring: returns the length of the hypotenuse of a right-angled triangle with parameters: - name: a type: float + label: false - name: b type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.inRange.yaml b/yaml-files/Float.inRange.yaml index 3748250a..428df612 100644 --- a/yaml-files/Float.inRange.yaml +++ b/yaml-files/Float.inRange.yaml @@ -4,10 +4,13 @@ docstring: Checks if is between and up to, but not inclu parameters: - name: a type: float + label: false - name: lower type: float + label: true - name: upper type: float + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/Float.isFinite.yaml b/yaml-files/Float.isFinite.yaml index a3693a4f..62350ace 100644 --- a/yaml-files/Float.isFinite.yaml +++ b/yaml-files/Float.isFinite.yaml @@ -4,6 +4,7 @@ docstring: Determine whether is finite number. Returning True for any parameters: - name: a type: float + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Float.isInfinite.yaml b/yaml-files/Float.isInfinite.yaml index 595c5ae8..8e76276e 100644 --- a/yaml-files/Float.isInfinite.yaml +++ b/yaml-files/Float.isInfinite.yaml @@ -4,6 +4,7 @@ docstring: Determine whether is positive or negative infinity. parameters: - name: a type: float + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Float.isInteger.yaml b/yaml-files/Float.isInteger.yaml index fbab6ccc..5357e017 100644 --- a/yaml-files/Float.isInteger.yaml +++ b/yaml-files/Float.isInteger.yaml @@ -4,6 +4,7 @@ docstring: Determine whether the is an integer. parameters: - name: a type: float + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Float.isNaN.yaml b/yaml-files/Float.isNaN.yaml index 00e2d7a8..685a6bf3 100644 --- a/yaml-files/Float.isNaN.yaml +++ b/yaml-files/Float.isNaN.yaml @@ -4,6 +4,7 @@ docstring: Determine whether is an [undefined] or unrepresentable numb parameters: - name: a type: float + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Float.log.yaml b/yaml-files/Float.log.yaml index adf1770d..7895575c 100644 --- a/yaml-files/Float.log.yaml +++ b/yaml-files/Float.log.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Float.maximum.yaml b/yaml-files/Float.maximum.yaml index c75015ac..9e711e89 100644 --- a/yaml-files/Float.maximum.yaml +++ b/yaml-files/Float.maximum.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Float.minimum.yaml b/yaml-files/Float.minimum.yaml index ac0b7c1e..8d239fd6 100644 --- a/yaml-files/Float.minimum.yaml +++ b/yaml-files/Float.minimum.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Float.multiply.yaml b/yaml-files/Float.multiply.yaml index ada13143..53a3cf51 100644 --- a/yaml-files/Float.multiply.yaml +++ b/yaml-files/Float.multiply.yaml @@ -4,8 +4,10 @@ docstring: Multiply by , returning their product parameters: - name: a type: float + label: false - name: b type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.negate.yaml b/yaml-files/Float.negate.yaml index e82d5b49..8769affe 100644 --- a/yaml-files/Float.negate.yaml +++ b/yaml-files/Float.negate.yaml @@ -4,6 +4,7 @@ docstring: Flips the 'sign' of parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.power.yaml b/yaml-files/Float.power.yaml index 4cdffda6..a7fff7fe 100644 --- a/yaml-files/Float.power.yaml +++ b/yaml-files/Float.power.yaml @@ -4,8 +4,10 @@ docstring: Raise to the power of , returning the po parameters: - name: base type: float + label: true - name: exponent type: float + label: true returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.radians.yaml b/yaml-files/Float.radians.yaml index a8b4ddb0..a9e29e49 100644 --- a/yaml-files/Float.radians.yaml +++ b/yaml-files/Float.radians.yaml @@ -4,6 +4,7 @@ docstring: Convert to radians parameters: - name: a type: float + label: false returnType: radians # For compatibility constraints: diff --git a/yaml-files/Float.round.yaml b/yaml-files/Float.round.yaml index 1887f925..6e7160bc 100644 --- a/yaml-files/Float.round.yaml +++ b/yaml-files/Float.round.yaml @@ -4,8 +4,10 @@ docstring: Round , by default to the to the closest [int] with halves r parameters: - name: direction type: Direction + label: true - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.sin.yaml b/yaml-files/Float.sin.yaml index 160cbe50..720c0250 100644 --- a/yaml-files/Float.sin.yaml +++ b/yaml-files/Float.sin.yaml @@ -4,6 +4,7 @@ docstring: Takes in radians and figure out its sine parameters: - name: a type: radians + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.squareRoot.yaml b/yaml-files/Float.squareRoot.yaml index f0fc6373..c1e9000a 100644 --- a/yaml-files/Float.squareRoot.yaml +++ b/yaml-files/Float.squareRoot.yaml @@ -4,6 +4,7 @@ docstring: Takes and returns its square root or [NaN] when it is negat parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.subtract.yaml b/yaml-files/Float.subtract.yaml index 05f640c0..35cd496f 100644 --- a/yaml-files/Float.subtract.yaml +++ b/yaml-files/Float.subtract.yaml @@ -4,8 +4,10 @@ docstring: Subtract from , returning their difference parameters: - name: a type: float + label: false - name: b type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.tan.yaml b/yaml-files/Float.tan.yaml index c0b05923..c9e0bf5d 100644 --- a/yaml-files/Float.tan.yaml +++ b/yaml-files/Float.tan.yaml @@ -4,6 +4,7 @@ docstring: Takes and figure out its tangent parameters: - name: a type: radians + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.toInt.yaml b/yaml-files/Float.toInt.yaml index 0a486287..17a92e50 100644 --- a/yaml-files/Float.toInt.yaml +++ b/yaml-files/Float.toInt.yaml @@ -4,6 +4,7 @@ docstring: Attempt to convert into an Int parameters: - name: a type: float + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Float.truncate.yaml b/yaml-files/Float.truncate.yaml index 72eef1a3..8d1f5e3a 100644 --- a/yaml-files/Float.truncate.yaml +++ b/yaml-files/Float.truncate.yaml @@ -4,6 +4,7 @@ docstring: Takes and remove all the positions after the decimal point parameters: - name: a type: float + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Float.turns.yaml b/yaml-files/Float.turns.yaml index 340faff7..5bd075c6 100644 --- a/yaml-files/Float.turns.yaml +++ b/yaml-files/Float.turns.yaml @@ -4,6 +4,7 @@ docstring: Convert an angle in turns into radians parameters: - name: a type: float + label: false returnType: radians # For compatibility constraints: diff --git a/yaml-files/Fun.apply.yaml b/yaml-files/Fun.apply.yaml index bf7dc8d5..11c1bed5 100644 --- a/yaml-files/Fun.apply.yaml +++ b/yaml-files/Fun.apply.yaml @@ -5,9 +5,11 @@ parameters: - name: a type: >- 'a => 'b + label: false - name: b type: >- 'a + label: false returnType: >- 'b # For compatibility diff --git a/yaml-files/Fun.compose..yaml b/yaml-files/Fun.compose..yaml index 4465d15b..2a5603e8 100644 --- a/yaml-files/Fun.compose..yaml +++ b/yaml-files/Fun.compose..yaml @@ -5,12 +5,15 @@ 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 diff --git a/yaml-files/Fun.composeRight.yaml b/yaml-files/Fun.composeRight.yaml index 0550ebbb..4fa24502 100644 --- a/yaml-files/Fun.composeRight.yaml +++ b/yaml-files/Fun.composeRight.yaml @@ -5,12 +5,15 @@ 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 diff --git a/yaml-files/Fun.constant.yaml b/yaml-files/Fun.constant.yaml index 7c3a3a30..157623d7 100644 --- a/yaml-files/Fun.constant.yaml +++ b/yaml-files/Fun.constant.yaml @@ -5,9 +5,11 @@ parameters: - name: a type: >- 'a + label: false - name: b type: >- 'b + label: false returnType: >- 'a # For compatibility diff --git a/yaml-files/Fun.curry.yaml b/yaml-files/Fun.curry.yaml index 57e3b31e..0291bffe 100644 --- a/yaml-files/Fun.curry.yaml +++ b/yaml-files/Fun.curry.yaml @@ -4,12 +4,15 @@ docstring: Takes a function [f] which takes a single argument of a tuple [('a, ' 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 diff --git a/yaml-files/Fun.curry3.yaml b/yaml-files/Fun.curry3.yaml index edea54a2..d55c81ec 100644 --- a/yaml-files/Fun.curry3.yaml +++ b/yaml-files/Fun.curry3.yaml @@ -4,15 +4,19 @@ docstring: Takes a function [f] which takes a single argument of a tuple3 [('a, 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 diff --git a/yaml-files/Fun.flip.yaml b/yaml-files/Fun.flip.yaml index 1496e51b..45c222c7 100644 --- a/yaml-files/Fun.flip.yaml +++ b/yaml-files/Fun.flip.yaml @@ -4,12 +4,15 @@ 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 diff --git a/yaml-files/Fun.identity.yaml b/yaml-files/Fun.identity.yaml index 2a6940ff..f622f92f 100644 --- a/yaml-files/Fun.identity.yaml +++ b/yaml-files/Fun.identity.yaml @@ -5,6 +5,7 @@ parameters: - name: a type: >- 'a + label: false returnType: >- 'a # For compatibility diff --git a/yaml-files/Fun.ignore.yaml b/yaml-files/Fun.ignore.yaml index a8fd9374..afba8c2e 100644 --- a/yaml-files/Fun.ignore.yaml +++ b/yaml-files/Fun.ignore.yaml @@ -4,6 +4,7 @@ docstring: Discards the value it is given and returns [()] parameters: - name: a type: _ + label: false returnType: unit # For compatibility constraints: diff --git a/yaml-files/Fun.negate.yaml b/yaml-files/Fun.negate.yaml index 02ff7134..afc335ed 100644 --- a/yaml-files/Fun.negate.yaml +++ b/yaml-files/Fun.negate.yaml @@ -5,9 +5,11 @@ parameters: - name: a type: >- 'a => bool + label: false - name: b type: >- 'a + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Fun.sequence.yaml b/yaml-files/Fun.sequence.yaml index 57d3c0f9..d6efd2d3 100644 --- a/yaml-files/Fun.sequence.yaml +++ b/yaml-files/Fun.sequence.yaml @@ -5,9 +5,11 @@ parameters: - name: a type: >- 'a + label: false - name: b type: >- 'b + label: false returnType: >- 'b # For compatibility diff --git a/yaml-files/Fun.uncurry.yaml b/yaml-files/Fun.uncurry.yaml index dc0a1b4a..6cade79b 100644 --- a/yaml-files/Fun.uncurry.yaml +++ b/yaml-files/Fun.uncurry.yaml @@ -4,8 +4,10 @@ docstring: Takes a function which takes two arguments and returns a function whi parameters: - name: a type: ('a, 'b) => 'c + label: false - name: b type: ('a, 'b) + label: false returnType: >- 'c # For compatibility diff --git a/yaml-files/Fun.uncurry3.yaml b/yaml-files/Fun.uncurry3.yaml index b8420842..1d292b20 100644 --- a/yaml-files/Fun.uncurry3.yaml +++ b/yaml-files/Fun.uncurry3.yaml @@ -4,8 +4,10 @@ docstring: Takes a function which takes three arguments and returns a function w parameters: - name: a type: ('a, 'b, 'c) => 'd + label: false - name: b type: ('a, 'b, 'c) + label: false returnType: >- 'd # For compatibility diff --git a/yaml-files/Int.absolute.yaml b/yaml-files/Int.absolute.yaml index 96a75912..9b3b8d72 100644 --- a/yaml-files/Int.absolute.yaml +++ b/yaml-files/Int.absolute.yaml @@ -4,6 +4,7 @@ docstring: Get the absolute value of parameters: - name: a type: int + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.add.yaml b/yaml-files/Int.add.yaml index 707e9055..8066ff04 100644 --- a/yaml-files/Int.add.yaml +++ b/yaml-files/Int.add.yaml @@ -4,8 +4,10 @@ docstring: Add to , returning their sum parameters: - name: a type: int + label: false - name: b type: int + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.clamp.yaml b/yaml-files/Int.clamp.yaml index dcedb445..73840ed1 100644 --- a/yaml-files/Int.clamp.yaml +++ b/yaml-files/Int.clamp.yaml @@ -4,10 +4,13 @@ docstring: Clamps within the inclusive [lower] and [upper] bounds and parameters: - name: a type: int + label: false - name: lower type: int + label: true - name: upper type: int + label: true returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.divide.yaml b/yaml-files/Int.divide.yaml index b544a72d..771ad335 100644 --- a/yaml-files/Int.divide.yaml +++ b/yaml-files/Int.divide.yaml @@ -4,8 +4,10 @@ docstring: divide by , returning their quotient parameters: - name: a type: int + label: false - name: by type: int + label: true returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.divideFloat.yaml b/yaml-files/Int.divideFloat.yaml index ca01dbb1..6b3e67ad 100644 --- a/yaml-files/Int.divideFloat.yaml +++ b/yaml-files/Int.divideFloat.yaml @@ -4,8 +4,10 @@ docstring: divide by , returning their quotient parameters: - name: a type: int + label: false - name: by type: int + label: true returnType: float # For compatibility constraints: diff --git a/yaml-files/Int.fromString.yaml b/yaml-files/Int.fromString.yaml index a833e8aa..8f451850 100644 --- a/yaml-files/Int.fromString.yaml +++ b/yaml-files/Int.fromString.yaml @@ -4,6 +4,7 @@ docstring: Attempt to parse to an int parameters: - name: a type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/Int.inRange.yaml b/yaml-files/Int.inRange.yaml index 7dbe19e9..c37e5156 100644 --- a/yaml-files/Int.inRange.yaml +++ b/yaml-files/Int.inRange.yaml @@ -4,10 +4,13 @@ docstring: Checks if is between and up to, but not inclu parameters: - name: a type: int + label: false - name: lower type: int + label: true - name: upper type: int + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/Int.isEven.yaml b/yaml-files/Int.isEven.yaml index f5e29fad..37ce01e2 100644 --- a/yaml-files/Int.isEven.yaml +++ b/yaml-files/Int.isEven.yaml @@ -4,6 +4,7 @@ docstring: Calculate mod 2, returning true if the remainder equals to parameters: - name: a type: int + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Int.isOdd.yaml b/yaml-files/Int.isOdd.yaml index 83f7af44..f04d94c7 100644 --- a/yaml-files/Int.isOdd.yaml +++ b/yaml-files/Int.isOdd.yaml @@ -4,6 +4,7 @@ docstring: Calculate mod 2, returning false if the remainder equals to parameters: - name: a type: int + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Int.maximum.yaml b/yaml-files/Int.maximum.yaml index ab13d1bc..b16f1d99 100644 --- a/yaml-files/Int.maximum.yaml +++ b/yaml-files/Int.maximum.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Int.minimum..yaml b/yaml-files/Int.minimum..yaml index 264131d6..bdf24dcc 100644 --- a/yaml-files/Int.minimum..yaml +++ b/yaml-files/Int.minimum..yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Int.modulo.yaml b/yaml-files/Int.modulo.yaml index f00e5347..158d324d 100644 --- a/yaml-files/Int.modulo.yaml +++ b/yaml-files/Int.modulo.yaml @@ -4,8 +4,10 @@ docstring: Perform modular arithmetic parameters: - name: a type: int + label: false - name: by type: int + label: true returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.multiply.yaml b/yaml-files/Int.multiply.yaml index cf3386be..8f0c5b8e 100644 --- a/yaml-files/Int.multiply.yaml +++ b/yaml-files/Int.multiply.yaml @@ -4,8 +4,10 @@ docstring: Multiply by , returning their product parameters: - name: a type: int + label: false - name: b type: int + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.negate.yaml b/yaml-files/Int.negate.yaml index 43109d0d..bbb07808 100644 --- a/yaml-files/Int.negate.yaml +++ b/yaml-files/Int.negate.yaml @@ -4,6 +4,7 @@ docstring: Flips the 'sign' of parameters: - name: a type: int + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.power.yaml b/yaml-files/Int.power.yaml index a30f2484..a273462d 100644 --- a/yaml-files/Int.power.yaml +++ b/yaml-files/Int.power.yaml @@ -4,8 +4,10 @@ docstring: Raise to the power of , returning the po parameters: - name: base type: int + label: true - name: exponent type: int + label: true returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.remainder.yaml b/yaml-files/Int.remainder.yaml index d981a724..18b23768 100644 --- a/yaml-files/Int.remainder.yaml +++ b/yaml-files/Int.remainder.yaml @@ -4,8 +4,10 @@ docstring: divide by , returning their remainder parameters: - name: a type: int + label: false - name: by type: int + label: true returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.subtract.yaml b/yaml-files/Int.subtract.yaml index a7578fe3..d6260ece 100644 --- a/yaml-files/Int.subtract.yaml +++ b/yaml-files/Int.subtract.yaml @@ -4,8 +4,10 @@ docstring: Subtract from , returning their difference parameters: - name: a type: int + label: false - name: b type: int + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/Int.toFloat.yaml b/yaml-files/Int.toFloat.yaml index 902ca1aa..15181f53 100644 --- a/yaml-files/Int.toFloat.yaml +++ b/yaml-files/Int.toFloat.yaml @@ -4,6 +4,7 @@ docstring: Convert into a [float] representation parameters: - name: a type: int + label: false returnType: float # For compatibility constraints: diff --git a/yaml-files/Int.toString.yaml b/yaml-files/Int.toString.yaml index 5de7334d..db76de14 100644 --- a/yaml-files/Int.toString.yaml +++ b/yaml-files/Int.toString.yaml @@ -4,6 +4,7 @@ docstring: Convert into a [string] representation parameters: - name: a type: int + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/List.all.yaml b/yaml-files/List.all.yaml index 8199adf9..6d030ccc 100644 --- a/yaml-files/List.all.yaml +++ b/yaml-files/List.all.yaml @@ -4,9 +4,11 @@ docstring: Determine if [f] returns true for [all] values in a list. Stops itera parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/List.any.yaml b/yaml-files/List.any.yaml index 5265c24a..6894a5e9 100644 --- a/yaml-files/List.any.yaml +++ b/yaml-files/List.any.yaml @@ -4,9 +4,11 @@ docstring: Determine if [f] returns true for [any] values in a list. Stops itera parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: bool # For compatibility constraints: diff --git a/yaml-files/List.append.yaml b/yaml-files/List.append.yaml index 59175df6..6b2f6bc4 100644 --- a/yaml-files/List.append.yaml +++ b/yaml-files/List.append.yaml @@ -4,8 +4,10 @@ docstring: Creates a new list which is the result of appending the second list o parameters: - name: a type: list<'a> + label: false - name: b type: list<'a> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.chunksOf.yaml b/yaml-files/List.chunksOf.yaml index 4054e6be..aaa21b74 100644 --- a/yaml-files/List.chunksOf.yaml +++ b/yaml-files/List.chunksOf.yaml @@ -4,8 +4,10 @@ docstring: Split a list into equally sized chunks. If there aren't enough elemen parameters: - name: a type: list<'a> + label: false - name: size type: int + label: true returnType: list> # For compatibility constraints: diff --git a/yaml-files/List.compare.yaml b/yaml-files/List.compare.yaml index 1c08bdcd..02c22bbd 100644 --- a/yaml-files/List.compare.yaml +++ b/yaml-files/List.compare.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/List.cons.yaml b/yaml-files/List.cons.yaml index fba4ad94..426253e4 100644 --- a/yaml-files/List.cons.yaml +++ b/yaml-files/List.cons.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.count.yaml b/yaml-files/List.count.yaml index 97b18c02..60d60c79 100644 --- a/yaml-files/List.count.yaml +++ b/yaml-files/List.count.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.drop.yaml b/yaml-files/List.drop.yaml index 05e45bba..34563946 100644 --- a/yaml-files/List.drop.yaml +++ b/yaml-files/List.drop.yaml @@ -4,8 +4,10 @@ docstring: Drop the first [count] elements from the front of a list. If the list parameters: - name: a type: list<'a> + label: false - name: count type: int + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.dropWhile.yaml b/yaml-files/List.dropWhile.yaml index 71f86223..3f09921f 100644 --- a/yaml-files/List.dropWhile.yaml +++ b/yaml-files/List.dropWhile.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.equal.yaml b/yaml-files/List.equal.yaml index 492e3881..1e3dacf5 100644 --- a/yaml-files/List.equal.yaml +++ b/yaml-files/List.equal.yaml @@ -4,10 +4,13 @@ docstring: Test two lists for equality using the provided function to test eleme 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: diff --git a/yaml-files/List.extent.yaml b/yaml-files/List.extent.yaml index 2fe61395..b4a3c40c 100644 --- a/yaml-files/List.extent.yaml +++ b/yaml-files/List.extent.yaml @@ -4,8 +4,10 @@ docstring: Find a {!Tuple2} of the [(minimum, maximum)] elements using the provi parameters: - name: a type: list<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<('a, 'a)> # For compatibility constraints: diff --git a/yaml-files/List.filter.yaml b/yaml-files/List.filter.yaml index 1cf2b9bd..709e413f 100644 --- a/yaml-files/List.filter.yaml +++ b/yaml-files/List.filter.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.filterMap.yaml b/yaml-files/List.filterMap.yaml index 24890251..0ca972ee 100644 --- a/yaml-files/List.filterMap.yaml +++ b/yaml-files/List.filterMap.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.filterWithIndex.yaml b/yaml-files/List.filterWithIndex.yaml index 6d162906..451a1cbd 100644 --- a/yaml-files/List.filterWithIndex.yaml +++ b/yaml-files/List.filterWithIndex.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.find.yaml b/yaml-files/List.find.yaml index d39b9ade..61cab401 100644 --- a/yaml-files/List.find.yaml +++ b/yaml-files/List.find.yaml @@ -4,9 +4,11 @@ docstring: Returns, as an [option], the first element for which [f] evaluates to parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.findIndex.yaml b/yaml-files/List.findIndex.yaml index c3a49603..c51a052c 100644 --- a/yaml-files/List.findIndex.yaml +++ b/yaml-files/List.findIndex.yaml @@ -4,8 +4,10 @@ docstring: Returns, as an option, a tuple of the first element and its index for parameters: - name: a type: list<'a> + label: false - name: f type: (int, 'a)=> bool + label: true returnType: option<(int, 'a)> # For compatibility constraints: diff --git a/yaml-files/List.flatMap.yaml b/yaml-files/List.flatMap.yaml index fe4d30bf..9e0565cb 100644 --- a/yaml-files/List.flatMap.yaml +++ b/yaml-files/List.flatMap.yaml @@ -4,9 +4,11 @@ docstring: Apply a function [f] onto a list and {!flatten} the resulting list of parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => list<'b> + label: true returnType: list<'b> # For compatibility constraints: diff --git a/yaml-files/List.flatten.yaml b/yaml-files/List.flatten.yaml index d4b163e3..ffb26536 100644 --- a/yaml-files/List.flatten.yaml +++ b/yaml-files/List.flatten.yaml @@ -2,7 +2,8 @@ module: List name: flatten docstring: Concatenate a list of lists into a single list - name: a - type: list> + type: list> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.fromArray.yaml b/yaml-files/List.fromArray.yaml index 01c22798..589be36b 100644 --- a/yaml-files/List.fromArray.yaml +++ b/yaml-files/List.fromArray.yaml @@ -4,6 +4,7 @@ docstring: Create a list from an {!Array} parameters: - name: a type: array<'a> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.getAt.yaml b/yaml-files/List.getAt.yaml index 6b458f6c..c395fcce 100644 --- a/yaml-files/List.getAt.yaml +++ b/yaml-files/List.getAt.yaml @@ -4,8 +4,10 @@ docstring: Returns the element at position [index] in the list. Returns [None] i parameters: - name: a type: list<'a> + label: false - name: index type: int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.groupWhile.yaml b/yaml-files/List.groupWhile.yaml index a2516867..6f30391d 100644 --- a/yaml-files/List.groupWhile.yaml +++ b/yaml-files/List.groupWhile.yaml @@ -4,8 +4,10 @@ docstring: Divide a list into groups. [f] is called with consecutive elements, w parameters: - name: a type: list<'a> + label: false - name: f type: ('a, 'a) => bool + label: true returnType: list> # For compatibility constraints: diff --git a/yaml-files/List.head.yaml b/yaml-files/List.head.yaml index 8bb67973..b436b08a 100644 --- a/yaml-files/List.head.yaml +++ b/yaml-files/List.head.yaml @@ -4,6 +4,7 @@ docstring: Returns, as an {!Option}, the first element of a list. If the list is parameters: - name: a type: list<'a> + label: false returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.includes.yaml b/yaml-files/List.includes.yaml index 2a6c13b9..84153fa4 100644 --- a/yaml-files/List.includes.yaml +++ b/yaml-files/List.includes.yaml @@ -4,11 +4,14 @@ docstring: Test if a list contains the specified element using the provided [equ 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: diff --git a/yaml-files/List.initial.yaml b/yaml-files/List.initial.yaml index cf43f3b6..1fef1ea9 100644 --- a/yaml-files/List.initial.yaml +++ b/yaml-files/List.initial.yaml @@ -4,6 +4,7 @@ docstring: As an {!Option} get of all of the elements of a list except the last parameters: - name: a type: list<'a> + label: false returnType: option> # For compatibility constraints: diff --git a/yaml-files/List.initialize.yaml b/yaml-files/List.initialize.yaml index a29adece..7c1a1e45 100644 --- a/yaml-files/List.initialize.yaml +++ b/yaml-files/List.initialize.yaml @@ -4,8 +4,10 @@ docstring: Initialize a list parameters: - name: a type: int + label: false - name: f type: int => 'a + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.insertAt.yaml b/yaml-files/List.insertAt.yaml index c4330295..6721903b 100644 --- a/yaml-files/List.insertAt.yaml +++ b/yaml-files/List.insertAt.yaml @@ -4,11 +4,14 @@ docstring: Insert a new element at the specified index. The element previously o 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: diff --git a/yaml-files/List.intersperse.yaml b/yaml-files/List.intersperse.yaml index c2e65873..a74f70f4 100644 --- a/yaml-files/List.intersperse.yaml +++ b/yaml-files/List.intersperse.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.isEmpty.yaml b/yaml-files/List.isEmpty.yaml index 03424f0f..564f12b0 100644 --- a/yaml-files/List.isEmpty.yaml +++ b/yaml-files/List.isEmpty.yaml @@ -4,6 +4,7 @@ docstring: Determine if a list is empty parameters: - name: a type: list<_> + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/List.join.yaml b/yaml-files/List.join.yaml index d7b92e32..c889bacc 100644 --- a/yaml-files/List.join.yaml +++ b/yaml-files/List.join.yaml @@ -4,8 +4,10 @@ docstring: Converts a list of strings into a {!String}, placing [sep] between ea parameters: - name: a type: list + label: false - name: sep type: string + label: true returnType: string # For compatibility constraints: diff --git a/yaml-files/List.last.yaml b/yaml-files/List.last.yaml index a7dbf2c0..eb8a4d63 100644 --- a/yaml-files/List.last.yaml +++ b/yaml-files/List.last.yaml @@ -4,6 +4,7 @@ docstring: As an {!Option} get of all of the elements of a list except the last parameters: - name: a type: list<'a> + label: false returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.length.yaml b/yaml-files/List.length.yaml index 58dc2e19..67e3bf1a 100644 --- a/yaml-files/List.length.yaml +++ b/yaml-files/List.length.yaml @@ -4,6 +4,7 @@ docstring: Return the number of elements in a list parameters: - name: a type: list<'a> + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/List.map.yaml b/yaml-files/List.map.yaml index 316763f8..b260165e 100644 --- a/yaml-files/List.map.yaml +++ b/yaml-files/List.map.yaml @@ -4,9 +4,11 @@ docstring: Create a new list which is the result of applying a function [f] to e parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => 'b + label: true returnType: list<'b> # For compatibility constraints: diff --git a/yaml-files/List.map2.yaml b/yaml-files/List.map2.yaml index 63531e9f..726bd140 100644 --- a/yaml-files/List.map2.yaml +++ b/yaml-files/List.map2.yaml @@ -4,10 +4,13 @@ docstring: Combine two lists, using [f] to combine each pair of elements. If one 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: diff --git a/yaml-files/List.map3.yaml b/yaml-files/List.map3.yaml index f43656c4..8253ea3b 100644 --- a/yaml-files/List.map3.yaml +++ b/yaml-files/List.map3.yaml @@ -4,12 +4,16 @@ docstring: Combine three lists, using [f] to combine each trio of elements. If o 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: diff --git a/yaml-files/List.mapWithIndex.yaml b/yaml-files/List.mapWithIndex.yaml index 8d8e6ff7..9dd59a10 100644 --- a/yaml-files/List.mapWithIndex.yaml +++ b/yaml-files/List.mapWithIndex.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/List.maximum.yaml b/yaml-files/List.maximum.yaml index 91c473e0..9c31d62e 100644 --- a/yaml-files/List.maximum.yaml +++ b/yaml-files/List.maximum.yaml @@ -4,8 +4,10 @@ docstring: Find the largest element using the provided [compare] function. Retur parameters: - name: a type: list<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.maximumBy.yaml b/yaml-files/List.maximumBy.yaml index 7c98d73e..9f2a2100 100644 --- a/yaml-files/List.maximumBy.yaml +++ b/yaml-files/List.maximumBy.yaml @@ -7,9 +7,11 @@ docstring: >- parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => 'comparable + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.minimum.yaml b/yaml-files/List.minimum.yaml index 0070b339..a1921999 100644 --- a/yaml-files/List.minimum.yaml +++ b/yaml-files/List.minimum.yaml @@ -4,8 +4,10 @@ docstring: Find the smallest element using the provided [compare] function. Retu parameters: - name: a type: list<'a> + label: false - name: compare type: ('a, 'a) => int + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.minimumBy.yaml b/yaml-files/List.minimumBy.yaml index 640a7811..2f03adf5 100644 --- a/yaml-files/List.minimumBy.yaml +++ b/yaml-files/List.minimumBy.yaml @@ -7,9 +7,11 @@ docstring: >- parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => 'comparable + label: true returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/List.partition.yaml b/yaml-files/List.partition.yaml index 0a8c97f0..f0da1216 100644 --- a/yaml-files/List.partition.yaml +++ b/yaml-files/List.partition.yaml @@ -4,9 +4,11 @@ docstring: Split a list into a {!Tuple2} of lists. Values which [f] returns true parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: (list<'a>, list<'a>) # For compatibility constraints: diff --git a/yaml-files/List.range.yaml b/yaml-files/List.range.yaml index 60e78f34..ffa4b788 100644 --- a/yaml-files/List.range.yaml +++ b/yaml-files/List.range.yaml @@ -4,8 +4,10 @@ docstring: Creates a list containing all of the integers from [from] if it is pr parameters: - name: from type: int=? + label: true - name: a type: int + label: false returnType: list # For compatibility constraints: diff --git a/yaml-files/List.removeAt.yaml b/yaml-files/List.removeAt.yaml index 3f4b356e..9eec90d6 100644 --- a/yaml-files/List.removeAt.yaml +++ b/yaml-files/List.removeAt.yaml @@ -4,8 +4,10 @@ docstring: Creates a new list without the element at [index]. If [index] is outs parameters: - name: a type: list<'a> + label: false - name: index type: int + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.repeat.yaml b/yaml-files/List.repeat.yaml index 426b0caa..d75bf0bc 100644 --- a/yaml-files/List.repeat.yaml +++ b/yaml-files/List.repeat.yaml @@ -5,8 +5,10 @@ parameters: - name: a type: >- 'a + label: false - name: times type: int + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.reverse.yaml b/yaml-files/List.reverse.yaml index a955127e..789a0cd6 100644 --- a/yaml-files/List.reverse.yaml +++ b/yaml-files/List.reverse.yaml @@ -4,6 +4,7 @@ docstring: Reverse the elements in a list parameters: - name: a type: list<'a> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.singleton.yaml b/yaml-files/List.singleton.yaml index e8cc3cf5..3e64def5 100644 --- a/yaml-files/List.singleton.yaml +++ b/yaml-files/List.singleton.yaml @@ -5,6 +5,7 @@ parameters: - name: a type: >- 'a + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.sliding.yaml b/yaml-files/List.sliding.yaml index ce0034b7..a055ef27 100644 --- a/yaml-files/List.sliding.yaml +++ b/yaml-files/List.sliding.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/List.sort.yaml b/yaml-files/List.sort.yaml index f53e732b..30520555 100644 --- a/yaml-files/List.sort.yaml +++ b/yaml-files/List.sort.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/List.splitAt.yaml b/yaml-files/List.splitAt.yaml index 5ab59854..8616fd97 100644 --- a/yaml-files/List.splitAt.yaml +++ b/yaml-files/List.splitAt.yaml @@ -8,8 +8,10 @@ If [index] is greater than the length of the list, all elements will be in the s parameters: - name: a type: list<'a> + label: false - name: index type: int + label: true returnType: (list<'a>, list<'a>) # For compatibility constraints: diff --git a/yaml-files/List.splitWhen.yaml b/yaml-files/List.splitWhen.yaml index 94b4b4bb..629d4221 100644 --- a/yaml-files/List.splitWhen.yaml +++ b/yaml-files/List.splitWhen.yaml @@ -5,9 +5,11 @@ Elements up to (but not including) the first element [f] returns [true] for will parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => bool + label: true returnType: (list<'a>, list<'a>) # For compatibility constraints: diff --git a/yaml-files/List.take.yaml b/yaml-files/List.take.yaml index 14573032..f92af01d 100644 --- a/yaml-files/List.take.yaml +++ b/yaml-files/List.take.yaml @@ -4,8 +4,10 @@ docstring: Attempt to take the first [count] elements of a list. If the list has parameters: - name: a type: list<'a> + label: false - name: count type: int + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.takeWhile.yaml b/yaml-files/List.takeWhile.yaml index 21b3a05f..3689f28c 100644 --- a/yaml-files/List.takeWhile.yaml +++ b/yaml-files/List.takeWhile.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/List.toArray.yaml b/yaml-files/List.toArray.yaml index db094bcb..a3af5feb 100644 --- a/yaml-files/List.toArray.yaml +++ b/yaml-files/List.toArray.yaml @@ -4,6 +4,7 @@ docstring: Converts a list to an {!Array}. parameters: - name: a type: list<'a> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/List.uniqueBy.yaml b/yaml-files/List.uniqueBy.yaml index 154be75b..47687021 100644 --- a/yaml-files/List.uniqueBy.yaml +++ b/yaml-files/List.uniqueBy.yaml @@ -6,9 +6,11 @@ docstring: >- parameters: - name: a type: list<'a> + label: false - name: f type: >- 'a => string + label: true returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/List.unzip.yaml b/yaml-files/List.unzip.yaml index e3df9297..edbcd1c5 100644 --- a/yaml-files/List.unzip.yaml +++ b/yaml-files/List.unzip.yaml @@ -3,6 +3,7 @@ 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: diff --git a/yaml-files/List.updateAt.yaml b/yaml-files/List.updateAt.yaml index 4d1e1b23..92a173fa 100644 --- a/yaml-files/List.updateAt.yaml +++ b/yaml-files/List.updateAt.yaml @@ -4,11 +4,14 @@ docstring: Returns a new list with the value at [index] updated to be the result 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: diff --git a/yaml-files/List.zip.yaml b/yaml-files/List.zip.yaml index 0b686329..3353f619 100644 --- a/yaml-files/List.zip.yaml +++ b/yaml-files/List.zip.yaml @@ -3,8 +3,10 @@ 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: diff --git a/yaml-files/Option.andThen.yaml b/yaml-files/Option.andThen.yaml index ef40a1cf..cd69c7c2 100644 --- a/yaml-files/Option.andThen.yaml +++ b/yaml-files/Option.andThen.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Option.and_.yaml b/yaml-files/Option.and_.yaml index 285aadac..9f51e118 100644 --- a/yaml-files/Option.and_.yaml +++ b/yaml-files/Option.and_.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Option.both.yaml b/yaml-files/Option.both.yaml index 57d08c0b..379a5acf 100644 --- a/yaml-files/Option.both.yaml +++ b/yaml-files/Option.both.yaml @@ -4,8 +4,10 @@ docstring: Transform and into an option of a {!Tuple2}. Retu parameters: - name: a type: option<'a> + label: false - name: b type: option<'b> + label: false returnType: option<('a, 'b)> # For compatibility constraints: diff --git a/yaml-files/Option.compare.yaml b/yaml-files/Option.compare.yaml index 916924a3..938a1e99 100644 --- a/yaml-files/Option.compare.yaml +++ b/yaml-files/Option.compare.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/Option.equal.yaml b/yaml-files/Option.equal.yaml index 655e5534..8fabb2e6 100644 --- a/yaml-files/Option.equal.yaml +++ b/yaml-files/Option.equal.yaml @@ -4,10 +4,13 @@ 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: diff --git a/yaml-files/Option.flatten.yaml b/yaml-files/Option.flatten.yaml index 6e04ec84..1f1f4dd7 100644 --- a/yaml-files/Option.flatten.yaml +++ b/yaml-files/Option.flatten.yaml @@ -4,6 +4,7 @@ docstring: Flatten two optional layers into a single optional layer parameters: - name: a type: option> + label: false returnType: option<'a> # For compatibility constraints: diff --git a/yaml-files/Option.isNone.yaml b/yaml-files/Option.isNone.yaml index 68eaee81..39d92ebe 100644 --- a/yaml-files/Option.isNone.yaml +++ b/yaml-files/Option.isNone.yaml @@ -4,6 +4,7 @@ docstring: Check if is a [None] parameters: - name: a type: option<'a> + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Option.isSome.yaml b/yaml-files/Option.isSome.yaml index 969a3ae4..285a7988 100644 --- a/yaml-files/Option.isSome.yaml +++ b/yaml-files/Option.isSome.yaml @@ -4,6 +4,7 @@ docstring: Check if is a [Some]. parameters: - name: a type: option<'a> + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/Option.map.yaml b/yaml-files/Option.map.yaml index a72d1d2b..5ddab444 100644 --- a/yaml-files/Option.map.yaml +++ b/yaml-files/Option.map.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Option.map2.yaml b/yaml-files/Option.map2.yaml index 2587a74a..22b979ab 100644 --- a/yaml-files/Option.map2.yaml +++ b/yaml-files/Option.map2.yaml @@ -4,10 +4,13 @@ docstring: Combine and . If both options are [Some] returns, 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: diff --git a/yaml-files/Option.orElse.yaml b/yaml-files/Option.orElse.yaml index b5d87b9b..de6a79f9 100644 --- a/yaml-files/Option.orElse.yaml +++ b/yaml-files/Option.orElse.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Option.or_.yaml b/yaml-files/Option.or_.yaml index 50a12a62..3b95fb62 100644 --- a/yaml-files/Option.or_.yaml +++ b/yaml-files/Option.or_.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/Option.toArray.yaml b/yaml-files/Option.toArray.yaml index d6085dfc..0551d6db 100644 --- a/yaml-files/Option.toArray.yaml +++ b/yaml-files/Option.toArray.yaml @@ -4,6 +4,7 @@ docstring: Convert to an {!Array} parameters: - name: a type: option<'a> + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Option.toList.yaml b/yaml-files/Option.toList.yaml index 89f7ae05..81b32ead 100644 --- a/yaml-files/Option.toList.yaml +++ b/yaml-files/Option.toList.yaml @@ -4,6 +4,7 @@ docstring: Convert to a {!List} parameters: - name: a type: option<'a> + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/Option.unwrap.yaml b/yaml-files/Option.unwrap.yaml index 2e7329f6..cb46469e 100644 --- a/yaml-files/Option.unwrap.yaml +++ b/yaml-files/Option.unwrap.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/String.fromArray.yaml b/yaml-files/String.fromArray.yaml index 3780a983..01c2037c 100644 --- a/yaml-files/String.fromArray.yaml +++ b/yaml-files/String.fromArray.yaml @@ -4,6 +4,7 @@ docstring: Create a string from an {!Array} of characters parameters: - name: a type: array + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/String.fromChar.yaml b/yaml-files/String.fromChar.yaml index b774fa67..0b93413a 100644 --- a/yaml-files/String.fromChar.yaml +++ b/yaml-files/String.fromChar.yaml @@ -4,6 +4,7 @@ docstring: Converts the to an equivalent string of length one parameters: - name: a type: char + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/String.fromList.yaml b/yaml-files/String.fromList.yaml index f8ebbb59..1487891b 100644 --- a/yaml-files/String.fromList.yaml +++ b/yaml-files/String.fromList.yaml @@ -4,6 +4,7 @@ docstring: Create a string from a {!List} of characters parameters: - name: a type: list + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/String.indexOf.yaml b/yaml-files/String.indexOf.yaml index 8c576249..85ccbece 100644 --- a/yaml-files/String.indexOf.yaml +++ b/yaml-files/String.indexOf.yaml @@ -4,8 +4,10 @@ docstring: Returns the index of the first occurrence of [string] or None if stri parameters: - name: a type: string + label: false - name: b type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/String.indexOfRight.yaml b/yaml-files/String.indexOfRight.yaml index 76fbdfed..719a4d60 100644 --- a/yaml-files/String.indexOfRight.yaml +++ b/yaml-files/String.indexOfRight.yaml @@ -4,8 +4,10 @@ docstring: Returns the index of the last occurrence of [string] or None if strin parameters: - name: a type: string + label: false - name: b type: string + label: false returnType: option # For compatibility constraints: diff --git a/yaml-files/String.initialize.yaml b/yaml-files/String.initialize.yaml index dd45e629..aa6a51f0 100644 --- a/yaml-files/String.initialize.yaml +++ b/yaml-files/String.initialize.yaml @@ -4,8 +4,10 @@ docstring: Create a string by providing a length and a function to choose charac parameters: - name: a type: int + label: false - name: f type: int => char + label: true returnType: string # For compatibility constraints: diff --git a/yaml-files/String.insertAt.yaml b/yaml-files/String.insertAt.yaml index 00ca52b0..e3ce2f47 100644 --- a/yaml-files/String.insertAt.yaml +++ b/yaml-files/String.insertAt.yaml @@ -4,10 +4,13 @@ docstring: Insert a string at [index] parameters: - name: a type: string + label: false - name: index type: int + label: true - name: value type: string + label: true returnType: string # For compatibility constraints: diff --git a/yaml-files/String.isEmpty.yaml b/yaml-files/String.isEmpty.yaml index f4689eda..f32eb835 100644 --- a/yaml-files/String.isEmpty.yaml +++ b/yaml-files/String.isEmpty.yaml @@ -4,6 +4,7 @@ docstring: Check if a string is empty parameters: - name: a type: string + label: false returnType: bool # For compatibility constraints: diff --git a/yaml-files/String.length.yaml b/yaml-files/String.length.yaml index 0293020a..332cca61 100644 --- a/yaml-files/String.length.yaml +++ b/yaml-files/String.length.yaml @@ -4,6 +4,7 @@ docstring: Returns the length of the given string parameters: - name: a type: string + label: false returnType: int # For compatibility constraints: diff --git a/yaml-files/String.repeat.yaml b/yaml-files/String.repeat.yaml index cbec8af1..1166a8a4 100644 --- a/yaml-files/String.repeat.yaml +++ b/yaml-files/String.repeat.yaml @@ -4,8 +4,10 @@ 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: diff --git a/yaml-files/String.reverse.yaml b/yaml-files/String.reverse.yaml index d1427440..6264e42a 100644 --- a/yaml-files/String.reverse.yaml +++ b/yaml-files/String.reverse.yaml @@ -4,6 +4,7 @@ docstring: Reverse a string parameters: - name: a type: string + label: false returnType: string # For compatibility constraints: diff --git a/yaml-files/String.split.yaml b/yaml-files/String.split.yaml index 4c20a3f4..beff87ce 100644 --- a/yaml-files/String.split.yaml +++ b/yaml-files/String.split.yaml @@ -4,9 +4,11 @@ docstring: Divide a string into a list of strings, splitting whenever [on] is en parameters: - name: a type: string + label: false - name: >- on type: string + label: true returnType: list # For compatibility constraints: diff --git a/yaml-files/String.toArray.yaml b/yaml-files/String.toArray.yaml index a8e239f0..3a39823e 100644 --- a/yaml-files/String.toArray.yaml +++ b/yaml-files/String.toArray.yaml @@ -4,6 +4,7 @@ docstring: Returns an {!Array} of the individual characters in the given string parameters: - name: a type: string + label: false returnType: array # For compatibility constraints: diff --git a/yaml-files/String.toList.yaml b/yaml-files/String.toList.yaml index 4fd648fd..bb188296 100644 --- a/yaml-files/String.toList.yaml +++ b/yaml-files/String.toList.yaml @@ -4,6 +4,7 @@ docstring: Returns a {!List} of the individual characters in the given string parameters: - name: a type: string + label: false returnType: list # For compatibility constraints: diff --git a/yaml-files/Tuple2.first.yaml b/yaml-files/Tuple2.first.yaml index 5e0484b4..7ca38a1e 100644 --- a/yaml-files/Tuple2.first.yaml +++ b/yaml-files/Tuple2.first.yaml @@ -4,6 +4,7 @@ docstring: Extract the first value from a tuple parameters: - name: a type: ('a, 'b) + label: false returnType: >- 'a # For compatibility diff --git a/yaml-files/Tuple2.make.yaml b/yaml-files/Tuple2.make.yaml index 28ec9626..a88f0095 100644 --- a/yaml-files/Tuple2.make.yaml +++ b/yaml-files/Tuple2.make.yaml @@ -5,9 +5,11 @@ parameters: - name: a type: >- 'a + label: false - name: b type: >- 'b + label: false returnType: ('a, 'b) # For compatibility constraints: diff --git a/yaml-files/Tuple2.mapAll.yaml b/yaml-files/Tuple2.mapAll.yaml index 9c642831..5e6eaca0 100644 --- a/yaml-files/Tuple2.mapAll.yaml +++ b/yaml-files/Tuple2.mapAll.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple2.mapEach.yaml b/yaml-files/Tuple2.mapEach.yaml index 12e997dc..afc381b2 100644 --- a/yaml-files/Tuple2.mapEach.yaml +++ b/yaml-files/Tuple2.mapEach.yaml @@ -4,12 +4,15 @@ docstring: Transform both values of a tuple, using [f] for the first value and [ 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: diff --git a/yaml-files/Tuple2.mapFirst.yaml b/yaml-files/Tuple2.mapFirst.yaml index d259cc99..c2dc13e2 100644 --- a/yaml-files/Tuple2.mapFirst.yaml +++ b/yaml-files/Tuple2.mapFirst.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple2.mapSecond.yaml b/yaml-files/Tuple2.mapSecond.yaml index 03d8663c..ba4a75ca 100644 --- a/yaml-files/Tuple2.mapSecond.yaml +++ b/yaml-files/Tuple2.mapSecond.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple2.second.yaml b/yaml-files/Tuple2.second.yaml index ce6b7ef4..c73a5c1e 100644 --- a/yaml-files/Tuple2.second.yaml +++ b/yaml-files/Tuple2.second.yaml @@ -4,6 +4,7 @@ docstring: Extract the second value from a tuple parameters: - name: a type: ('a, 'b) + label: false returnType: >- 'b # For compatibility diff --git a/yaml-files/Tuple2.swap.yaml b/yaml-files/Tuple2.swap.yaml index d2fbc0fe..47194efa 100644 --- a/yaml-files/Tuple2.swap.yaml +++ b/yaml-files/Tuple2.swap.yaml @@ -4,6 +4,7 @@ docstring: Switches the first and second values of a tuple parameters: - name: a type: ('a, 'b) + label: false returnType: ('b, 'a) # For compatibility constraints: diff --git a/yaml-files/Tuple2.toArray.yaml b/yaml-files/Tuple2.toArray.yaml index f21bd93f..58278962 100644 --- a/yaml-files/Tuple2.toArray.yaml +++ b/yaml-files/Tuple2.toArray.yaml @@ -4,6 +4,7 @@ docstring: Turns a tuple into an {!Array} of length two parameters: - name: a type: ('a, 'a) + label: false returnType: array<'a> # For compatibility constraints: diff --git a/yaml-files/Tuple2.toList.yaml b/yaml-files/Tuple2.toList.yaml index 2cb0a8b1..fa9ad4c0 100644 --- a/yaml-files/Tuple2.toList.yaml +++ b/yaml-files/Tuple2.toList.yaml @@ -4,6 +4,7 @@ docstring: Turns a tuple into a list of length two parameters: - name: a type: ('a, 'a) + label: false returnType: list<'a> # For compatibility constraints: diff --git a/yaml-files/Tuple3.first.yaml b/yaml-files/Tuple3.first.yaml index f3268e79..6e9e5712 100644 --- a/yaml-files/Tuple3.first.yaml +++ b/yaml-files/Tuple3.first.yaml @@ -4,6 +4,7 @@ docstring: Extract the first value from a tuple parameters: - name: a type: ('a, 'b, 'c) + label: false returnType: >- 'a # For compatibility diff --git a/yaml-files/Tuple3.initial.yaml b/yaml-files/Tuple3.initial.yaml index b8eb5cb9..7a723a25 100644 --- a/yaml-files/Tuple3.initial.yaml +++ b/yaml-files/Tuple3.initial.yaml @@ -4,6 +4,7 @@ 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: diff --git a/yaml-files/Tuple3.make.yaml b/yaml-files/Tuple3.make.yaml index b283643b..c59915ed 100644 --- a/yaml-files/Tuple3.make.yaml +++ b/yaml-files/Tuple3.make.yaml @@ -5,12 +5,15 @@ 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: diff --git a/yaml-files/Tuple3.mapAll.yaml b/yaml-files/Tuple3.mapAll.yaml index 595724cd..8d0aeea3 100644 --- a/yaml-files/Tuple3.mapAll.yaml +++ b/yaml-files/Tuple3.mapAll.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple3.mapEach.yaml b/yaml-files/Tuple3.mapEach.yaml index a6cf7bee..b6ba1047 100644 --- a/yaml-files/Tuple3.mapEach.yaml +++ b/yaml-files/Tuple3.mapEach.yaml @@ -4,15 +4,19 @@ docstring: Transform each value in a tuple by applying [f] to the {!first} 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: diff --git a/yaml-files/Tuple3.mapFirst.yaml b/yaml-files/Tuple3.mapFirst.yaml index d5f45658..05ae08eb 100644 --- a/yaml-files/Tuple3.mapFirst.yaml +++ b/yaml-files/Tuple3.mapFirst.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple3.mapSecond.yaml b/yaml-files/Tuple3.mapSecond.yaml index 60b165c7..61177dcb 100644 --- a/yaml-files/Tuple3.mapSecond.yaml +++ b/yaml-files/Tuple3.mapSecond.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple3.mapThird.yaml b/yaml-files/Tuple3.mapThird.yaml index e9995ff7..5a2634e4 100644 --- a/yaml-files/Tuple3.mapThird.yaml +++ b/yaml-files/Tuple3.mapThird.yaml @@ -4,9 +4,11 @@ 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: diff --git a/yaml-files/Tuple3.rotateLeft.yaml b/yaml-files/Tuple3.rotateLeft.yaml index 2887a0ff..629846b2 100644 --- a/yaml-files/Tuple3.rotateLeft.yaml +++ b/yaml-files/Tuple3.rotateLeft.yaml @@ -4,6 +4,7 @@ docstring: Move each value in the tuple one position to the left, moving the val parameters: - name: a type: ('a, 'b, 'c) + label: false returnType: ('b, 'c, 'a) # For compatibility constraints: diff --git a/yaml-files/Tuple3.rotateRight.yaml b/yaml-files/Tuple3.rotateRight.yaml index 2c268dab..45007706 100644 --- a/yaml-files/Tuple3.rotateRight.yaml +++ b/yaml-files/Tuple3.rotateRight.yaml @@ -4,6 +4,7 @@ docstring: Move each value in the tuple one position to the right, moving the va parameters: - name: a type: ('a, 'b, 'c) + label: false returnType: ('c, 'a, 'b) # For compatibility constraints: diff --git a/yaml-files/Tuple3.second.yaml b/yaml-files/Tuple3.second.yaml index 2c4e5dce..8cd26aae 100644 --- a/yaml-files/Tuple3.second.yaml +++ b/yaml-files/Tuple3.second.yaml @@ -4,6 +4,7 @@ docstring: Extract the second value from a tuple parameters: - name: a type: ('a, 'b, 'c) + label: false returnType: >- 'b # For compatibility diff --git a/yaml-files/Tuple3.tail.yaml b/yaml-files/Tuple3.tail.yaml index fd7ff3d1..7157676d 100644 --- a/yaml-files/Tuple3.tail.yaml +++ b/yaml-files/Tuple3.tail.yaml @@ -4,6 +4,7 @@ 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: diff --git a/yaml-files/Tuple3.third.yaml b/yaml-files/Tuple3.third.yaml index d2f2116a..7ff92b3c 100644 --- a/yaml-files/Tuple3.third.yaml +++ b/yaml-files/Tuple3.third.yaml @@ -4,6 +4,7 @@ docstring: Extract the third value from a tuple parameters: - name: a type: ('a, 'b, 'c) + label: false returnType: >- 'c # For compatibility diff --git a/yaml-files/Tuple3.toArray.yaml b/yaml-files/Tuple3.toArray.yaml index c02939a7..ae585ff3 100644 --- a/yaml-files/Tuple3.toArray.yaml +++ b/yaml-files/Tuple3.toArray.yaml @@ -4,6 +4,7 @@ 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: diff --git a/yaml-files/Tuple3.toList.yaml b/yaml-files/Tuple3.toList.yaml index 7ee904fb..31a2999c 100644 --- a/yaml-files/Tuple3.toList.yaml +++ b/yaml-files/Tuple3.toList.yaml @@ -4,6 +4,7 @@ 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: From 32fbbf2c05af827862f5c3ed60cf184f6ce9b376 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2022 13:39:36 +0100 Subject: [PATCH 31/31] Add labels + Fix some yaml files --- src/generateTest.res | 442 +++++++++++++++++-------------- test/fsharpTests/CharTest.fs | 4 - test/fsharpTests/FloatTest.fs | 368 ++++++++++++------------- test/fsharpTests/IntTest.fs | 160 +++++------ test/ocamlTests/CharTest.ml | 1 - test/ocamlTests/FloatTest.ml | 184 ++++++------- test/ocamlTests/IntTest.ml | 80 +++--- test/rescriptTests/CharTest.res | 2 - test/rescriptTests/FloatTest.res | 184 ++++++------- test/rescriptTests/IntTest.res | 80 +++--- yaml-files/Float.atan2.yaml | 76 +++--- yaml-files/String.insertAt.yaml | 90 +++---- 12 files changed, 859 insertions(+), 812 deletions(-) diff --git a/src/generateTest.res b/src/generateTest.res index a882d555..250fcc47 100644 --- a/src/generateTest.res +++ b/src/generateTest.res @@ -1,194 +1,248 @@ -@module("fs") -external readFileSync: (~name: string, [#utf8]) => string = "readFileSync" - -type tests = { - inputs: array, - output: int, -} - -type parameter = { - name: string, - \"type": string, -} - -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 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 - newInput := Js_array.joinWith(",", test.inputs) - newInputOF := Js_array.joinWith(" ", test.inputs) - newInputR := Js_array.joinWith(",", test.inputs) - } - - 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, -) +@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/CharTest.fs b/test/fsharpTests/CharTest.fs index 2c3d234b..610913fb 100644 --- a/test/fsharpTests/CharTest.fs +++ b/test/fsharpTests/CharTest.fs @@ -121,10 +121,6 @@ testCase "isPrintable('~')" <| fun _ -> let expected = true Expect.equal expected (Char.isPrintable '~') "error" -testCase "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" -<| fun _ -> - let expected = Some(false) - Expect.equal expected (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) "error" testCase "isUppercase('A')" <| fun _ -> let expected = true diff --git a/test/fsharpTests/FloatTest.fs b/test/fsharpTests/FloatTest.fs index bcae1997..534408dc 100644 --- a/test/fsharpTests/FloatTest.fs +++ b/test/fsharpTests/FloatTest.fs @@ -21,41 +21,41 @@ testCase "add(3.14,3.14)" <| fun _ -> let expected = 6.28 Expect.equal expected (Float.add 3.14 3.14) "error" -testCase "clamp(5.,0.,8.)" +testCase "clamp(5.,~lower=0.,~upper=8.)" <| fun _ -> let expected = 5. - Expect.equal expected (Float.clamp 5. 0. 8.) "error" -testCase "clamp(9.,0.,8.)" + 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. 0. 8.) "error" -testCase "clamp(1.,2.,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. 2. 8.) "error" -testCase "clamp(5.,-10.,-5.)" + 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. -10. -5.) "error" -testCase "clamp(-15.,-10.,-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. -10. -5.) "error" -testCase "clamp(-6.6,-7.9,nan)" + 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 -7.9 nan) "error" -testCase "clamp(-6.6,nan,0.)" + 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 nan 0.) "error" -testCase "clamp(nan,2.,8.)" + 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 2. 8.) "error" -testCase "clamp(3.,7., 1.)" + Expect.equal expected (Float.clamp nan ~lower:2. ~upper:8.) "error" +testCase "clamp(3.,~lower=7.,~upper= 1.)" <| fun _ -> - Expect.equal (Float.clamp 3. 7. 1.) |> failwith "error" + Expect.equal (Float.clamp 3. ~lower:7. ~upper: 1.) |> failwith "error" testCase "atan(0.)" <| fun _ -> let expected = 0. @@ -76,26 +76,26 @@ testCase "atan(-1. /. 1.)" <| fun _ -> let expected = -0.7853981633974483 Expect.equal expected (Float.atan -1. /. 1.) "error" -testCase "atan2(0.,0.)" +testCase "atan2(~y=0.,~x=0.)" <| fun _ -> let expected = 0. - Expect.equal expected (Float.atan2 0. 0.) "error" -testCase "atan2(1.,1.)" + 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 1. 1.) "error" -testCase "atan2(1.,-1.)" + 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 1. -1.) "error" -testCase "atan2(-1.,-1.)" + 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 -1. -1.) "error" -testCase "atan2(-1.,1.)" + 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 -1. 1.) "error" + Expect.equal expected (Float.atan2 ~y:-1. ~x:1.) "error" testCase "ceiling(1.2)" <| fun _ -> let expected = 2. @@ -132,18 +132,18 @@ testCase "degrees(180.)" <| fun _ -> let expected = pi Expect.equal expected (Float.degrees 180.) "error" -testCase "divide(3.14,2.)" +testCase "divide(3.14,~by=2.)" <| fun _ -> let expected = 1.57 - Expect.equal expected (Float.divide 3.14 2.) "error" -testCase "divide(3.14,0.)" + 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 0.) "error" -testCase "divide(3.14,-0.)" + 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 -0.) "error" + Expect.equal expected (Float.divide 3.14 ~by:-0.) "error" testCase "floor(1.2)" <| fun _ -> let expected = 1. @@ -212,41 +212,41 @@ testCase "hypotenuse(3.,4.)" <| fun _ -> let expected = 5. Expect.equal expected (Float.hypotenuse 3. 4.) "error" -testCase "inRange(3.,2.,4.)" +testCase "inRange(3.,~lower=2.,~upper=4.)" <| fun _ -> let expected = true - Expect.equal expected (Float.inRange 3. 2. 4.) "error" -testCase "inRange(8.,2.,4.)" + 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. 2. 4.) "error" -testCase "inRange(1., 2.,4.)" + 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. 2. 4.) "error" -testCase "inRange(2.,1.,2.)" + 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. 1. 2.) "error" -testCase "inRange(-6.6,-7.9,-5.2)" + 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 -7.9 -5.2) "error" -testCase "inRange(-6.6,-7.9,nan)" + 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 -7.9 nan) "error" -testCase "inRange(-6.6,nan,0.)" + 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 nan 0.) "error" -testCase "inRange(nan,2.,8.)" + 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 2. 8.) "error" -testCase "inRange(3.,7.,1.)" + Expect.equal expected (Float.inRange nan ~lower:2. ~upper:8.) "error" +testCase "inRange(3.,~lower=7.,~upper=1.)" <| fun _ -> - Expect.equal (Float.inRange 3. 7. 1.) |> failwith "error" + Expect.equal (Float.inRange 3. ~lower:7. ~upper:1.) |> failwith "error" testCase "isFinite(infinity)" <| fun _ -> let expected = false @@ -319,18 +319,18 @@ testCase "isNaN(91.4)" <| fun _ -> let expected = false Expect.equal expected (Float.isNaN 91.4) "error" -testCase "log(100.,10.)" +testCase "log(100.,~base=10.)" <| fun _ -> let expected = 2. - Expect.equal expected (Float.log 100. 10.) "error" -testCase "log(256.,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. 2.) "error" -testCase "log(0.,10.)" + Expect.equal expected (Float.log 256. ~base:2.) "error" +testCase "log(0.,~base=10.)" <| fun _ -> let expected = negativeInfinity - Expect.equal expected (Float.log 0. 10.) "error" + Expect.equal expected (Float.log 0. ~base:10.) "error" testCase "maximum(7.,9.)" <| fun _ -> let expected = 9. @@ -387,258 +387,258 @@ testCase "negate(0.)" <| fun _ -> let expected = -0. Expect.equal expected (Float.negate 0.) "error" -testCase "power(7.,3.)" +testCase "power(~base=7.,~exponent=3.)" <| fun _ -> let expected = 343. - Expect.equal expected (Float.power 7. 3.) "error" -testCase "power(0.,3.)" + 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 0. 3.) "error" -testCase "power(7.,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 7. 0.) "error" -testCase "round(#Zero,1.2)" + 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 #Zero 1.2) "error" -testCase "round(#Zero,1.5)" + 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 #Zero 1.5) "error" -testCase "round(#Zero,1.8)" + 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 #Zero 1.8) "error" -testCase "round(#Zero,-1.2)" + 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 #Zero -1.2) "error" -testCase "round(#Zero,-1.5)" + 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 #Zero -1.5) "error" -testCase "round(#Zero,-1.8)" + 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 #Zero -1.8) "error" -testCase "round(#AwayFromZero,1.2)" + 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 #AwayFromZero 1.2) "error" -testCase "round(#AwayFromZero,1.5)" + 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 #AwayFromZero 1.5) "error" -testCase "round(#AwayFromZero,1.8)" + 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 #AwayFromZero 1.8) "error" -testCase "round(#AwayFromZero,-1.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 #AwayFromZero -1.2) "error" -testCase "round(#AwayFromZero,-1.5)" + 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 #AwayFromZero -1.5) "error" -testCase "round(#AwayFromZero,-1.8)" + 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 #AwayFromZero -1.8) "error" -testCase "round(#Up,1.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 #Up 1.2) "error" -testCase "round(#Up,1.5)" + 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 #Up 1.5) "error" -testCase "round(#Up,1.8)" + 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 #Up 1.8) "error" -testCase "round(#Up,-1.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 #Up -1.2) "error" -testCase "round(#Up,-1.5)" + 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 #Up -1.5) "error" -testCase "round(#Up,-1.8)" + 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 #Up -1.8) "error" -testCase "round(#Down,1.2)" + 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 #Down 1.2) "error" -testCase "round(#Down,1.5)" + 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 #Down 1.5) "error" -testCase "round(#Down,1.8)" + 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 #Down 1.8) "error" -testCase "round(#Down,-1.2)" + 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 #Down -1.2) "error" -testCase "round(#Down,-1.5)" + 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 #Down -1.5) "error" -testCase "round(#Down,-1.8)" + 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 #Down -1.8) "error" -testCase "round(#Closest(#Zero),1.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 #Closest(#Zero) 1.2) "error" -testCase "round(#Closest(#Zero),1.5)" + 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 #Closest(#Zero) 1.5) "error" -testCase "round(#Closest(#Zero),1.8)" + 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 #Closest(#Zero) 1.8) "error" -testCase "round(#Closest(#Zero),-1.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 #Closest(#Zero) -1.2) "error" -testCase "round(#Closest(#Zero),-1.5)" + 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 #Closest(#Zero) -1.5) "error" -testCase "round(#Closest(#Zero),-1.8)" + 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 #Closest(#Zero) -1.8) "error" -testCase "round(#Closest(#AwayFromZero),1.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 #Closest(#AwayFromZero) 1.2) "error" -testCase "round(#Closest(#AwayFromZero),1.5)" + 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 #Closest(#AwayFromZero) 1.5) "error" -testCase "round(#Closest(#AwayFromZero),1.8)" + 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 #Closest(#AwayFromZero) 1.8) "error" -testCase "round(#Closest(#AwayFromZero),-1.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 #Closest(#AwayFromZero) -1.2) "error" -testCase "round(#Closest(#AwayFromZero),-1.5)" + 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 #Closest(#AwayFromZero) -1.5) "error" -testCase "round(#Closest(#AwayFromZero),-1.8)" + 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 #Closest(#AwayFromZero) -1.8) "error" -testCase "round(#Closest(#Up),1.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 #Closest(#Up) 1.2) "error" -testCase "round(#Closest(#Up),1.5)" + 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 #Closest(#Up) 1.5) "error" -testCase "round(#Closest(#Up),1.8)" + 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 #Closest(#Up) 1.8) "error" -testCase "round(#Closest(#Up),-1.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 #Closest(#Up) -1.2) "error" -testCase "round(#Closest(#Up),-1.5)" + 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 #Closest(#Up) -1.5) "error" -testCase "round(#Closest(#Up),-1.8)" + 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 #Closest(#Up) -1.8) "error" -testCase "round(#Closest(#Down),1.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 #Closest(#Down) 1.2) "error" -testCase "round(#Closest(#Down),1.5)" + 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 #Closest(#Down) 1.5) "error" -testCase "round(#Closest(#Down),1.8)" + 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 #Closest(#Down) 1.8) "error" -testCase "round(#Closest(#Down),-1.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 #Closest(#Down) -1.2) "error" -testCase "round(#Closest(#Down),-1.5)" + 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 #Closest(#Down) -1.5) "error" -testCase "round(#Closest(#Down),-1.8)" + 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 #Closest(#Down) -1.8) "error" -testCase "round(#Closest(#ToEven),1.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 #Closest(#ToEven) 1.2) "error" -testCase "round(#Closest(#ToEven),1.5)" + 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 #Closest(#ToEven) 1.5) "error" -testCase "round(#Closest(#ToEven),1.8)" + 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 #Closest(#ToEven) 1.8) "error" -testCase "round(#Closest(#ToEven),2.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 #Closest(#ToEven) 2.2) "error" -testCase "round(#Closest(#ToEven),2.5)" + 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 #Closest(#ToEven) 2.5) "error" -testCase "round(#Closest(#ToEven),2.8)" + 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 #Closest(#ToEven) 2.8) "error" -testCase "round(#Closest(#ToEven),-1.2)" + 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 #Closest(#ToEven) -1.2) "error" -testCase "round(#Closest(#ToEven),-1.5)" + 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 #Closest(#ToEven) -1.5) "error" -testCase "round(#Closest(#ToEven),-1.8)" + 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 #Closest(#ToEven) -1.8) "error" -testCase "round(#Closest(#ToEven),-2.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 #Closest(#ToEven) -2.2) "error" -testCase "round(#Closest(#ToEven),-2.5)" + 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 #Closest(#ToEven) -2.5) "error" -testCase "round(#Closest(#ToEven),-2.8)" + 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 #Closest(#ToEven) -2.8) "error" + Expect.equal expected (Float.round ~direction:#Closest(#ToEven) -2.8) "error" testCase "radians(pi)" <| fun _ -> let expected = pi diff --git a/test/fsharpTests/IntTest.fs b/test/fsharpTests/IntTest.fs index f749c6f2..d7614bd5 100644 --- a/test/fsharpTests/IntTest.fs +++ b/test/fsharpTests/IntTest.fs @@ -25,60 +25,60 @@ testCase "add(1,1)" <| fun _ -> let expected = 2 Expect.equal expected (Int.add 1 1) "error" -testCase "clamp(5,0,8)" +testCase "clamp(5,~lower=0,~upper=8)" <| fun _ -> let expected = 5 - Expect.equal expected (Int.clamp 5 0 8) "error" -testCase "clamp(9,0,8)" + 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 0 8) "error" -testCase "clamp(1,2,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 2 8) "error" -testCase "clamp(5,-10,-5)" + 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 -10 -5) "error" -testCase "clamp(-15,-10,-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 -10 -5) "error" -testCase "clamp(3,7,1)" + Expect.equal expected (Int.clamp -15 ~lower:-10 ~upper:-5) "error" +testCase "clamp(3,~lower=7,~upper=1)" <| fun _ -> - Expect.equal (Int.clamp 3 7 1) |> failwith "error" -testCase "divide(3,2)" + 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 2) "error" -testCase "divide(3,0)" + Expect.equal expected (Int.divide 3 ~by:2) "error" +testCase "divide(3,~by=0)" <| fun _ -> - Expect.equal (Int.divide 3 0) |> failwith "error" -testCase "divide(27,5)" + Expect.equal (Int.divide 3 ~by:0) |> failwith "error" +testCase "divide(27,~by=5)" <| fun _ -> let expected = 5 - Expect.equal expected (Int.divide 27 5) "error" -testCase "divideFloat(3,2)" + 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 2) "error" -testCase "divideFloat(27,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 5) "error" -testCase "divideFloat(8,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 4) "error" -testCase "divideFloat(8,0)" + 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 0) "error" -testCase "divideFloat(-8,0)" + 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 0) "error" + Expect.equal expected (Int.divideFloat -8 ~by:0) "error" testCase "fromString("0")" <| fun _ -> let expected = Some(0) @@ -131,29 +131,29 @@ testCase "fromString(" ")" <| fun _ -> let expected = None Expect.equal expected (Int.fromString " ") "error" -testCase "inRange(3,2,4)" +testCase "inRange(3,~lower=2,~upper=4)" <| fun _ -> let expected = true - Expect.equal expected (Int.inRange 3 2 4) "error" -testCase "inRange(8,2,4)" + 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 2 4) "error" -testCase "inRange(1,2,4)" + 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 2 4) "error" -testCase "inRange(2,1,2)" + 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 1 2) "error" -testCase "inRange(-6,-7,-5)" + 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 -7 -5) "error" -testCase "inRange(3,7,1)" + Expect.equal expected (Int.inRange -6 ~lower:-7 ~upper:-5) "error" +testCase "inRange(3,~lower=7,~upper=1)" <| fun _ -> - Expect.equal (Int.inRange 3 7 1) |> failwith "error" + Expect.equal (Int.inRange 3 ~lower:7 ~upper:1) |> failwith "error" testCase "isEven(8)" <| fun _ -> let expected = true @@ -202,42 +202,42 @@ testCase "minimum(-4,-1)" <| fun _ -> let expected = -4 Expect.equal expected (Int.minimum -4 -1) "error" -testCase "modulo(-4,3)" +testCase "modulo(-4,~by=3)" <| fun _ -> let expected = 2 - Expect.equal expected (Int.modulo -4 3) "error" -testCase "modulo(-3,3)" + Expect.equal expected (Int.modulo -4 ~by:3) "error" +testCase "modulo(-3,~by=3)" <| fun _ -> let expected = 0 - Expect.equal expected (Int.modulo -3 3) "error" -testCase "modulo(-2,3)" + Expect.equal expected (Int.modulo -3 ~by:3) "error" +testCase "modulo(-2,~by=3)" <| fun _ -> let expected = 1 - Expect.equal expected (Int.modulo -2 3) "error" -testCase "modulo(-1,3)" + Expect.equal expected (Int.modulo -2 ~by:3) "error" +testCase "modulo(-1,~by=3)" <| fun _ -> let expected = 2 - Expect.equal expected (Int.modulo -1 3) "error" -testCase "modulo(0,3)" + Expect.equal expected (Int.modulo -1 ~by:3) "error" +testCase "modulo(0,~by=3)" <| fun _ -> let expected = 0 - Expect.equal expected (Int.modulo 0 3) "error" -testCase "modulo(1,3)" + Expect.equal expected (Int.modulo 0 ~by:3) "error" +testCase "modulo(1,~by=3)" <| fun _ -> let expected = 1 - Expect.equal expected (Int.modulo 1 3) "error" -testCase "modulo(2,3)" + Expect.equal expected (Int.modulo 1 ~by:3) "error" +testCase "modulo(2,~by=3)" <| fun _ -> let expected = 2 - Expect.equal expected (Int.modulo 2 3) "error" -testCase "modulo(3,3)" + Expect.equal expected (Int.modulo 2 ~by:3) "error" +testCase "modulo(3,~by=3)" <| fun _ -> let expected = 0 - Expect.equal expected (Int.modulo 3 3) "error" -testCase "modulo(4,3)" + Expect.equal expected (Int.modulo 3 ~by:3) "error" +testCase "modulo(4,~by=3)" <| fun _ -> let expected = 1 - Expect.equal expected (Int.modulo 4 3) "error" + Expect.equal expected (Int.modulo 4 ~by:3) "error" testCase "multiply(2,7)" <| fun _ -> let expected = 14 @@ -254,50 +254,50 @@ testCase "negate(0)" <| fun _ -> let expected = 0 Expect.equal expected (Int.negate 0) "error" -testCase "power(7,3)" +testCase "power(~base=7,~exponent=3)" <| fun _ -> let expected = 343 - Expect.equal expected (Int.power 7 3) "error" -testCase "power(0,3)" + 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 0 3) "error" -testCase "power(7,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 7 0) "error" -testCase "remainder(-4,3)" + 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 3) "error" -testCase "remainder(-2,3)" + Expect.equal expected (Int.remainder -4 ~by:3) "error" +testCase "remainder(-2,~by=3)" <| fun _ -> let expected = -2 - Expect.equal expected (Int.remainder -2 3) "error" -testCase "remainder(-1,3)" + Expect.equal expected (Int.remainder -2 ~by:3) "error" +testCase "remainder(-1,~by=3)" <| fun _ -> let expected = -1 - Expect.equal expected (Int.remainder -1 3) "error" -testCase "remainder(0,3)" + Expect.equal expected (Int.remainder -1 ~by:3) "error" +testCase "remainder(0,~by=3)" <| fun _ -> let expected = 0 - Expect.equal expected (Int.remainder 0 3) "error" -testCase "remainder(1,3)" + Expect.equal expected (Int.remainder 0 ~by:3) "error" +testCase "remainder(1,~by=3)" <| fun _ -> let expected = 1 - Expect.equal expected (Int.remainder 1 3) "error" -testCase "remainder(2,3)" + Expect.equal expected (Int.remainder 1 ~by:3) "error" +testCase "remainder(2,~by=3)" <| fun _ -> let expected = 2 - Expect.equal expected (Int.remainder 2 3) "error" -testCase "remainder(3,3)" + Expect.equal expected (Int.remainder 2 ~by:3) "error" +testCase "remainder(3,~by=3)" <| fun _ -> let expected = 0 - Expect.equal expected (Int.remainder 3 3) "error" -testCase "remainder(4,3)" + Expect.equal expected (Int.remainder 3 ~by:3) "error" +testCase "remainder(4,~by=3)" <| fun _ -> let expected = 1 - Expect.equal expected (Int.remainder 4 3) "error" + Expect.equal expected (Int.remainder 4 ~by:3) "error" testCase "subtract(4,3)" <| fun _ -> let expected = 1 diff --git a/test/ocamlTests/CharTest.ml b/test/ocamlTests/CharTest.ml index 4b5918e9..5adcca2f 100644 --- a/test/ocamlTests/CharTest.ml +++ b/test/ocamlTests/CharTest.ml @@ -33,7 +33,6 @@ test "isLowercase('a')" (fun () -> expect (Char.isLowercase 'a') |> toEqual Eq.b 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 "isPrintable(fromCode(31) |> Option.map(~f=isPrintable))" (fun () -> expect (Char.isPrintable fromCode(31) |> Option.map(~f=isPrintable)) |> toEqual (let open Eq in bool ) Some(false)) ; 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) ; diff --git a/test/ocamlTests/FloatTest.ml b/test/ocamlTests/FloatTest.ml index f6c81173..e3ce7307 100644 --- a/test/ocamlTests/FloatTest.ml +++ b/test/ocamlTests/FloatTest.ml @@ -8,25 +8,25 @@ 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.,0.,8.)" (fun () -> expect (Float.clamp 5. 0. 8.) |> toEqual Eq.float 5.) ; -test "clamp(9.,0.,8.)" (fun () -> expect (Float.clamp 9. 0. 8.) |> toEqual Eq.float 8.) ; -test "clamp(1.,2.,8.)" (fun () -> expect (Float.clamp 1. 2. 8.) |> toEqual Eq.float 2.) ; -test "clamp(5.,-10.,-5.)" (fun () -> expect (Float.clamp 5. -10. -5.) |> toEqual Eq.float -5.) ; -test "clamp(-15.,-10.,-5.)" (fun () -> expect (Float.clamp -15. -10. -5.) |> toEqual Eq.float -10.) ; -test "clamp(-6.6,-7.9,nan)" (fun () -> expect (Float.clamp -6.6 -7.9 nan) |> toEqual Eq.float NaN) ; -test "clamp(-6.6,nan,0.)" (fun () -> expect (Float.clamp -6.6 nan 0.) |> toEqual Eq.float NaN) ; -test "clamp(nan,2.,8.)" (fun () -> expect (Float.clamp nan 2. 8.) |> toEqual Eq.float NaN) ; -test "clamp(3.,7., 1.)" (fun () -> expect (fun () -> clamp 3. 7. 1.) |> toThrow); +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(0.,0.)" (fun () -> expect (Float.atan2 0. 0.) |> toEqual Eq.radians 0.) ; -test "atan2(1.,1.)" (fun () -> expect (Float.atan2 1. 1.) |> toEqual Eq.radians 0.7853981633974483) ; -test "atan2(1.,-1.)" (fun () -> expect (Float.atan2 1. -1.) |> toEqual Eq.radians 2.356194490192345) ; -test "atan2(-1.,-1.)" (fun () -> expect (Float.atan2 -1. -1.) |> toEqual Eq.radians -2.356194490192345) ; -test "atan2(-1.,1.)" (fun () -> expect (Float.atan2 -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.) ; @@ -36,9 +36,9 @@ test "ceiling(-1.8)" (fun () -> expect (Float.ceiling -1.8) |> toEqual Eq.float 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,2.)" (fun () -> expect (Float.divide 3.14 2.) |> toEqual Eq.float 1.57) ; -test "divide(3.14,0.)" (fun () -> expect (Float.divide 3.14 0.) |> toEqual Eq.float infinity) ; -test "divide(3.14,-0.)" (fun () -> expect (Float.divide 3.14 -0.) |> toEqual Eq.float negativeInfinity) ; +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.) ; @@ -56,15 +56,15 @@ test "fromString("55")" (fun () -> expect (Float.fromString "55") |> toEqual (le 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.,2.,4.)" (fun () -> expect (Float.inRange 3. 2. 4.) |> toEqual Eq.bool true) ; -test "inRange(8.,2.,4.)" (fun () -> expect (Float.inRange 8. 2. 4.) |> toEqual Eq.bool false) ; -test "inRange(1., 2.,4.)" (fun () -> expect (Float.inRange 1. 2. 4.) |> toEqual Eq.bool false) ; -test "inRange(2.,1.,2.)" (fun () -> expect (Float.inRange 2. 1. 2.) |> toEqual Eq.bool false) ; -test "inRange(-6.6,-7.9,-5.2)" (fun () -> expect (Float.inRange -6.6 -7.9 -5.2) |> toEqual Eq.bool true) ; -test "inRange(-6.6,-7.9,nan)" (fun () -> expect (Float.inRange -6.6 -7.9 nan) |> toEqual Eq.bool false) ; -test "inRange(-6.6,nan,0.)" (fun () -> expect (Float.inRange -6.6 nan 0.) |> toEqual Eq.bool false) ; -test "inRange(nan,2.,8.)" (fun () -> expect (Float.inRange nan 2. 8.) |> toEqual Eq.bool false) ; -test "inRange(3.,7.,1.)" (fun () -> expect (fun () -> inRange 3. 7. 1.) |> toThrow); +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) ; @@ -83,9 +83,9 @@ test "isInteger(5.0)" (fun () -> expect (Float.isInteger 5.0) |> toEqual Eq.bool 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.,10.)" (fun () -> expect (Float.log 100. 10.) |> toEqual Eq.float 2.) ; -test "log(256.,2.)" (fun () -> expect (Float.log 256. 2.) |> toEqual Eq.float 8.) ; -test "log(0.,10.)" (fun () -> expect (Float.log 0. 10.) |> toEqual Eq.float negativeInfinity) ; +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) ; @@ -100,69 +100,69 @@ test "multiply(2.,7.)" (fun () -> expect (Float.multiply 2. 7.) |> toEqual Eq.fl 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(7.,3.)" (fun () -> expect (Float.power 7. 3.) |> toEqual Eq.float 343.) ; -test "power(0.,3.)" (fun () -> expect (Float.power 0. 3.) |> toEqual Eq.float 0.) ; -test "power(7.,0.)" (fun () -> expect (Float.power 7. 0.) |> toEqual Eq.float 1.) ; -test "round(#Zero,1.2)" (fun () -> expect (Float.round #Zero 1.2) |> toEqual Eq.float 1.) ; -test "round(#Zero,1.5)" (fun () -> expect (Float.round #Zero 1.5) |> toEqual Eq.float 1.) ; -test "round(#Zero,1.8)" (fun () -> expect (Float.round #Zero 1.8) |> toEqual Eq.float 1.) ; -test "round(#Zero,-1.2)" (fun () -> expect (Float.round #Zero -1.2) |> toEqual Eq.float -1.) ; -test "round(#Zero,-1.5)" (fun () -> expect (Float.round #Zero -1.5) |> toEqual Eq.float -1.) ; -test "round(#Zero,-1.8)" (fun () -> expect (Float.round #Zero -1.8) |> toEqual Eq.float -1.) ; -test "round(#AwayFromZero,1.2)" (fun () -> expect (Float.round #AwayFromZero 1.2) |> toEqual Eq.float 2.) ; -test "round(#AwayFromZero,1.5)" (fun () -> expect (Float.round #AwayFromZero 1.5) |> toEqual Eq.float 2.) ; -test "round(#AwayFromZero,1.8)" (fun () -> expect (Float.round #AwayFromZero 1.8) |> toEqual Eq.float 2.) ; -test "round(#AwayFromZero,-1.2)" (fun () -> expect (Float.round #AwayFromZero -1.2) |> toEqual Eq.float -2.) ; -test "round(#AwayFromZero,-1.5)" (fun () -> expect (Float.round #AwayFromZero -1.5) |> toEqual Eq.float -2.) ; -test "round(#AwayFromZero,-1.8)" (fun () -> expect (Float.round #AwayFromZero -1.8) |> toEqual Eq.float -2.) ; -test "round(#Up,1.2)" (fun () -> expect (Float.round #Up 1.2) |> toEqual Eq.float 2.) ; -test "round(#Up,1.5)" (fun () -> expect (Float.round #Up 1.5) |> toEqual Eq.float 2.) ; -test "round(#Up,1.8)" (fun () -> expect (Float.round #Up 1.8) |> toEqual Eq.float 2.) ; -test "round(#Up,-1.2)" (fun () -> expect (Float.round #Up -1.2) |> toEqual Eq.float -1.) ; -test "round(#Up,-1.5)" (fun () -> expect (Float.round #Up -1.5) |> toEqual Eq.float -1.) ; -test "round(#Up,-1.8)" (fun () -> expect (Float.round #Up -1.8) |> toEqual Eq.float -1.) ; -test "round(#Down,1.2)" (fun () -> expect (Float.round #Down 1.2) |> toEqual Eq.float 1.) ; -test "round(#Down,1.5)" (fun () -> expect (Float.round #Down 1.5) |> toEqual Eq.float 1.) ; -test "round(#Down,1.8)" (fun () -> expect (Float.round #Down 1.8) |> toEqual Eq.float 1.) ; -test "round(#Down,-1.2)" (fun () -> expect (Float.round #Down -1.2) |> toEqual Eq.float -2.) ; -test "round(#Down,-1.5)" (fun () -> expect (Float.round #Down -1.5) |> toEqual Eq.float -2.) ; -test "round(#Down,-1.8)" (fun () -> expect (Float.round #Down -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#Zero),1.2)" (fun () -> expect (Float.round #Closest(#Zero) 1.2) |> toEqual Eq.float 1.) ; -test "round(#Closest(#Zero),1.5)" (fun () -> expect (Float.round #Closest(#Zero) 1.5) |> toEqual Eq.float 1.) ; -test "round(#Closest(#Zero),1.8)" (fun () -> expect (Float.round #Closest(#Zero) 1.8) |> toEqual Eq.float 2.) ; -test "round(#Closest(#Zero),-1.2)" (fun () -> expect (Float.round #Closest(#Zero) -1.2) |> toEqual Eq.float -1.) ; -test "round(#Closest(#Zero),-1.5)" (fun () -> expect (Float.round #Closest(#Zero) -1.5) |> toEqual Eq.float -1.) ; -test "round(#Closest(#Zero),-1.8)" (fun () -> expect (Float.round #Closest(#Zero) -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#AwayFromZero),1.2)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.2) |> toEqual Eq.float 1.) ; -test "round(#Closest(#AwayFromZero),1.5)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.5) |> toEqual Eq.float 2.) ; -test "round(#Closest(#AwayFromZero),1.8)" (fun () -> expect (Float.round #Closest(#AwayFromZero) 1.8) |> toEqual Eq.float 2.) ; -test "round(#Closest(#AwayFromZero),-1.2)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.2) |> toEqual Eq.float -1.) ; -test "round(#Closest(#AwayFromZero),-1.5)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.5) |> toEqual Eq.float -2.) ; -test "round(#Closest(#AwayFromZero),-1.8)" (fun () -> expect (Float.round #Closest(#AwayFromZero) -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#Up),1.2)" (fun () -> expect (Float.round #Closest(#Up) 1.2) |> toEqual Eq.float 1.) ; -test "round(#Closest(#Up),1.5)" (fun () -> expect (Float.round #Closest(#Up) 1.5) |> toEqual Eq.float 2.) ; -test "round(#Closest(#Up),1.8)" (fun () -> expect (Float.round #Closest(#Up) 1.8) |> toEqual Eq.float 2.) ; -test "round(#Closest(#Up),-1.2)" (fun () -> expect (Float.round #Closest(#Up) -1.2) |> toEqual Eq.float -1.) ; -test "round(#Closest(#Up),-1.5)" (fun () -> expect (Float.round #Closest(#Up) -1.5) |> toEqual Eq.float -1.) ; -test "round(#Closest(#Up),-1.8)" (fun () -> expect (Float.round #Closest(#Up) -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#Down),1.2)" (fun () -> expect (Float.round #Closest(#Down) 1.2) |> toEqual Eq.float 1.) ; -test "round(#Closest(#Down),1.5)" (fun () -> expect (Float.round #Closest(#Down) 1.5) |> toEqual Eq.float 1.) ; -test "round(#Closest(#Down),1.8)" (fun () -> expect (Float.round #Closest(#Down) 1.8) |> toEqual Eq.float 2.) ; -test "round(#Closest(#Down),-1.2)" (fun () -> expect (Float.round #Closest(#Down) -1.2) |> toEqual Eq.float -1.) ; -test "round(#Closest(#Down),-1.5)" (fun () -> expect (Float.round #Closest(#Down) -1.5) |> toEqual Eq.float -2.) ; -test "round(#Closest(#Down),-1.8)" (fun () -> expect (Float.round #Closest(#Down) -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#ToEven),1.2)" (fun () -> expect (Float.round #Closest(#ToEven) 1.2) |> toEqual Eq.float 1.) ; -test "round(#Closest(#ToEven),1.5)" (fun () -> expect (Float.round #Closest(#ToEven) 1.5) |> toEqual Eq.float 2.) ; -test "round(#Closest(#ToEven),1.8)" (fun () -> expect (Float.round #Closest(#ToEven) 1.8) |> toEqual Eq.float 2.) ; -test "round(#Closest(#ToEven),2.2)" (fun () -> expect (Float.round #Closest(#ToEven) 2.2) |> toEqual Eq.float 2.) ; -test "round(#Closest(#ToEven),2.5)" (fun () -> expect (Float.round #Closest(#ToEven) 2.5) |> toEqual Eq.float 2.) ; -test "round(#Closest(#ToEven),2.8)" (fun () -> expect (Float.round #Closest(#ToEven) 2.8) |> toEqual Eq.float 3.) ; -test "round(#Closest(#ToEven),-1.2)" (fun () -> expect (Float.round #Closest(#ToEven) -1.2) |> toEqual Eq.float -1.) ; -test "round(#Closest(#ToEven),-1.5)" (fun () -> expect (Float.round #Closest(#ToEven) -1.5) |> toEqual Eq.float -2.) ; -test "round(#Closest(#ToEven),-1.8)" (fun () -> expect (Float.round #Closest(#ToEven) -1.8) |> toEqual Eq.float -2.) ; -test "round(#Closest(#ToEven),-2.2)" (fun () -> expect (Float.round #Closest(#ToEven) -2.2) |> toEqual Eq.float -2.) ; -test "round(#Closest(#ToEven),-2.5)" (fun () -> expect (Float.round #Closest(#ToEven) -2.5) |> toEqual Eq.float -2.) ; -test "round(#Closest(#ToEven),-2.8)" (fun () -> expect (Float.round #Closest(#ToEven) -2.8) |> toEqual Eq.float -3.) ; +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) ; diff --git a/test/ocamlTests/IntTest.ml b/test/ocamlTests/IntTest.ml index bb983c05..77214297 100644 --- a/test/ocamlTests/IntTest.ml +++ b/test/ocamlTests/IntTest.ml @@ -9,20 +9,20 @@ 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,0,8)" (fun () -> expect (Int.clamp 5 0 8) |> toEqual Eq.int 5) ; -test "clamp(9,0,8)" (fun () -> expect (Int.clamp 9 0 8) |> toEqual Eq.int 8) ; -test "clamp(1,2,8)" (fun () -> expect (Int.clamp 1 2 8) |> toEqual Eq.int 2) ; -test "clamp(5,-10,-5)" (fun () -> expect (Int.clamp 5 -10 -5) |> toEqual Eq.int -5) ; -test "clamp(-15,-10,-5)" (fun () -> expect (Int.clamp -15 -10 -5) |> toEqual Eq.int -10) ; -test "clamp(3,7,1)" (fun () -> expect (fun () -> clamp 3 7 1) |> toThrow); -test "divide(3,2)" (fun () -> expect (Int.divide 3 2) |> toEqual Eq.int 1) ; -test "divide(3,0)" (fun () -> expect (fun () -> divide 3 0) |> toThrow); -test "divide(27,5)" (fun () -> expect (Int.divide 27 5) |> toEqual Eq.int 5) ; -test "divideFloat(3,2)" (fun () -> expect (Int.divideFloat 3 2) |> toEqual Eq.float 1.5) ; -test "divideFloat(27,5)" (fun () -> expect (Int.divideFloat 27 5) |> toEqual Eq.float 5.4) ; -test "divideFloat(8,4)" (fun () -> expect (Int.divideFloat 8 4) |> toEqual Eq.float 2) ; -test "divideFloat(8,0)" (fun () -> expect (Int.divideFloat 8 0) |> toEqual Eq.float Float.infinity) ; -test "divideFloat(-8,0)" (fun () -> expect (Int.divideFloat -8 0) |> toEqual Eq.float Float.negativeInfinity) ; +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)) ; @@ -36,12 +36,12 @@ test "fromString("NaN")" (fun () -> expect (Int.fromString "NaN") |> toEqual (le 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,2,4)" (fun () -> expect (Int.inRange 3 2 4) |> toEqual Eq.bool true) ; -test "inRange(8,2,4)" (fun () -> expect (Int.inRange 8 2 4) |> toEqual Eq.bool false) ; -test "inRange(1,2,4)" (fun () -> expect (Int.inRange 1 2 4) |> toEqual Eq.bool false) ; -test "inRange(2,1,2)" (fun () -> expect (Int.inRange 2 1 2) |> toEqual Eq.bool false) ; -test "inRange(-6,-7,-5)" (fun () -> expect (Int.inRange -6 -7 -5) |> toEqual Eq.bool true) ; -test "inRange(3,7,1)" (fun () -> expect (fun () -> inRange 3 7 1) |> toThrow); +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) ; @@ -54,30 +54,30 @@ 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,3)" (fun () -> expect (Int.modulo -4 3) |> toEqual Eq.int 2) ; -test "modulo(-3,3)" (fun () -> expect (Int.modulo -3 3) |> toEqual Eq.int 0) ; -test "modulo(-2,3)" (fun () -> expect (Int.modulo -2 3) |> toEqual Eq.int 1) ; -test "modulo(-1,3)" (fun () -> expect (Int.modulo -1 3) |> toEqual Eq.int 2) ; -test "modulo(0,3)" (fun () -> expect (Int.modulo 0 3) |> toEqual Eq.int 0) ; -test "modulo(1,3)" (fun () -> expect (Int.modulo 1 3) |> toEqual Eq.int 1) ; -test "modulo(2,3)" (fun () -> expect (Int.modulo 2 3) |> toEqual Eq.int 2) ; -test "modulo(3,3)" (fun () -> expect (Int.modulo 3 3) |> toEqual Eq.int 0) ; -test "modulo(4,3)" (fun () -> expect (Int.modulo 4 3) |> toEqual Eq.int 1) ; +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(7,3)" (fun () -> expect (Int.power 7 3) |> toEqual Eq.int 343) ; -test "power(0,3)" (fun () -> expect (Int.power 0 3) |> toEqual Eq.int 0) ; -test "power(7,0)" (fun () -> expect (Int.power 7 0) |> toEqual Eq.int 1) ; -test "remainder(-4,3)" (fun () -> expect (Int.remainder -4 3) |> toEqual Eq.int -1) ; -test "remainder(-2,3)" (fun () -> expect (Int.remainder -2 3) |> toEqual Eq.int -2) ; -test "remainder(-1,3)" (fun () -> expect (Int.remainder -1 3) |> toEqual Eq.int -1) ; -test "remainder(0,3)" (fun () -> expect (Int.remainder 0 3) |> toEqual Eq.int 0) ; -test "remainder(1,3)" (fun () -> expect (Int.remainder 1 3) |> toEqual Eq.int 1) ; -test "remainder(2,3)" (fun () -> expect (Int.remainder 2 3) |> toEqual Eq.int 2) ; -test "remainder(3,3)" (fun () -> expect (Int.remainder 3 3) |> toEqual Eq.int 0) ; -test "remainder(4,3)" (fun () -> expect (Int.remainder 4 3) |> toEqual Eq.int 1) ; +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.) ; diff --git a/test/rescriptTests/CharTest.res b/test/rescriptTests/CharTest.res index d208fe93..0c6f6c23 100644 --- a/test/rescriptTests/CharTest.res +++ b/test/rescriptTests/CharTest.res @@ -38,8 +38,6 @@ test ("isLowercase('a')", () => expect(Char.isLowercase('a')) |> toEqual(Eq.bool 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 ("isPrintable(fromCode(31) |> Option.map(~f=isPrintable))", () => expect(Char.isPrintable(fromCode(31) |> Option.map(~f=isPrintable))) |> toEqual({open Eq -bool()}, Some(false))) 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)) diff --git a/test/rescriptTests/FloatTest.res b/test/rescriptTests/FloatTest.res index 699ac76c..39326ce3 100644 --- a/test/rescriptTests/FloatTest.res +++ b/test/rescriptTests/FloatTest.res @@ -7,25 +7,25 @@ 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.,0.,8.)", () => expect(Float.clamp(5.,0.,8.)) |> toEqual(Eq.float, 5.)) -test ("clamp(9.,0.,8.)", () => expect(Float.clamp(9.,0.,8.)) |> toEqual(Eq.float, 8.)) -test ("clamp(1.,2.,8.)", () => expect(Float.clamp(1.,2.,8.)) |> toEqual(Eq.float, 2.)) -test ("clamp(5.,-10.,-5.)", () => expect(Float.clamp(5.,-10.,-5.)) |> toEqual(Eq.float, -5.)) -test ("clamp(-15.,-10.,-5.)", () => expect(Float.clamp(-15.,-10.,-5.)) |> toEqual(Eq.float, -10.)) -test ("clamp(-6.6,-7.9,nan)", () => expect(Float.clamp(-6.6,-7.9,nan)) |> toEqual(Eq.float, NaN)) -test ("clamp(-6.6,nan,0.)", () => expect(Float.clamp(-6.6,nan,0.)) |> toEqual(Eq.float, NaN)) -test ("clamp(nan,2.,8.)", () => expect(Float.clamp(nan,2.,8.)) |> toEqual(Eq.float, NaN)) -test ("clamp(3.,7., 1.)", () => expect(() => Float.clamp(3.,7., 1.)) |> toThrow) +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(0.,0.)", () => expect(Float.atan2(0.,0.)) |> toEqual(Eq.radians, 0.)) -test ("atan2(1.,1.)", () => expect(Float.atan2(1.,1.)) |> toEqual(Eq.radians, 0.7853981633974483)) -test ("atan2(1.,-1.)", () => expect(Float.atan2(1.,-1.)) |> toEqual(Eq.radians, 2.356194490192345)) -test ("atan2(-1.,-1.)", () => expect(Float.atan2(-1.,-1.)) |> toEqual(Eq.radians, -2.356194490192345)) -test ("atan2(-1.,1.)", () => expect(Float.atan2(-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.)) @@ -35,9 +35,9 @@ 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,2.)", () => expect(Float.divide(3.14,2.)) |> toEqual(Eq.float, 1.57)) -test ("divide(3.14,0.)", () => expect(Float.divide(3.14,0.)) |> toEqual(Eq.float, infinity)) -test ("divide(3.14,-0.)", () => expect(Float.divide(3.14,-0.)) |> toEqual(Eq.float, negativeInfinity)) +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.)) @@ -62,15 +62,15 @@ 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.,2.,4.)", () => expect(Float.inRange(3.,2.,4.)) |> toEqual(Eq.bool, true)) -test ("inRange(8.,2.,4.)", () => expect(Float.inRange(8.,2.,4.)) |> toEqual(Eq.bool, false)) -test ("inRange(1., 2.,4.)", () => expect(Float.inRange(1., 2.,4.)) |> toEqual(Eq.bool, false)) -test ("inRange(2.,1.,2.)", () => expect(Float.inRange(2.,1.,2.)) |> toEqual(Eq.bool, false)) -test ("inRange(-6.6,-7.9,-5.2)", () => expect(Float.inRange(-6.6,-7.9,-5.2)) |> toEqual(Eq.bool, true)) -test ("inRange(-6.6,-7.9,nan)", () => expect(Float.inRange(-6.6,-7.9,nan)) |> toEqual(Eq.bool, false)) -test ("inRange(-6.6,nan,0.)", () => expect(Float.inRange(-6.6,nan,0.)) |> toEqual(Eq.bool, false)) -test ("inRange(nan,2.,8.)", () => expect(Float.inRange(nan,2.,8.)) |> toEqual(Eq.bool, false)) -test ("inRange(3.,7.,1.)", () => expect(() => Float.inRange(3.,7.,1.)) |> toThrow) +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)) @@ -89,9 +89,9 @@ test ("isInteger(5.0)", () => expect(Float.isInteger(5.0)) |> toEqual(Eq.bool, t 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.,10.)", () => expect(Float.log(100.,10.)) |> toEqual(Eq.float, 2.)) -test ("log(256.,2.)", () => expect(Float.log(256.,2.)) |> toEqual(Eq.float, 8.)) -test ("log(0.,10.)", () => expect(Float.log(0.,10.)) |> toEqual(Eq.float, negativeInfinity)) +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)) @@ -106,69 +106,69 @@ test ("multiply(2.,7.)", () => expect(Float.multiply(2.,7.)) |> toEqual(Eq.float 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(7.,3.)", () => expect(Float.power(7.,3.)) |> toEqual(Eq.float, 343.)) -test ("power(0.,3.)", () => expect(Float.power(0.,3.)) |> toEqual(Eq.float, 0.)) -test ("power(7.,0.)", () => expect(Float.power(7.,0.)) |> toEqual(Eq.float, 1.)) -test ("round(#Zero,1.2)", () => expect(Float.round(#Zero,1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Zero,1.5)", () => expect(Float.round(#Zero,1.5)) |> toEqual(Eq.float, 1.)) -test ("round(#Zero,1.8)", () => expect(Float.round(#Zero,1.8)) |> toEqual(Eq.float, 1.)) -test ("round(#Zero,-1.2)", () => expect(Float.round(#Zero,-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Zero,-1.5)", () => expect(Float.round(#Zero,-1.5)) |> toEqual(Eq.float, -1.)) -test ("round(#Zero,-1.8)", () => expect(Float.round(#Zero,-1.8)) |> toEqual(Eq.float, -1.)) -test ("round(#AwayFromZero,1.2)", () => expect(Float.round(#AwayFromZero,1.2)) |> toEqual(Eq.float, 2.)) -test ("round(#AwayFromZero,1.5)", () => expect(Float.round(#AwayFromZero,1.5)) |> toEqual(Eq.float, 2.)) -test ("round(#AwayFromZero,1.8)", () => expect(Float.round(#AwayFromZero,1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#AwayFromZero,-1.2)", () => expect(Float.round(#AwayFromZero,-1.2)) |> toEqual(Eq.float, -2.)) -test ("round(#AwayFromZero,-1.5)", () => expect(Float.round(#AwayFromZero,-1.5)) |> toEqual(Eq.float, -2.)) -test ("round(#AwayFromZero,-1.8)", () => expect(Float.round(#AwayFromZero,-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Up,1.2)", () => expect(Float.round(#Up,1.2)) |> toEqual(Eq.float, 2.)) -test ("round(#Up,1.5)", () => expect(Float.round(#Up,1.5)) |> toEqual(Eq.float, 2.)) -test ("round(#Up,1.8)", () => expect(Float.round(#Up,1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Up,-1.2)", () => expect(Float.round(#Up,-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Up,-1.5)", () => expect(Float.round(#Up,-1.5)) |> toEqual(Eq.float, -1.)) -test ("round(#Up,-1.8)", () => expect(Float.round(#Up,-1.8)) |> toEqual(Eq.float, -1.)) -test ("round(#Down,1.2)", () => expect(Float.round(#Down,1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Down,1.5)", () => expect(Float.round(#Down,1.5)) |> toEqual(Eq.float, 1.)) -test ("round(#Down,1.8)", () => expect(Float.round(#Down,1.8)) |> toEqual(Eq.float, 1.)) -test ("round(#Down,-1.2)", () => expect(Float.round(#Down,-1.2)) |> toEqual(Eq.float, -2.)) -test ("round(#Down,-1.5)", () => expect(Float.round(#Down,-1.5)) |> toEqual(Eq.float, -2.)) -test ("round(#Down,-1.8)", () => expect(Float.round(#Down,-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#Zero),1.2)", () => expect(Float.round(#Closest(#Zero),1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#Zero),1.5)", () => expect(Float.round(#Closest(#Zero),1.5)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#Zero),1.8)", () => expect(Float.round(#Closest(#Zero),1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#Zero),-1.2)", () => expect(Float.round(#Closest(#Zero),-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#Zero),-1.5)", () => expect(Float.round(#Closest(#Zero),-1.5)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#Zero),-1.8)", () => expect(Float.round(#Closest(#Zero),-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#AwayFromZero),1.2)", () => expect(Float.round(#Closest(#AwayFromZero),1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#AwayFromZero),1.5)", () => expect(Float.round(#Closest(#AwayFromZero),1.5)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#AwayFromZero),1.8)", () => expect(Float.round(#Closest(#AwayFromZero),1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#AwayFromZero),-1.2)", () => expect(Float.round(#Closest(#AwayFromZero),-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#AwayFromZero),-1.5)", () => expect(Float.round(#Closest(#AwayFromZero),-1.5)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#AwayFromZero),-1.8)", () => expect(Float.round(#Closest(#AwayFromZero),-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#Up),1.2)", () => expect(Float.round(#Closest(#Up),1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#Up),1.5)", () => expect(Float.round(#Closest(#Up),1.5)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#Up),1.8)", () => expect(Float.round(#Closest(#Up),1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#Up),-1.2)", () => expect(Float.round(#Closest(#Up),-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#Up),-1.5)", () => expect(Float.round(#Closest(#Up),-1.5)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#Up),-1.8)", () => expect(Float.round(#Closest(#Up),-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#Down),1.2)", () => expect(Float.round(#Closest(#Down),1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#Down),1.5)", () => expect(Float.round(#Closest(#Down),1.5)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#Down),1.8)", () => expect(Float.round(#Closest(#Down),1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#Down),-1.2)", () => expect(Float.round(#Closest(#Down),-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#Down),-1.5)", () => expect(Float.round(#Closest(#Down),-1.5)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#Down),-1.8)", () => expect(Float.round(#Closest(#Down),-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#ToEven),1.2)", () => expect(Float.round(#Closest(#ToEven),1.2)) |> toEqual(Eq.float, 1.)) -test ("round(#Closest(#ToEven),1.5)", () => expect(Float.round(#Closest(#ToEven),1.5)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#ToEven),1.8)", () => expect(Float.round(#Closest(#ToEven),1.8)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#ToEven),2.2)", () => expect(Float.round(#Closest(#ToEven),2.2)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#ToEven),2.5)", () => expect(Float.round(#Closest(#ToEven),2.5)) |> toEqual(Eq.float, 2.)) -test ("round(#Closest(#ToEven),2.8)", () => expect(Float.round(#Closest(#ToEven),2.8)) |> toEqual(Eq.float, 3.)) -test ("round(#Closest(#ToEven),-1.2)", () => expect(Float.round(#Closest(#ToEven),-1.2)) |> toEqual(Eq.float, -1.)) -test ("round(#Closest(#ToEven),-1.5)", () => expect(Float.round(#Closest(#ToEven),-1.5)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#ToEven),-1.8)", () => expect(Float.round(#Closest(#ToEven),-1.8)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#ToEven),-2.2)", () => expect(Float.round(#Closest(#ToEven),-2.2)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#ToEven),-2.5)", () => expect(Float.round(#Closest(#ToEven),-2.5)) |> toEqual(Eq.float, -2.)) -test ("round(#Closest(#ToEven),-2.8)", () => expect(Float.round(#Closest(#ToEven),-2.8)) |> toEqual(Eq.float, -3.)) +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)) diff --git a/test/rescriptTests/IntTest.res b/test/rescriptTests/IntTest.res index c247cd9f..dddc3336 100644 --- a/test/rescriptTests/IntTest.res +++ b/test/rescriptTests/IntTest.res @@ -8,20 +8,20 @@ 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,0,8)", () => expect(Int.clamp(5,0,8)) |> toEqual(Eq.int, 5)) -test ("clamp(9,0,8)", () => expect(Int.clamp(9,0,8)) |> toEqual(Eq.int, 8)) -test ("clamp(1,2,8)", () => expect(Int.clamp(1,2,8)) |> toEqual(Eq.int, 2)) -test ("clamp(5,-10,-5)", () => expect(Int.clamp(5,-10,-5)) |> toEqual(Eq.int, -5)) -test ("clamp(-15,-10,-5)", () => expect(Int.clamp(-15,-10,-5)) |> toEqual(Eq.int, -10)) -test ("clamp(3,7,1)", () => expect(() => Int.clamp(3,7,1)) |> toThrow) -test ("divide(3,2)", () => expect(Int.divide(3,2)) |> toEqual(Eq.int, 1)) -test ("divide(3,0)", () => expect(() => Int.divide(3,0)) |> toThrow) -test ("divide(27,5)", () => expect(Int.divide(27,5)) |> toEqual(Eq.int, 5)) -test ("divideFloat(3,2)", () => expect(Int.divideFloat(3,2)) |> toEqual(Eq.float, 1.5)) -test ("divideFloat(27,5)", () => expect(Int.divideFloat(27,5)) |> toEqual(Eq.float, 5.4)) -test ("divideFloat(8,4)", () => expect(Int.divideFloat(8,4)) |> toEqual(Eq.float, 2)) -test ("divideFloat(8,0)", () => expect(Int.divideFloat(8,0)) |> toEqual(Eq.float, Float.infinity)) -test ("divideFloat(-8,0)", () => expect(Int.divideFloat(-8,0)) |> toEqual(Eq.float, Float.negativeInfinity)) +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 @@ -48,12 +48,12 @@ 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,2,4)", () => expect(Int.inRange(3,2,4)) |> toEqual(Eq.bool, true)) -test ("inRange(8,2,4)", () => expect(Int.inRange(8,2,4)) |> toEqual(Eq.bool, false)) -test ("inRange(1,2,4)", () => expect(Int.inRange(1,2,4)) |> toEqual(Eq.bool, false)) -test ("inRange(2,1,2)", () => expect(Int.inRange(2,1,2)) |> toEqual(Eq.bool, false)) -test ("inRange(-6,-7,-5)", () => expect(Int.inRange(-6,-7,-5)) |> toEqual(Eq.bool, true)) -test ("inRange(3,7,1)", () => expect(() => Int.inRange(3,7,1)) |> toThrow) +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)) @@ -66,30 +66,30 @@ 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,3)", () => expect(Int.modulo(-4,3)) |> toEqual(Eq.int, 2)) -test ("modulo(-3,3)", () => expect(Int.modulo(-3,3)) |> toEqual(Eq.int, 0)) -test ("modulo(-2,3)", () => expect(Int.modulo(-2,3)) |> toEqual(Eq.int, 1)) -test ("modulo(-1,3)", () => expect(Int.modulo(-1,3)) |> toEqual(Eq.int, 2)) -test ("modulo(0,3)", () => expect(Int.modulo(0,3)) |> toEqual(Eq.int, 0)) -test ("modulo(1,3)", () => expect(Int.modulo(1,3)) |> toEqual(Eq.int, 1)) -test ("modulo(2,3)", () => expect(Int.modulo(2,3)) |> toEqual(Eq.int, 2)) -test ("modulo(3,3)", () => expect(Int.modulo(3,3)) |> toEqual(Eq.int, 0)) -test ("modulo(4,3)", () => expect(Int.modulo(4,3)) |> toEqual(Eq.int, 1)) +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(7,3)", () => expect(Int.power(7,3)) |> toEqual(Eq.int, 343)) -test ("power(0,3)", () => expect(Int.power(0,3)) |> toEqual(Eq.int, 0)) -test ("power(7,0)", () => expect(Int.power(7,0)) |> toEqual(Eq.int, 1)) -test ("remainder(-4,3)", () => expect(Int.remainder(-4,3)) |> toEqual(Eq.int, -1)) -test ("remainder(-2,3)", () => expect(Int.remainder(-2,3)) |> toEqual(Eq.int, -2)) -test ("remainder(-1,3)", () => expect(Int.remainder(-1,3)) |> toEqual(Eq.int, -1)) -test ("remainder(0,3)", () => expect(Int.remainder(0,3)) |> toEqual(Eq.int, 0)) -test ("remainder(1,3)", () => expect(Int.remainder(1,3)) |> toEqual(Eq.int, 1)) -test ("remainder(2,3)", () => expect(Int.remainder(2,3)) |> toEqual(Eq.int, 2)) -test ("remainder(3,3)", () => expect(Int.remainder(3,3)) |> toEqual(Eq.int, 0)) -test ("remainder(4,3)", () => expect(Int.remainder(4,3)) |> toEqual(Eq.int, 1)) +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.)) diff --git a/yaml-files/Float.atan2.yaml b/yaml-files/Float.atan2.yaml index efb3d065..98aeb581 100644 --- a/yaml-files/Float.atan2.yaml +++ b/yaml-files/Float.atan2.yaml @@ -1,38 +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 +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/String.insertAt.yaml b/yaml-files/String.insertAt.yaml index e3ce2f47..97c9098c 100644 --- a/yaml-files/String.insertAt.yaml +++ b/yaml-files/String.insertAt.yaml @@ -1,45 +1,45 @@ -module: String -name: insertAt -docstring: Insert a string at [index] -parameters: - - name: a - type: string - label: false - - name: index - type: int - label: true - - name: value - type: string - 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 +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