summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJake Zimmerman <zimmerman.jake@gmail.com>2017-09-03 11:56:14 -0700
committerw0rp <w0rp@users.noreply.github.com>2017-09-03 19:56:14 +0100
commit63e8946fc808c19512454b33d641be1a5fd99ce0 (patch)
treea48101ae352803d9dd1fc7e726ef6ed92e458345 /test
parentc7fbcb3c02131a4e168290005c1e550b953cb8f4 (diff)
downloadale-63e8946fc808c19512454b33d641be1a5fd99ce0.zip
Detect and use CM files for smlnj (#884)
* Detect and use CM files for smlnj * Split into two checkers - one for CM projects - one for single SML files * Fix some typos * Fix error caught by writing tests We want to actually use `glob` to search in paths upwards from us. (Previously we were just searching in the current directory every time!) * Fix errors from former test run * Write tests for GetCmFile and GetExecutableSmlnj * Typo in 'smlnj/' fixture filenames
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_sml_handler.vader11
-rw-r--r--test/smlnj/cm/foo.sml0
-rw-r--r--test/smlnj/cm/path/to/bar.sml0
-rw-r--r--test/smlnj/cm/sources.cm0
-rw-r--r--test/smlnj/file/qux.sml0
-rw-r--r--test/test_sml_command.vader47
6 files changed, 51 insertions, 7 deletions
diff --git a/test/handler/test_sml_handler.vader b/test/handler/test_sml_handler.vader
index 26c85710..f711cc9c 100644
--- a/test/handler/test_sml_handler.vader
+++ b/test/handler/test_sml_handler.vader
@@ -1,6 +1,3 @@
-Before:
- runtime ale_linters/sml/smlnj.vim
-
Execute (Testing on EOF error):
AssertEqual [
\ {
@@ -11,7 +8,7 @@ Execute (Testing on EOF error):
\ 'text': 'Error: syntax error found at EOF',
\ },
\],
- \ ale_linters#sml#smlnj#Handle(42, [
+ \ ale#handlers#sml#Handle(42, [
\ "Standard ML of New Jersey v110.78 [built: Thu Jul 23 11:21:58 2015]",
\ "[opening a.sml]",
\ "a.sml:2.16 Error: syntax error found at EOF",
@@ -35,7 +32,7 @@ Execute (Testing if the handler can handle multiple errors on the same line):
\ 'text': 'Error: unbound variable or constructor: wow',
\ },
\],
- \ ale_linters#sml#smlnj#Handle(42, [
+ \ ale#handlers#sml#Handle(42, [
\ "Standard ML of New Jersey v110.78 [built: Thu Jul 23 11:21:58 2015]",
\ "[opening test.sml]",
\ "a.sml:1.6-1.10 Error: can't find function arguments in clause",
@@ -61,7 +58,7 @@ Execute (Testing rarer errors):
\ 'text': "Error: value type in structure doesn't match signature spec",
\ },
\],
- \ ale_linters#sml#smlnj#Handle(42, [
+ \ ale#handlers#sml#Handle(42, [
\ "Standard ML of New Jersey v110.78 [built: Thu Jul 23 11:21:58 2015]",
\ "[opening test.sml]",
\ "a.sml:5.19 Error: syntax error found at ID",
@@ -80,7 +77,7 @@ Execute (Testing a warning):
\ 'text': "Warning: match nonexhaustive",
\ },
\],
- \ ale_linters#sml#smlnj#Handle(42, [
+ \ ale#handlers#sml#Handle(42, [
\ "Standard ML of New Jersey v110.78 [built: Thu Jul 23 11:21:58 2015]",
\ "[opening a.sml]",
\ "a.sml:4.5-4.12 Warning: match nonexhaustive",
diff --git a/test/smlnj/cm/foo.sml b/test/smlnj/cm/foo.sml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/smlnj/cm/foo.sml
diff --git a/test/smlnj/cm/path/to/bar.sml b/test/smlnj/cm/path/to/bar.sml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/smlnj/cm/path/to/bar.sml
diff --git a/test/smlnj/cm/sources.cm b/test/smlnj/cm/sources.cm
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/smlnj/cm/sources.cm
diff --git a/test/smlnj/file/qux.sml b/test/smlnj/file/qux.sml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/smlnj/file/qux.sml
diff --git a/test/test_sml_command.vader b/test/test_sml_command.vader
new file mode 100644
index 00000000..5ce8a313
--- /dev/null
+++ b/test/test_sml_command.vader
@@ -0,0 +1,47 @@
+Before:
+ runtime ale_linters/sml/sml.vim
+ runtime ale_linters/sml/smlnj.vim
+ call ale#test#SetDirectory('/testplugin/test')
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+# ----- GetCmFile -----
+
+Execute(smlnj finds CM file if it exists):
+ call ale#test#SetFilename('smlnj/cm/foo.sml')
+
+ AssertEqual '/testplugin/test/smlnj/cm/sources.cm', ale#handlers#sml#GetCmFile(bufnr('%'))
+
+Execute(smlnj finds CM file by searching upwards):
+ call ale#test#SetFilename('smlnj/cm/path/to/bar.sml')
+
+ AssertEqual '/testplugin/test/smlnj/cm/sources.cm', ale#handlers#sml#GetCmFile(bufnr('%'))
+
+Execute(smlnj returns '' when no CM file found):
+ call ale#test#SetFilename('smlnj/file/qux.sml')
+
+ AssertEqual '', ale#handlers#sml#GetCmFile(bufnr('%'))
+
+# ----- GetExecutableSmlnjCm & GetExecutableSmlnjFile -----
+
+Execute(CM-project mode enabled when CM file found):
+ call ale#test#SetFilename('smlnj/cm/foo.sml')
+
+ AssertEqual 'sml', ale#handlers#sml#GetExecutableSmlnjCm(bufnr('%'))
+
+Execute(single-file mode disabled when CM file found):
+ call ale#test#SetFilename('smlnj/cm/foo.sml')
+
+ AssertEqual '', ale#handlers#sml#GetExecutableSmlnjFile(bufnr('%'))
+
+Execute(CM-project mode disabled when CM file not found):
+ call ale#test#SetFilename('smlnj/file/qux.sml')
+
+ AssertEqual '', ale#handlers#sml#GetExecutableSmlnjCm(bufnr('%'))
+
+Execute(single-file mode enabled when CM file found):
+ call ale#test#SetFilename('smlnj/file/qux.sml')
+
+ AssertEqual 'sml', ale#handlers#sml#GetExecutableSmlnjFile(bufnr('%'))