PageRenderTime 29ms CodeModel.GetById 2ms app.highlight 22ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/octave/module_load/runme_nogl_func_base.m

#
Objective C | 55 lines | 43 code | 12 blank | 0 comment | 10 complexity | 3d6aa19a9a02a039f9dda9dcbd6c13dd MD5 | raw file
 1# file: runme_nogl_func_base.m
 2
 3# test whether module can be loaded in a function
 4# before the base context (no global cvar)
 5
 61;
 7
 8##### BEGIN TEST #####
 9function func
10  example -noglobal
11  assert(example.cvar.ivar == example.ifunc())
12endfunction
13
14# test loading in a function
15func
16
17# test a second time to check everything works
18func
19
20# test that everything works from the base context
21example -noglobal
22assert(example.cvar.ivar == example.ifunc())
23##### END TEST #####
24
25# clearing a module results in a segfault for Octave <= 3.0.*
26# (tested on Octave 3.0.5), so skip the following test
27try
28  vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
29catch
30  vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
31end_try_catch
32assert(length(vers) >= 2);
33if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
34  disp("skipping 'clear all' test");
35  return
36endif
37
38clear all;
39
40##### BEGIN TEST #####
41function func
42  example -noglobal
43  assert(example.cvar.ivar == example.ifunc())
44endfunction
45
46# test loading in a function
47func
48
49# test a second time to check everything works
50func
51
52# test that everything works from the base context
53example -noglobal
54assert(example.cvar.ivar == example.ifunc())
55##### END TEST #####