diff --git a/test/ability_volt_absorb.c b/test/ability_volt_absorb.c index 18902eaa20..8a3c21ef6a 100644 --- a/test/ability_volt_absorb.c +++ b/test/ability_volt_absorb.c @@ -80,8 +80,7 @@ DOUBLE_BATTLE_TEST("Volt Absorb does not stop Electric Typed Explosion from dama MESSAGE("Jolteon restored HP using its Volt Absorb!"); HP_BAR(playerRight, captureDamage: &results->damage1); HP_BAR(opponentRight, captureDamage: &results->damage2); - } - FINALLY { + } THEN { EXPECT_NE(results[0].damage1, 0); EXPECT_NE(results[0].damage2, 0); } diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 4662e9f25c..6fd58fe824 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -183,4 +183,4 @@ SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP by 25% of its max HP(30 } #undef TEST_HP -#undef MAX_HP \ No newline at end of file +#undef MAX_HP diff --git a/test/move_effect_bide.c b/test/move_effect_bide.c index 3a5c387353..0b0e184087 100644 --- a/test/move_effect_bide.c +++ b/test/move_effect_bide.c @@ -28,7 +28,7 @@ SINGLE_BATTLE_TEST("Bide deals twice the taken damage over two turns") MESSAGE("Wobbuffet unleashed energy!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_BIDE, player); HP_BAR(opponent, captureDamage: &bideDamage); - } FINALLY { - EXPECT_EQ(bideDamage, damage1 + damage2); + } THEN { + EXPECT_EQ(bideDamage, 2 * (damage1 + damage2)); } } diff --git a/test/move_effect_triple_kick.c b/test/move_effect_triple_kick.c index d3187aefec..e0a91b0112 100644 --- a/test/move_effect_triple_kick.c +++ b/test/move_effect_triple_kick.c @@ -6,7 +6,7 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_TRIPLE_KICK].effect & EFFECT_TRIPLE_KICK); } -SINGLE_BATTLE_TEST("Triple Kick damage is increaased by its base damage for each hit") +SINGLE_BATTLE_TEST("Triple Kick damage is increased by its base damage for each hit") { s16 firstHit; s16 secondHit; @@ -24,8 +24,8 @@ SINGLE_BATTLE_TEST("Triple Kick damage is increaased by its base damage for each HP_BAR(opponent, captureDamage: &secondHit); ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_KICK, player); HP_BAR(opponent, captureDamage: &thirdHit); - } FINALLY { - EXPECT_EQ(secondHit, firstHit * 2); - EXPECT_EQ(thirdHit, firstHit * 3); + } THEN { + EXPECT_MUL_EQ(firstHit, Q_4_12(2.0), secondHit); + EXPECT_MUL_EQ(firstHit, Q_4_12(3.0), thirdHit); } } diff --git a/test/move_flag_three_strikes.c b/test/move_flag_three_strikes.c index 7ea7844c4f..b597b4efef 100644 --- a/test/move_flag_three_strikes.c +++ b/test/move_flag_three_strikes.c @@ -20,7 +20,7 @@ SINGLE_BATTLE_TEST("Three-strike flag turns a move into a 3-hit move") HP_BAR(opponent, captureDamage: &secondHit); ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_DIVE, player); HP_BAR(opponent, captureDamage: &thirdHit); - } FINALLY { + } THEN { EXPECT_EQ(firstHit, secondHit); EXPECT_EQ(secondHit, thirdHit); EXPECT_EQ(firstHit, thirdHit); @@ -49,7 +49,7 @@ SINGLE_BATTLE_TEST("Surging Strikes hits 3 times with each hit being a critical ANIMATION(ANIM_TYPE_MOVE, MOVE_SURGING_STRIKES, player); HP_BAR(opponent, captureDamage: &thirdHit); MESSAGE("A critical hit!"); - } FINALLY { + } THEN { EXPECT_EQ(firstHit, secondHit); EXPECT_EQ(secondHit, thirdHit); EXPECT_EQ(firstHit, thirdHit); diff --git a/test/terrain_electric.c b/test/terrain_electric.c index e9c34ef923..78f490c425 100644 --- a/test/terrain_electric.c +++ b/test/terrain_electric.c @@ -34,7 +34,7 @@ SINGLE_BATTLE_TEST("Electric Terrain activates Electric Seed and Mimicry") MESSAGE("Using Electric Seed, the Defense of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Electr!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_ELECTRIC); } } diff --git a/test/terrain_grassy.c b/test/terrain_grassy.c index 7668c49bde..21d64f61e4 100644 --- a/test/terrain_grassy.c +++ b/test/terrain_grassy.c @@ -30,7 +30,7 @@ SINGLE_BATTLE_TEST("Grassy Terrain activates Grassy Seed and Mimicry") MESSAGE("Using Grassy Seed, the Defense of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Grass!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_GRASS); } } diff --git a/test/terrain_misty.c b/test/terrain_misty.c index 4f8793d9d0..f60122075c 100644 --- a/test/terrain_misty.c +++ b/test/terrain_misty.c @@ -34,7 +34,7 @@ SINGLE_BATTLE_TEST("Misty Terrain activates Misty Seed and Mimicry") MESSAGE("Using Misty Seed, the Sp. Def of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Fairy!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_FAIRY); } } diff --git a/test/terrain_psychic.c b/test/terrain_psychic.c index 3ecfa99e06..f7e3a2af73 100644 --- a/test/terrain_psychic.c +++ b/test/terrain_psychic.c @@ -33,7 +33,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain activates Psychic Seed and Mimicry") MESSAGE("Using Psychic Seed, the Sp. Def of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Psychc!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_PSYCHIC); } } diff --git a/test/test_battle.h b/test/test_battle.h index 4c563c91d6..205c699192 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -897,7 +897,9 @@ void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEve /* Finally */ -#define FINALLY for (; gBattleTestRunnerState->runFinally; gBattleTestRunnerState->runFinally = FALSE) if ((gBattleTestRunnerState->runningFinally = TRUE)) +#define FINALLY for (ValidateFinally(__LINE__); gBattleTestRunnerState->runFinally; gBattleTestRunnerState->runFinally = FALSE) if ((gBattleTestRunnerState->runningFinally = TRUE)) + +void ValidateFinally(u32 sourceLine); /* Expect */ diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 7740783b2c..2c26e39180 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1719,7 +1719,6 @@ void QueueMessage(u32 sourceLine, const u8 *pattern) }; } - void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEventContext ctx) { s32 battlerId = battler - gBattleMons; @@ -1759,3 +1758,11 @@ void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEve }}, }; } + +void ValidateFinally(u32 sourceLine) +{ + // Defer this error until after estimating the cost. + if (STATE->results == NULL) + return; + INVALID_IF(STATE->parametersCount == 0, "FINALLY without PARAMETRIZE"); +}