|
| 1 | + |
| 2 | +#include "../testTools.h" |
| 3 | +#include "../../DFPSR/api/mediaMachineAPI.h" |
| 4 | + |
| 5 | +START_TEST(CompilerFront) |
| 6 | + { |
| 7 | + MediaMachine testMachine = machine_create( |
| 8 | + U"BEGIN: addFixedPoint\n" |
| 9 | + U" INPUT: FixedPoint, left\n" |
| 10 | + U" INPUT: FixedPoint, right\n" |
| 11 | + U" OUTPUT: FixedPoint, result\n" |
| 12 | + U" ADD: result, left, right\n" |
| 13 | + U"END:\n" |
| 14 | + U"BEGIN: addEight\n" |
| 15 | + U" INPUT: FixedPoint, x\n" |
| 16 | + U" OUTPUT: FixedPoint, result\n" |
| 17 | + U" CALL: addFixedPoint, result, x, 8\n" |
| 18 | + U"END:\n" |
| 19 | + ); |
| 20 | + ASSERT(machine_exists(testMachine)); |
| 21 | + { |
| 22 | + int32_t addMethod = machine_findMethod(testMachine, U"addFixedPoint"); |
| 23 | + ASSERT_NOT_EQUAL(addMethod, -1); |
| 24 | + machine_setInputByIndex(testMachine, addMethod, 0, FixedPoint::fromWhole(1200)); |
| 25 | + machine_setInputByIndex(testMachine, addMethod, 1, FixedPoint::fromWhole(34)); |
| 26 | + machine_executeMethod(testMachine, addMethod); |
| 27 | + ASSERT_EQUAL(machine_getFixedPointOutputByIndex(testMachine, addMethod, 0), FixedPoint::fromWhole(1234)); |
| 28 | + } |
| 29 | + { |
| 30 | + MediaMethod addMethod = machine_getMethod(testMachine, U"addFixedPoint", -1); |
| 31 | + FixedPoint result; |
| 32 | + addMethod(FixedPoint::fromWhole(1200), FixedPoint::fromWhole(34))(result); |
| 33 | + ASSERT_EQUAL(result, FixedPoint::fromWhole(1234)); |
| 34 | + } |
| 35 | + { |
| 36 | + int32_t addEightMethod = machine_findMethod(testMachine, U"addEight"); |
| 37 | + ASSERT_NOT_EQUAL(addEightMethod, -1); |
| 38 | + machine_setInputByIndex(testMachine, addEightMethod, 0, FixedPoint::fromWhole(120)); |
| 39 | + machine_executeMethod(testMachine, addEightMethod); |
| 40 | + ASSERT_EQUAL(machine_getFixedPointOutputByIndex(testMachine, addEightMethod, 0), FixedPoint::fromWhole(128)); |
| 41 | + } |
| 42 | + } |
| 43 | +END_TEST |
0 commit comments