MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

update tco spec

+70 -1
+69
examples/spec/tco.js
··· 70 70 } 71 71 test('tail lastElement', lastElement([1, 2, 3, 4, 5]), 5); 72 72 73 + function ternaryBothBare(n) { 74 + return n <= 0 ? ternaryBothBare_done(n) : ternaryBothBare(n - 1); 75 + } 76 + function ternaryBothBare_done(_) { 77 + return 'done'; 78 + } 79 + test('ternary both bare calls', ternaryBothBare(100000), 'done'); 80 + 81 + function ternaryThenBinop(n) { 82 + return n <= 0 ? identity(0) + 1 : ternaryThenBinop(n - 1); 83 + } 84 + function identity(x) { 85 + return x; 86 + } 87 + test('ternary then-branch binop', ternaryThenBinop(5), 1); 88 + 89 + function ternaryElseBinop(n) { 90 + return n <= 0 ? identity(42) : identity(n) * 2; 91 + } 92 + test('ternary else-branch binop', ternaryElseBinop(0), 42); 93 + test('ternary else-branch binop non-zero', ternaryElseBinop(3), 6); 94 + 95 + function ternaryBothBinop(n) { 96 + return n <= 0 ? identity(10) + 5 : identity(n) - 1; 97 + } 98 + test('ternary both branches binop', ternaryBothBinop(0), 15); 99 + test('ternary both branches binop non-zero', ternaryBothBinop(7), 6); 100 + 101 + function ternaryNestedArith(n) { 102 + return n <= 0 ? (identity(2) + 3) * identity(4) : ternaryNestedArith(n - 1); 103 + } 104 + test('ternary nested arith in then', ternaryNestedArith(5), 20); 105 + 106 + function ternaryParenBareCall(n) { 107 + return n <= 0 ? ternaryParenBareCall_end() : ternaryParenBareCall(n - 1); 108 + } 109 + function ternaryParenBareCall_end() { 110 + return 'end'; 111 + } 112 + test('ternary paren bare call', ternaryParenBareCall(100000), 'end'); 113 + 114 + function ternaryCallWithBinopArg(n) { 115 + return n <= 0 ? identity(2 + 3) : ternaryCallWithBinopArg(n - 1); 116 + } 117 + test('ternary call with binop arg', ternaryCallWithBinopArg(100000), 5); 118 + 119 + function ternaryNested(n, branch) { 120 + return branch === 0 ? ternaryNested_a(n) : branch === 1 ? ternaryNested_b(n) : ternaryNested_c(n); 121 + } 122 + function ternaryNested_a(_) { 123 + return 'a'; 124 + } 125 + function ternaryNested_b(_) { 126 + return 'b'; 127 + } 128 + function ternaryNested_c(_) { 129 + return 'c'; 130 + } 131 + test('nested ternary branch 0', ternaryNested(1, 0), 'a'); 132 + test('nested ternary branch 1', ternaryNested(1, 1), 'b'); 133 + test('nested ternary branch 2', ternaryNested(1, 2), 'c'); 134 + 135 + function ternaryNestedUnsafe(n, branch) { 136 + return branch === 0 ? identity(n) + 1 : branch === 1 ? identity(n) : identity(n) * 3; 137 + } 138 + test('nested ternary unsafe then', ternaryNestedUnsafe(5, 0), 6); 139 + test('nested ternary safe middle', ternaryNestedUnsafe(5, 1), 5); 140 + test('nested ternary unsafe else', ternaryNestedUnsafe(5, 2), 15); 141 + 73 142 summary();
+1 -1
meson/ant.version
··· 1 - 0.5.3 1 + 0.6.0