aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/unit/garray_spec.moon5
-rw-r--r--test/unit/helpers.moon9
-rw-r--r--test/unit/os/env_spec.moon4
-rw-r--r--test/unit/os/fs_spec.moon6
-rw-r--r--test/unit/os/users_spec.moon6
-rw-r--r--test/unit/path_spec.moon5
6 files changed, 14 insertions, 21 deletions
diff --git a/test/unit/garray_spec.moon b/test/unit/garray_spec.moon
index 245245e33b..5d4dbe690c 100644
--- a/test/unit/garray_spec.moon
+++ b/test/unit/garray_spec.moon
@@ -1,10 +1,7 @@
-{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
+{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr, :NULL} = require 'test.unit.helpers'
garray = cimport './src/nvim/garray.h'
--- handy constants
-NULL = ffi.cast 'void*', 0
-
-- define a basic interface to garray. We could make it a lot nicer by
-- constructing a moonscript class wrapper around garray. It could for
-- example associate ga_clear_strings to the underlying garray cdata if the
diff --git a/test/unit/helpers.moon b/test/unit/helpers.moon
index 8064537d93..f533b9a1c6 100644
--- a/test/unit/helpers.moon
+++ b/test/unit/helpers.moon
@@ -108,6 +108,12 @@ vim_init = ->
os.mch_early_init!
vim_init_called = true
+-- C constants.
+NULL = ffi.cast 'void*', 0
+
+OK = 1
+FAIL = 0
+
return {
cimport: cimport
cppimport: cppimport
@@ -119,4 +125,7 @@ return {
cstr: cstr
to_cstr: to_cstr
vim_init: vim_init
+ NULL: NULL
+ OK: OK
+ FAIL: FAIL
}
diff --git a/test/unit/os/env_spec.moon b/test/unit/os/env_spec.moon
index 43fd663d9a..ab5b940a58 100644
--- a/test/unit/os/env_spec.moon
+++ b/test/unit/os/env_spec.moon
@@ -1,10 +1,8 @@
-{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
+{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr, :NULL} = require 'test.unit.helpers'
require 'lfs'
env = cimport './src/nvim/os/os.h'
-NULL = ffi.cast 'void*', 0
-
describe 'env function', ->
os_setenv = (name, value, override) ->
diff --git a/test/unit/os/fs_spec.moon b/test/unit/os/fs_spec.moon
index 6d87cb95df..52f587d6f9 100644
--- a/test/unit/os/fs_spec.moon
+++ b/test/unit/os/fs_spec.moon
@@ -1,13 +1,9 @@
-{:cimport, :cppimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
+{:cimport, :cppimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr, :OK, :FAIL} = require 'test.unit.helpers'
require 'lfs'
require 'bit'
fs = cimport './src/nvim/os/os.h'
--- TODO(aktau): define these constants "better"
-FAIL = 0
-OK = 1
-
cppimport 'sys/stat.h'
cppimport 'sys/fcntl.h'
cppimport 'sys/errno.h'
diff --git a/test/unit/os/users_spec.moon b/test/unit/os/users_spec.moon
index d6b618eb8c..35c23ccc6f 100644
--- a/test/unit/os/users_spec.moon
+++ b/test/unit/os/users_spec.moon
@@ -1,11 +1,7 @@
-{:cimport, :internalize, :eq, :ffi, :lib, :cstr} = require 'test.unit.helpers'
+{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :NULL, :OK, :FAIL} = require 'test.unit.helpers'
users = cimport './src/nvim/os/os.h', 'unistd.h'
-NULL = ffi.cast 'void*', 0
-OK = 1
-FAIL = 0
-
garray_new = () ->
ffi.new 'garray_T[1]'
diff --git a/test/unit/path_spec.moon b/test/unit/path_spec.moon
index 4a4170e463..0786fe6c01 100644
--- a/test/unit/path_spec.moon
+++ b/test/unit/path_spec.moon
@@ -1,13 +1,10 @@
-{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
+{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr, :NULL, :OK, :FAIL} = require 'test.unit.helpers'
require 'lfs'
path = cimport './src/nvim/path.h'
-- import constants parsed by ffi
{:kEqualFiles, :kDifferentFiles, :kBothFilesMissing, :kOneFileMissing, :kEqualFileNames} = path
-NULL = ffi.cast 'void*', 0
-OK = 1
-FAIL = 0
describe 'path function', ->
describe 'path_full_dir_name', ->