File: fptr.tst

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (50 lines) | stat: -rw-r--r-- 1,328 bytes parent folder | download | duplicates (4)
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
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

// <-- ENGLISH IMPOSED -->

//tests on functions pointer usage

funcprot(0);

f=exp
if type(f)<>130 then pause,end
if f(1)<>exp(1) then pause,end
l=list(exp,f,3);
f=l(1);
if type(f)<>130 then pause,end
if f(1)<>exp(1) then pause,end

f=l(2);
if type(f)<>130 then pause,end
if f(1)<>exp(1) then pause,end

l=tlist(['foo','fun'],exp);
f=l.fun;
if type(f)<>130 then pause,end
if f(1)<>exp(1) then pause,end

if l.fun(1)<>exp(1) then pause,end

function y=myf(x),y=exp(x),endfunction
l=tlist(['foo','fun'],myf);
if l.fun(1)<> exp(1) then pause,end


function y=foo(fun,x),y=fun(x),endfunction
if foo(exp,1)<>exp(1) then pause,end


function y=foo(fun,x,y),y=fun(x,y),endfunction
if foo(atan,1,0)<>atan(1,0) then pause,end

function y=foo(fun),y=[],for x=1:3,y=[y,fun(x)],end,endfunction
if foo(exp)<>exp(1:3) then pause,end

l=tlist(['foo','funs'],list(exp,sin,cos));
function y=foo(l),y=[],for k=1:3,y=[y,l.funs(k)(1)],end,endfunction
if or(foo(l)<>[exp(1),sin(1),cos(1)]) then pause,end