INVALID if FINALLY without PARAMETRIZE

This commit is contained in:
Martin Griffin 2023-04-26 11:12:41 +01:00
parent 3cee3b18c8
commit e0bed6776b
11 changed files with 25 additions and 17 deletions

View File

@ -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);
}

View File

@ -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
#undef MAX_HP

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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 */

View File

@ -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");
}