1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
preproc_constants
assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, "const string")
# Test global constants can be seen within functions
function test_global()
global CONST_INT1
global CONST_DOUBLE3
global CONST_BOOL1
global CONST_CHAR
global CONST_STRING1
global CONST_STRING4
assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, "const string")
if (false)
# Currently SWIG/Octave truncates at a zero byte in a string constant.
# strings support embedded zero bytes so this ought to work, but is an
# uncommon case.
assert(CONST_STRING4, "zer\0zer\0")
else
# Test the current behaviour for now to ensure this testcase gets updated
# when this gets fixed, and also to check we don't mangle the value in some
# other way.
assert(CONST_STRING4, "zer")
endif
endfunction
test_global
|