diff --git a/dune b/dune index 6260b2e2..9ed2ee1b 100644 --- a/dune +++ b/dune @@ -1,4 +1,4 @@ -(dirs :standard \ examples) +(dirs :standard \ examples test) (env (dev (flags (:standard -warn-error -A)))) \ No newline at end of file diff --git a/package.json b/package.json index d40c2cb3..fdb6f0e8 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "rescript-editor-support", "version": "1.0.0", "scripts": { + "test": "cd test && ./test.sh", "dce": "dune build @check @all && node_modules/.bin/reanalyze -dce-cmt _build -suppress src/vendor" }, "keywords": [ diff --git a/src/EditorSupportCommands.ml b/src/EditorSupportCommands.ml index 4e1d801b..1d41c507 100644 --- a/src/EditorSupportCommands.ml +++ b/src/EditorSupportCommands.ml @@ -182,6 +182,7 @@ let test ~path = if mlen >= 3 then match String.sub rest 0 3 with | "def" -> definition ~path ~line ~col + | "hov" -> hover ~path ~line ~col | "com" -> let currentFile, cout = Filename.open_temp_file "def" "txt" in lines diff --git a/test.sh b/test.sh deleted file mode 100755 index 7d48ae7b..00000000 --- a/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/zsh - -./_build/install/default/bin/rescript-editor-support.exe test test/src/Definition.res - -./_build/install/default/bin/rescript-editor-support.exe test test/src/Complete.res diff --git a/test/bsconfig.json b/test/bsconfig.json index 0c9eafc6..a65991b9 100644 --- a/test/bsconfig.json +++ b/test/bsconfig.json @@ -1,5 +1,6 @@ { "name": "test", "sources": "src", - "bs-dependencies": ["reason-react"] -} \ No newline at end of file + "bs-dependencies": ["reason-react"], + "reason": { "react-jsx": 3 } +} diff --git a/test/package-lock.json b/test/package-lock.json index 50fe3745..979580da 100644 --- a/test/package-lock.json +++ b/test/package-lock.json @@ -1,33 +1,6 @@ { - "name": "test", - "lockfileVersion": 2, "requires": true, - "packages": { - "": { - "dependencies": { - "reason-react": "^0.9.1", - "rescript": "9.1.0" - } - }, - "node_modules/reason-react": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/reason-react/-/reason-react-0.9.1.tgz", - "integrity": "sha512-nlH0O2TDy9KzOLOW+vlEQk4ExHOeciyzFdoLcsmmiit6hx6H5+CVDrwJ+8aiaLT/kqK5xFOjy4PS7PftWz4plA==" - }, - "node_modules/rescript": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-9.1.0.tgz", - "integrity": "sha512-KHBM5SRk4aauUzeDCT3EB5kjly36Olkv+8jmurVJxJAa6L7Sz6AJXzmgZA0cU65/nvdi3InhpNSuxTsDlPj/3A==", - "hasInstallScript": true, - "bin": { - "bsb": "bsb", - "bsc": "bsc", - "bsrefmt": "bsrefmt", - "bstracing": "lib/bstracing", - "rescript": "rescript" - } - } - }, + "lockfileVersion": 1, "dependencies": { "reason-react": { "version": "0.9.1", diff --git a/test/src/Hover.res b/test/src/Hover.res index e69de29b..447cf5d8 100644 --- a/test/src/Hover.res +++ b/test/src/Hover.res @@ -0,0 +1,2 @@ +let abc = 22 + 34 +// ^hov diff --git a/test/src/Jsx.res b/test/src/Jsx.res new file mode 100644 index 00000000..d28ce76e --- /dev/null +++ b/test/src/Jsx.res @@ -0,0 +1,12 @@ +module M = { + @react.component + let make = (~first, ~fun="", ~second="") => React.string(first ++ fun++ second) +} + +let d = +// ^def + +//^com ", + "documentation": {"kind": "markdown", "value": "\nJsx.res:11"} + }] diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 00000000..2b97f919 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,10 @@ +#!/bin/zsh + +function exp { + echo "$(dirname $1)/expected/$(basename $1).txt" +} + +./node_modules/.bin/rescript build +for file in src/**/*.res; do + ../_build/install/default/bin/rescript-editor-support.exe test $file &> $(exp $file) +done