summaryrefslogtreecommitdiff
path: root/modules/functions/tests/unit_tests/exec.tst
blob: 37676c0beb0adb2d1a9e7a7bba7c205f06f647ee (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2009 - DIGITEO - Allan CORNET
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

tab_ref = [
"世界您好",
"азеазея",
"ハロー・ワールド",
"เฮลโลเวิลด์",
"حريات وحقوق",
"תוכנית"];

str_exec = 'disp(''OK'');';

for i = 1 : size(tab_ref,'*')
  mkdir(TMPDIR + filesep() + tab_ref(i));
  fd = mopen(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce','wt');
  mputl(str_exec,fd);
  mclose(fd);
  exec(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce');
  mdelete(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce');
  rmdir(TMPDIR + filesep() + tab_ref(i));
end  

// create a script file
mputl('a=1;b=2',TMPDIR+'/myscript')
// execute it
exec(TMPDIR+'/myscript')
if isdef('a')<> %t then pause,end
if isdef('b')<> %t then pause,end
if a <> 1 then pause,end
if b <> 2 then pause,end


// create a function
deff('y=foo(x)','a=x+1;y=a^2');
clear a b
// call the function
k = foo(1);
if isdef('k')<> %t then pause,end
if isdef('a')<> %f then pause,end
if k <> 4 then pause,end

x=4; //create x to make it known by the script foo
clear k y
exec(foo);
if isdef('y')<> %t then pause,end
if y <> 25 then pause,end