1; 2; Alain C., 22 June 2012 3; 4; More systematic tests on EXECUTE 5; 6pro PRO_MY_PRO, x, y 7; 8y=x+5 9; 10end 11; 12function FUNC_MY_FUNC, x 13; 14return, x+5 15; 16end 17; 18; --------------------- 19; old (corrected) bug 20; 21pro TEST_BUG_3441031, cumul_errors, test=test 22;; 23errors=0 24; 25; this caused a segfault, we don't care of the result 26; 27res=EXECUTE("a = STRJOIN(STRSPLIT((['a'])[1],'a'),'a')") 28; 29if (res EQ 1) then ERRORS_ADD, errors, 'Case STRJOIN' 30; 31BANNER_FOR_TESTSUITE, 'TEST_BUG_3441031', errors, /short 32ERRORS_CUMUL, cumul_errors, errors 33if KEYWORD_set(test) then STOP 34; 35end 36; 37; --------------------- 38; another old (corrected) bug 39; 40; by Sylwester Arabas <slayoo@igf.fuw.edu.pl> 41pro TEST_EXECUTE_OLD, cumul_errors, test=test 42; 43errors=0 44; 45res=EXECUTE('print, EXECUTE([''''])') 46; 47txt='EXECUTE should not accept array arguments' 48if (res EQ 1) then ERRORS_ADD, errors, txt 49; 50BANNER_FOR_TESTSUITE, 'TEST_EXECUTE_OLD', errors, /short 51ERRORS_CUMUL, cumul_errors, errors 52if KEYWORD_set(test) then STOP 53; 54end 55; 56; -------------------- 57; 58; All the tests in this procedure should fail 59; (EXECUTE() should return 0) 60; 61pro TEST_EXECUTE_MISSING, cumul_errors, help=help, test=test, $ 62 verbose=verbose 63; 64if KEYWORD_SET(help) then begin 65 print, 'pro TEST_EXECUTE_MISSING, cumul_errors, help=help, test=test, $' 66 print, ' verbose=verbose' 67 return 68endif 69; 70errors = 0 71; 72status=EXECUTE('z=MY_UNKNOW_FUNCTION()') 73if (status EQ 1) then ERRORS_ADD, errors, 'function without param' 74; 75status=EXECUTE('z=MY_UNKNOW_FUNCTION(1, 2)') 76if (status EQ 1) then ERRORS_ADD, errors, 'function with param' 77; 78status=EXECUTE('MY_UNKNOW_PROCEDURE') 79if (status EQ 1) then ERRORS_ADD, errors, 'procedure without param' 80; 81status=EXECUTE('MY_UNKNOW_PROCEDURE, findgen(10)') 82if (status EQ 1) then ERRORS_ADD, errors, 'procedure with param' 83; 84; ----- final ---- 85; 86BANNER_FOR_TESTSUITE, 'TEST_EXECUTE_MISSING', errors, /short 87ERRORS_CUMUL, cumul_errors, errors 88if KEYWORD_set(test) then STOP 89; 90end 91; 92; -------------------- 93; 94pro TEST_BASIC_EXECUTE, cumul_errors, help=help, test=test, $ 95 verbose=verbose 96; 97if KEYWORD_SET(help) then begin 98 print, 'pro TEST_BASIC_EXECUTE, cumul_errors, help=help, test=test, $' 99 print, ' verbose=verbose' 100 return 101endif 102; 103errors = 0 104tolerance=1e-5 105; 106; internal intrinsic function, single value 107com='a=COS(!pi)' 108expected=-1. 109status=EXECUTE(com) 110; 111if (status NE 1) then ERRORS_ADD, errors, 'Cos Status' 112if (ABS(a-expected) GT tolerance) then ERRORS_ADD, errors, 'Cos value' 113if KEYWORD_SET(verbose) then print, com, status, a, expected 114; 115; internal intrinsic function, array 116; 117com='a=COS(REPLICATE(!pi,10))' 118expected=REPLICATE(-1.,10) 119status=EXECUTE(com) 120; 121if (status NE 1) then ERRORS_ADD, errors, 'Cos Status (arr)' 122if (TOTAL(ABS(a-expected)) GT tolerance) then $ 123 ERRORS_ADD, errors, 'Cos Value (arr)' 124if KEYWORD_SET(verbose) then print, com, status, a, expected 125; 126; internal intrinsic procedure (better idea welcome !) 127; 128; REMOVED AS MAY STOP OR CRASH TESTS! 129;com='plot, SIN(!pi*findgen(100)/10.)' 130;status=EXECUTE(com) 131; 132;if (status NE 1) then ERRORS_ADD, errors, 'Sin Status' 133; 134; external function, single element 135; 136com='a=FUNC_MY_FUNC(12.)' 137expected=17. 138status=EXECUTE(com) 139; 140if (status NE 1) then ERRORS_ADD, errors, 'FUNC_MY_FUNC Status' 141if (ABS(a-expected) GT tolerance) then $ 142 ERRORS_ADD, errors, 'FUNC_MY_FUNC valeur 12' 143if KEYWORD_SET(verbose) then print, com, status, a, expected 144; 145; external function, value 2D array 146; 147com='a=FUNC_MY_FUNC(REPLICATE(-5,12,3))' 148expected=REPLICATE(0.,12,3) 149status=EXECUTE(com) 150; 151if (status NE 1) then ERRORS_ADD, errors, 'FUNC_MY_FUNC Status (arr)' 152if (TOTAL(ABS(a-expected)) GT tolerance) then $ 153 ERRORS_ADD, errors, 'FUNC_MY_FUNC valeur (arr)' 154if KEYWORD_SET(verbose) then print, com, status, a, expected 155; 156; external function, named' 2D array 157; 158input=REPLICATE(-5,12,3) 159com='a=FUNC_MY_FUNC(input)' 160expected=input+5. 161status=EXECUTE(com) 162; 163if (status NE 1) then ERRORS_ADD, errors, 'FUNC_MY_FUNC Status (input)' 164if (TOTAL(ABS(a-expected)) GT tolerance) then $ 165 ERRORS_ADD, errors, 'FUNC_MY_FUNC valeur (input)' 166if KEYWORD_SET(verbose) then print, com, status, a, expected 167; 168; ----- final ---- 169; 170BANNER_FOR_TESTSUITE, 'TEST_BASIC_EXECUTE', errors, /short 171ERRORS_CUMUL, cumul_errors, errors 172if KEYWORD_set(test) then STOP 173; 174end 175; 176; ---------------------------------------------------- 177; 178pro TEST_EXECUTE, help=help, test=test, no_exit=no_exit, verbose=verbose 179; 180if KEYWORD_SET(help) then begin 181 print, 'pro TEST_EXECUTE, help=help, test=test, no_exit=no_exit, verbose=verbose' 182 return 183endif; 184; 185TEST_BUG_3441031, cumul_errors 186TEST_EXECUTE_OLD, cumul_errors 187; 188TEST_BASIC_EXECUTE, cumul_errors, test=test, verbose=verbose 189; 190TEST_EXECUTE_MISSING, cumul_errors 191; 192; ----------------- final message ---------- 193; 194BANNER_FOR_TESTSUITE, 'TEST_EXECUTE', cumul_errors 195; 196if (cumul_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1 197; 198if KEYWORD_SET(test) then STOP 199 200; 201end 202