| 1 |
#include "tads.h" |
| 2 |
#include "t3.h" |
| 3 |
|
| 4 |
preinit() { } |
| 5 |
|
| 6 |
f1(x) |
| 7 |
{ |
| 8 |
"This is f1(<<x>>)\n"; |
| 9 |
return x; |
| 10 |
|
| 11 |
} |
| 12 |
|
| 13 |
main(args) |
| 14 |
{ |
| 15 |
local x; |
| 16 |
|
| 17 |
"is in:\b"; |
| 18 |
|
| 19 |
/* is in - short-circuit */ |
| 20 |
x = 3; |
| 21 |
if (x is in (f1(1), f1(2), f1(3), f1(4), f1(5))) |
| 22 |
"Found it!\n"; |
| 23 |
else |
| 24 |
"Didn't find it!\n"; |
| 25 |
|
| 26 |
/* is in - not found */ |
| 27 |
if (x is in (f1(10), f1(11), f1(12), f1(13), f1(14))) |
| 28 |
"Found it!\n"; |
| 29 |
else |
| 30 |
"Didn't find it!\n"; |
| 31 |
|
| 32 |
/* is in - found as constant in middle */ |
| 33 |
if (3 is in (f1(1), f1(2), 3, f1(4))) |
| 34 |
"Found it!\n"; |
| 35 |
else |
| 36 |
"Didn't find it!\n"; |
| 37 |
|
| 38 |
/* found as constant in first position */ |
| 39 |
if (3 is in (3, f1(1), f1(2), f1(4))) |
| 40 |
"Found it!\n"; |
| 41 |
else |
| 42 |
"Didn't find it!\n"; |
| 43 |
|
| 44 |
/* found as constant in second position */ |
| 45 |
if (3 is in (f1(1), 3, f1(4), f1(5))) |
| 46 |
"Found it!\n"; |
| 47 |
else |
| 48 |
"Didn't find it!\n"; |
| 49 |
|
| 50 |
/* found as constant in last */ |
| 51 |
if (3 is in (f1(1), f1(2), 3)) |
| 52 |
"Found it!\n"; |
| 53 |
else |
| 54 |
"Didn't find it!\n"; |
| 55 |
|
| 56 |
/* found as constant in second-to-last position */ |
| 57 |
if (3 is in (f1(1), f1(2), f1(4), 3, f1(5))) |
| 58 |
"Found it!\n"; |
| 59 |
else |
| 60 |
"Didn't find it!\n"; |
| 61 |
|
| 62 |
/* found as constant among other constants */ |
| 63 |
if (3 is in (f1(1), 2, 3, 4, f1(5))) |
| 64 |
"Found it!\n"; |
| 65 |
else |
| 66 |
"Didn't find it!\n"; |
| 67 |
|
| 68 |
/* found, all constants */ |
| 69 |
if (3 is in (1, 2, 3, 4, 5)) |
| 70 |
"Found it!\n"; |
| 71 |
else |
| 72 |
"Didn't find it!\n"; |
| 73 |
|
| 74 |
/* not found, all constants */ |
| 75 |
if (3 is in (1, 2, 4, 5)) |
| 76 |
"Found it!\n"; |
| 77 |
else |
| 78 |
"Didn't find it!\n"; |
| 79 |
|
| 80 |
/* -------------------------------------------------------------------- */ |
| 81 |
"\bnot in:\b"; |
| 82 |
|
| 83 |
/* not in - short-circuit */ |
| 84 |
x = 3; |
| 85 |
if (x not in (f1(1), f1(2), f1(3), f1(4), f1(5))) |
| 86 |
"Didn't find it!\n"; |
| 87 |
else |
| 88 |
"Found it!\n"; |
| 89 |
|
| 90 |
/* not in - not found */ |
| 91 |
if (x not in (f1(10), f1(11), f1(12), f1(13), f1(14))) |
| 92 |
"Didn't find it!\n"; |
| 93 |
else |
| 94 |
"Found it!\n"; |
| 95 |
|
| 96 |
/* not in - found as constant in middle */ |
| 97 |
if (3 not in (f1(1), f1(2), 3, f1(4))) |
| 98 |
"Didn't find it!\n"; |
| 99 |
else |
| 100 |
"Found it!\n"; |
| 101 |
|
| 102 |
/* found as constant in first position */ |
| 103 |
if (3 not in (3, f1(1), f1(2), f1(4))) |
| 104 |
"Didn't find it!\n"; |
| 105 |
else |
| 106 |
"Found it!\n"; |
| 107 |
|
| 108 |
/* found as constant in second position */ |
| 109 |
if (3 not in (f1(1), 3, f1(4), f1(5))) |
| 110 |
"Didn't find it!\n"; |
| 111 |
else |
| 112 |
"Found it!\n"; |
| 113 |
|
| 114 |
/* found as constant in last */ |
| 115 |
if (3 not in (f1(1), f1(2), 3)) |
| 116 |
"Didn't find it!\n"; |
| 117 |
else |
| 118 |
"Found it!\n"; |
| 119 |
|
| 120 |
/* found as constant in second-to-last position */ |
| 121 |
if (3 not in (f1(1), f1(2), f1(4), 3, f1(5))) |
| 122 |
"Didn't find it!\n"; |
| 123 |
else |
| 124 |
"Found it!\n"; |
| 125 |
|
| 126 |
/* found as constant among other constants */ |
| 127 |
if (3 not in (f1(1), 2, 3, 4, f1(5))) |
| 128 |
"Didn't find it!\n"; |
| 129 |
else |
| 130 |
"Found it!\n"; |
| 131 |
|
| 132 |
/* found, all constants */ |
| 133 |
if (3 not in (1, 2, 3, 4, 5)) |
| 134 |
"Didn't find it!\n"; |
| 135 |
else |
| 136 |
"Found it!\n"; |
| 137 |
|
| 138 |
/* not found, all constants */ |
| 139 |
if (3 not in (1, 2, 4, 5)) |
| 140 |
"Didn't find it!\n"; |
| 141 |
else |
| 142 |
"Found it!\n"; |
| 143 |
} |