Units: Move NULL, OK, and FAIL to helpers.moon. #982

This commit is contained in:
Scott Prager 2014-07-22 16:00:16 -04:00 committed by Justin M. Keyes
parent 5f9fb6ed64
commit c3b9f863ea
6 changed files with 14 additions and 21 deletions

View File

@ -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' 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 -- define a basic interface to garray. We could make it a lot nicer by
-- constructing a moonscript class wrapper around garray. It could for -- constructing a moonscript class wrapper around garray. It could for
-- example associate ga_clear_strings to the underlying garray cdata if the -- example associate ga_clear_strings to the underlying garray cdata if the

View File

@ -108,6 +108,12 @@ vim_init = ->
os.mch_early_init! os.mch_early_init!
vim_init_called = true vim_init_called = true
-- C constants.
NULL = ffi.cast 'void*', 0
OK = 1
FAIL = 0
return { return {
cimport: cimport cimport: cimport
cppimport: cppimport cppimport: cppimport
@ -119,4 +125,7 @@ return {
cstr: cstr cstr: cstr
to_cstr: to_cstr to_cstr: to_cstr
vim_init: vim_init vim_init: vim_init
NULL: NULL
OK: OK
FAIL: FAIL
} }

View File

@ -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' require 'lfs'
env = cimport './src/nvim/os/os.h' env = cimport './src/nvim/os/os.h'
NULL = ffi.cast 'void*', 0
describe 'env function', -> describe 'env function', ->
os_setenv = (name, value, override) -> os_setenv = (name, value, override) ->

View File

@ -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 'lfs'
require 'bit' require 'bit'
fs = cimport './src/nvim/os/os.h' fs = cimport './src/nvim/os/os.h'
-- TODO(aktau): define these constants "better"
FAIL = 0
OK = 1
cppimport 'sys/stat.h' cppimport 'sys/stat.h'
cppimport 'sys/fcntl.h' cppimport 'sys/fcntl.h'
cppimport 'sys/errno.h' cppimport 'sys/errno.h'

View File

@ -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' users = cimport './src/nvim/os/os.h', 'unistd.h'
NULL = ffi.cast 'void*', 0
OK = 1
FAIL = 0
garray_new = () -> garray_new = () ->
ffi.new 'garray_T[1]' ffi.new 'garray_T[1]'

View File

@ -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' require 'lfs'
path = cimport './src/nvim/path.h' path = cimport './src/nvim/path.h'
-- import constants parsed by ffi -- import constants parsed by ffi
{:kEqualFiles, :kDifferentFiles, :kBothFilesMissing, :kOneFileMissing, :kEqualFileNames} = path {:kEqualFiles, :kDifferentFiles, :kBothFilesMissing, :kOneFileMissing, :kEqualFileNames} = path
NULL = ffi.cast 'void*', 0
OK = 1
FAIL = 0
describe 'path function', -> describe 'path function', ->
describe 'path_full_dir_name', -> describe 'path_full_dir_name', ->