PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme_nogl_func_base.m
  2. # test whether module can be loaded in a function
  3. # before the base context (no global cvar)
  4. 1;
  5. ##### BEGIN TEST #####
  6. function func
  7. example -noglobal
  8. assert(example.cvar.ivar == example.ifunc())
  9. endfunction
  10. # test loading in a function
  11. func
  12. # test a second time to check everything works
  13. func
  14. # test that everything works from the base context
  15. example -noglobal
  16. assert(example.cvar.ivar == example.ifunc())
  17. ##### END TEST #####
  18. # clearing a module results in a segfault for Octave <= 3.0.*
  19. # (tested on Octave 3.0.5), so skip the following test
  20. try
  21. vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
  22. catch
  23. vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
  24. end_try_catch
  25. assert(length(vers) >= 2);
  26. if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
  27. disp("skipping 'clear all' test");
  28. return
  29. endif
  30. clear all;
  31. ##### BEGIN TEST #####
  32. function func
  33. example -noglobal
  34. assert(example.cvar.ivar == example.ifunc())
  35. endfunction
  36. # test loading in a function
  37. func
  38. # test a second time to check everything works
  39. func
  40. # test that everything works from the base context
  41. example -noglobal
  42. assert(example.cvar.ivar == example.ifunc())
  43. ##### END TEST #####