mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
Test improvements (#3408)
* Run assumptions on all runners * Make i const in battle tests This avoids the pitfall of using i in a PARAMETRIZEd test and confusing the runner.
This commit is contained in:
parent
482029d7ec
commit
f5b149b971
@ -472,8 +472,8 @@
|
||||
|
||||
enum { BATTLE_TEST_SINGLES, BATTLE_TEST_DOUBLES };
|
||||
|
||||
typedef void (*SingleBattleTestFunction)(void *, u32, struct BattlePokemon *, struct BattlePokemon *);
|
||||
typedef void (*DoubleBattleTestFunction)(void *, u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *);
|
||||
typedef void (*SingleBattleTestFunction)(void *, const u32, struct BattlePokemon *, struct BattlePokemon *);
|
||||
typedef void (*DoubleBattleTestFunction)(void *, const u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *);
|
||||
|
||||
struct BattleTest
|
||||
{
|
||||
@ -660,7 +660,7 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;
|
||||
|
||||
#define SINGLE_BATTLE_TEST(_name, ...) \
|
||||
struct CAT(Result, __LINE__) { MEMBERS(__VA_ARGS__) }; \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, u32, struct BattlePokemon *, struct BattlePokemon *); \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, const u32, struct BattlePokemon *, struct BattlePokemon *); \
|
||||
__attribute__((section(".tests"))) static const struct Test CAT(sTest, __LINE__) = \
|
||||
{ \
|
||||
.name = _name, \
|
||||
@ -674,11 +674,11 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;
|
||||
.resultsSize = sizeof(struct CAT(Result, __LINE__)), \
|
||||
}, \
|
||||
}; \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, u32 i, struct BattlePokemon *player, struct BattlePokemon *opponent)
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, const u32 i, struct BattlePokemon *player, struct BattlePokemon *opponent)
|
||||
|
||||
#define DOUBLE_BATTLE_TEST(_name, ...) \
|
||||
struct CAT(Result, __LINE__) { MEMBERS(__VA_ARGS__) }; \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *); \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, const u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *); \
|
||||
__attribute__((section(".tests"))) static const struct Test CAT(sTest, __LINE__) = \
|
||||
{ \
|
||||
.name = _name, \
|
||||
@ -692,7 +692,7 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;
|
||||
.resultsSize = sizeof(struct CAT(Result, __LINE__)), \
|
||||
}, \
|
||||
}; \
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, u32 i, struct BattlePokemon *playerLeft, struct BattlePokemon *opponentLeft, struct BattlePokemon *playerRight, struct BattlePokemon *opponentRight)
|
||||
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, const u32 i, struct BattlePokemon *playerLeft, struct BattlePokemon *opponentLeft, struct BattlePokemon *playerRight, struct BattlePokemon *opponentRight)
|
||||
|
||||
/* Parametrize */
|
||||
|
||||
|
@ -8,18 +8,19 @@ ASSUMPTIONS
|
||||
|
||||
SINGLE_BATTLE_TEST("Salt Cure inflicts 1/8 of the target's maximum HP as damage per turn")
|
||||
{
|
||||
u32 j;
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_SALT_CURE); }
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 3; j++)
|
||||
TURN {}
|
||||
} SCENE {
|
||||
s32 maxHP = GetMonData(&OPPONENT_PARTY[0], MON_DATA_MAX_HP);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_SALT_CURE, player);
|
||||
MESSAGE("Foe Wobbuffet is being salt cured!");
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SALT_CURE_DAMAGE, opponent);
|
||||
HP_BAR(opponent, damage: maxHP / 8);
|
||||
MESSAGE("Foe Wobbuffet is hurt by Salt Cure!");
|
||||
|
@ -3,21 +3,23 @@
|
||||
|
||||
SINGLE_BATTLE_TEST("Bad poison deals 1/16th cumulative damage per turn")
|
||||
{
|
||||
u32 j;
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_TOXIC_POISON); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
TURN {}
|
||||
} SCENE {
|
||||
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
|
||||
for (i = 0; i < 4; i++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (i + 1));
|
||||
for (j = 0; j < 4; j++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (j + 1));
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Bad poison cumulative damage resets on switch")
|
||||
{
|
||||
u32 j;
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_TOXIC_POISON); }
|
||||
PLAYER(SPECIES_WYNAUT);
|
||||
@ -31,9 +33,9 @@ SINGLE_BATTLE_TEST("Bad poison cumulative damage resets on switch")
|
||||
TURN {}
|
||||
} SCENE {
|
||||
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
|
||||
for (i = 0; i < 2; i++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (i + 1));
|
||||
for (i = 0; i < 2; i++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (i + 1));
|
||||
for (j = 0; j < 2; j++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (j + 1));
|
||||
for (j = 0; j < 2; j++)
|
||||
HP_BAR(player, damage: maxHP / 16 * (j + 1));
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,17 @@
|
||||
|
||||
SINGLE_BATTLE_TEST("Burn deals 1/16th damage per turn")
|
||||
{
|
||||
u32 j;
|
||||
GIVEN {
|
||||
ASSUME(B_BURN_DAMAGE >= GEN_LATEST);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_BURN); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
TURN {}
|
||||
} SCENE {
|
||||
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
HP_BAR(player, damage: maxHP / 16);
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,16 @@
|
||||
|
||||
SINGLE_BATTLE_TEST("Poison deals 1/8th damage per turn")
|
||||
{
|
||||
u32 j;
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_POISON); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
TURN {}
|
||||
} SCENE {
|
||||
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
HP_BAR(player, damage: maxHP / 8);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
SINGLE_BATTLE_TEST("Sleep prevents the battler from using a move")
|
||||
{
|
||||
u32 turns;
|
||||
u32 turns, j;
|
||||
PARAMETRIZE { turns = 1; }
|
||||
PARAMETRIZE { turns = 2; }
|
||||
PARAMETRIZE { turns = 3; }
|
||||
@ -11,10 +11,10 @@ SINGLE_BATTLE_TEST("Sleep prevents the battler from using a move")
|
||||
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_SLEEP_TURN(turns)); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
for (i = 0; i < turns; i++)
|
||||
for (j = 0; j < turns; j++)
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); }
|
||||
} SCENE {
|
||||
for (i = 0; i < turns - 1; i++)
|
||||
for (j = 0; j < turns - 1; j++)
|
||||
MESSAGE("Wobbuffet is fast asleep.");
|
||||
MESSAGE("Wobbuffet woke up!");
|
||||
STATUS_ICON(player, none: TRUE);
|
||||
|
@ -88,7 +88,7 @@ static u32 AssignCostToRunner(void)
|
||||
u32 minCostProcess;
|
||||
|
||||
if (gTestRunnerState.test->runner == &gAssumptionsRunner)
|
||||
return 0;
|
||||
return gTestRunnerI;
|
||||
|
||||
minCostProcess = MinCostProcess();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user