diff options
Diffstat (limited to '022arithmetic.cc')
-rw-r--r-- | 022arithmetic.cc | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/022arithmetic.cc b/022arithmetic.cc index 5d1583c4..760aa98d 100644 --- a/022arithmetic.cc +++ b/022arithmetic.cc @@ -36,37 +36,37 @@ case ADD: { :(scenario add_literal) def main [ - 1:number <- add 23, 34 + 1:num <- add 23, 34 ] +mem: storing 57 in location 1 :(scenario add) def main [ - 1:number <- copy 23 - 2:number <- copy 34 - 3:number <- add 1:number, 2:number + 1:num <- copy 23 + 2:num <- copy 34 + 3:num <- add 1:num, 2:num ] +mem: storing 57 in location 3 :(scenario add_multiple) def main [ - 1:number <- add 3, 4, 5 + 1:num <- add 3, 4, 5 ] +mem: storing 12 in location 1 :(scenario add_checks_type) % Hide_errors = true; def main [ - 1:number <- add 2:boolean, 1 + 1:num <- add 2:boolean, 1 ] +error: main: 'add' requires number ingredients, but got '2:boolean' :(scenario add_checks_return_type) % Hide_errors = true; def main [ - 1:address:number <- add 2, 2 + 1:address:num <- add 2, 2 ] -+error: main: 'add' should yield a number, but got '1:address:number' ++error: main: 'add' should yield a number, but got '1:address:num' :(before "End Primitive Recipe Declarations") SUBTRACT, @@ -111,21 +111,21 @@ bool is_raw(const reagent& r) { :(scenario subtract_literal) def main [ - 1:number <- subtract 5, 2 + 1:num <- subtract 5, 2 ] +mem: storing 3 in location 1 :(scenario subtract) def main [ - 1:number <- copy 23 - 2:number <- copy 34 - 3:number <- subtract 1:number, 2:number + 1:num <- copy 23 + 2:num <- copy 34 + 3:num <- subtract 1:num, 2:num ] +mem: storing -11 in location 3 :(scenario subtract_multiple) def main [ - 1:number <- subtract 6, 3, 2 + 1:num <- subtract 6, 3, 2 ] +mem: storing 1 in location 1 @@ -164,21 +164,21 @@ case MULTIPLY: { :(scenario multiply_literal) def main [ - 1:number <- multiply 2, 3 + 1:num <- multiply 2, 3 ] +mem: storing 6 in location 1 :(scenario multiply) def main [ - 1:number <- copy 4 - 2:number <- copy 6 - 3:number <- multiply 1:number, 2:number + 1:num <- copy 4 + 2:num <- copy 6 + 3:num <- multiply 1:num, 2:num ] +mem: storing 24 in location 3 :(scenario multiply_multiple) def main [ - 1:number <- multiply 2, 3, 4 + 1:num <- multiply 2, 3, 4 ] +mem: storing 24 in location 1 @@ -220,21 +220,21 @@ case DIVIDE: { :(scenario divide_literal) def main [ - 1:number <- divide 8, 2 + 1:num <- divide 8, 2 ] +mem: storing 4 in location 1 :(scenario divide) def main [ - 1:number <- copy 27 - 2:number <- copy 3 - 3:number <- divide 1:number, 2:number + 1:num <- copy 27 + 2:num <- copy 3 + 3:num <- divide 1:num, 2:num ] +mem: storing 9 in location 3 :(scenario divide_multiple) def main [ - 1:number <- divide 12, 3, 2 + 1:num <- divide 12, 3, 2 ] +mem: storing 2 in location 1 @@ -288,39 +288,39 @@ case DIVIDE_WITH_REMAINDER: { :(scenario divide_with_remainder_literal) def main [ - 1:number, 2:number <- divide-with-remainder 9, 2 + 1:num, 2:num <- divide-with-remainder 9, 2 ] +mem: storing 4 in location 1 +mem: storing 1 in location 2 :(scenario divide_with_remainder) def main [ - 1:number <- copy 27 - 2:number <- copy 11 - 3:number, 4:number <- divide-with-remainder 1:number, 2:number + 1:num <- copy 27 + 2:num <- copy 11 + 3:num, 4:num <- divide-with-remainder 1:num, 2:num ] +mem: storing 2 in location 3 +mem: storing 5 in location 4 :(scenario divide_with_decimal_point) def main [ - 1:number <- divide 5, 2 + 1:num <- divide 5, 2 ] +mem: storing 2.5 in location 1 :(scenario divide_by_zero) def main [ - 1:number <- divide 4, 0 + 1:num <- divide 4, 0 ] +mem: storing inf in location 1 :(scenario divide_by_zero_2) % Hide_errors = true; def main [ - 1:number <- divide-with-remainder 4, 0 + 1:num <- divide-with-remainder 4, 0 ] # integer division can't return floating-point infinity -+error: main: divide by zero in '1:number <- divide-with-remainder 4, 0' ++error: main: divide by zero in '1:num <- divide-with-remainder 4, 0' //: Bitwise shifts @@ -365,33 +365,33 @@ case SHIFT_LEFT: { :(scenario shift_left_by_zero) def main [ - 1:number <- shift-left 1, 0 + 1:num <- shift-left 1, 0 ] +mem: storing 1 in location 1 :(scenario shift_left_1) def main [ - 1:number <- shift-left 1, 4 + 1:num <- shift-left 1, 4 ] +mem: storing 16 in location 1 :(scenario shift_left_2) def main [ - 1:number <- shift-left 3, 2 + 1:num <- shift-left 3, 2 ] +mem: storing 12 in location 1 :(scenario shift_left_by_negative) % Hide_errors = true; def main [ - 1:number <- shift-left 3, -1 + 1:num <- shift-left 3, -1 ] -+error: main: second ingredient can't be negative in '1:number <- shift-left 3, -1' ++error: main: second ingredient can't be negative in '1:num <- shift-left 3, -1' :(scenario shift_left_ignores_fractional_part) def main [ - 1:number <- divide 3, 2 - 2:number <- shift-left 1:number, 1 + 1:num <- divide 3, 2 + 2:num <- shift-left 1:num, 1 ] +mem: storing 2 in location 2 @@ -436,33 +436,33 @@ case SHIFT_RIGHT: { :(scenario shift_right_by_zero) def main [ - 1:number <- shift-right 1, 0 + 1:num <- shift-right 1, 0 ] +mem: storing 1 in location 1 :(scenario shift_right_1) def main [ - 1:number <- shift-right 1024, 1 + 1:num <- shift-right 1024, 1 ] +mem: storing 512 in location 1 :(scenario shift_right_2) def main [ - 1:number <- shift-right 3, 1 + 1:num <- shift-right 3, 1 ] +mem: storing 1 in location 1 :(scenario shift_right_by_negative) % Hide_errors = true; def main [ - 1:number <- shift-right 4, -1 + 1:num <- shift-right 4, -1 ] -+error: main: second ingredient can't be negative in '1:number <- shift-right 4, -1' ++error: main: second ingredient can't be negative in '1:num <- shift-right 4, -1' :(scenario shift_right_ignores_fractional_part) def main [ - 1:number <- divide 3, 2 - 2:number <- shift-right 1:number, 1 + 1:num <- divide 3, 2 + 2:num <- shift-right 1:num, 1 ] +mem: storing 0 in location 2 @@ -502,25 +502,25 @@ case AND_BITS: { :(scenario and_bits_1) def main [ - 1:number <- and-bits 8, 3 + 1:num <- and-bits 8, 3 ] +mem: storing 0 in location 1 :(scenario and_bits_2) def main [ - 1:number <- and-bits 3, 2 + 1:num <- and-bits 3, 2 ] +mem: storing 2 in location 1 :(scenario and_bits_3) def main [ - 1:number <- and-bits 14, 3 + 1:num <- and-bits 14, 3 ] +mem: storing 2 in location 1 :(scenario and_bits_negative) def main [ - 1:number <- and-bits -3, 4 + 1:num <- and-bits -3, 4 ] +mem: storing 4 in location 1 @@ -560,19 +560,19 @@ case OR_BITS: { :(scenario or_bits_1) def main [ - 1:number <- or-bits 3, 8 + 1:num <- or-bits 3, 8 ] +mem: storing 11 in location 1 :(scenario or_bits_2) def main [ - 1:number <- or-bits 3, 10 + 1:num <- or-bits 3, 10 ] +mem: storing 11 in location 1 :(scenario or_bits_3) def main [ - 1:number <- or-bits 4, 6 + 1:num <- or-bits 4, 6 ] +mem: storing 6 in location 1 @@ -612,19 +612,19 @@ case XOR_BITS: { :(scenario xor_bits_1) def main [ - 1:number <- xor-bits 3, 8 + 1:num <- xor-bits 3, 8 ] +mem: storing 11 in location 1 :(scenario xor_bits_2) def main [ - 1:number <- xor-bits 3, 10 + 1:num <- xor-bits 3, 10 ] +mem: storing 9 in location 1 :(scenario xor_bits_3) def main [ - 1:number <- xor-bits 4, 6 + 1:num <- xor-bits 4, 6 ] +mem: storing 2 in location 1 @@ -663,25 +663,25 @@ case FLIP_BITS: { :(scenario flip_bits_zero) def main [ - 1:number <- flip-bits 0 + 1:num <- flip-bits 0 ] +mem: storing -1 in location 1 :(scenario flip_bits_negative) def main [ - 1:number <- flip-bits -1 + 1:num <- flip-bits -1 ] +mem: storing 0 in location 1 :(scenario flip_bits_1) def main [ - 1:number <- flip-bits 3 + 1:num <- flip-bits 3 ] +mem: storing -4 in location 1 :(scenario flip_bits_2) def main [ - 1:number <- flip-bits 12 + 1:num <- flip-bits 12 ] +mem: storing -13 in location 1 @@ -710,7 +710,7 @@ case ROUND: { :(scenario round_to_nearest_integer) def main [ - 1:number <- round 12.2 + 1:num <- round 12.2 ] +mem: storing 12 in location 1 |