//==================================================================================================
// Performs tests on all natives functions
//==================================================================================================
include "TriggerLibs/natives"

//--------------------------------------------------------------------------------------------------
const int c_outputError     = 1;
const int c_outputInfo      = 2;
const int c_outputAnim      = 3;

//--------------------------------------------------------------------------------------------------
void OutputInit () {
    TriggerDebugSetTypeName(c_outputError, StringToText("Error"));
    TriggerDebugSetTypeColor(c_outputError, Color(75, 0, 0));
    
    TriggerDebugSetTypeName(c_outputInfo, StringToText("Info"));
    TriggerDebugSetTypeColor(c_outputInfo, Color(0, 0, 0));
    
    TriggerDebugSetTypeName(c_outputAnim, StringToText("Anim"));
    TriggerDebugSetTypeColor(c_outputAnim, Color(0, 0, 50));
}

//--------------------------------------------------------------------------------------------------
void OutputText (int type, text inText) {
    TriggerDebugOutput(type, inText, false);
}

//--------------------------------------------------------------------------------------------------
void Output (int type, string inText) {
    OutputText(type, StringToText(inText));
}

//--------------------------------------------------------------------------------------------------
void CheckNativeError (bool check, string name) {
    if (!check) {
        Output(c_outputError, "Found an error with native function: " + name);
    }
}

//--------------------------------------------------------------------------------------------------
//bool ApproxEqualEx (fixed x1, fixed x2, fixed eps) {
//    fixed diff;
//    diff = x1 - x2;
//    return (diff < eps && diff > -eps);
//}
//
//bool ApproxEqual (fixed x1, fixed x2) {
//    return ApproxEqualEx(x1, x2, 0.001);
//}

//--------------------------------------------------------------------------------------------------
const fixed c_totalTestDuration = 10.0;

////--------------------------------------------------------------------------------------------------
//// Variable testing
////--------------------------------------------------------------------------------------------------
//bool        g_bool          = true;
//byte        g_byte          = 9;
//char        g_char          = 'x';
//fixed       g_fixed         = 3.14;
//handle      g_handle        = null;
//int         g_int           = 3;
//order       g_order         = null;
//playergroup g_playergroup   = null;
//point       g_point         = null;
//region      g_region        = null;
//string      g_string        = "text";
//timer       g_timer         = null;
//trigger     g_trigger       = null;
//unit        g_unit          = null;
//unitfilter  g_unitfilter    = null;
//unitgroup   g_unitgroup     = null;
//
//bool ChangeVars (bool c, bool a) {
//    g_bool          = false;
//    g_byte          = 222;
//    g_char          = 'y';
//    g_fixed         = 7.89;
//    g_handle        = Point(0, 0);
//    g_int           = 81;
//    g_order         = Order(AbilityCommand("move", 1));
//    g_playergroup   = PlayerGroupEmpty();
//    PlayerGroupAdd(g_playergroup, 12);
//    PlayerGroupAdd(g_playergroup, 7);
//    g_point         = Point(1.2, 3.4);
//    g_region        = RegionCircle(Point(1, 2), 3);
//    g_string        = "new string";
//    g_timer         = TimerCreate();
//    TimerStart(g_timer, 12, true, false);
//    g_trigger       = TriggerCreate("Dummy");
//    g_unit          = null;
//    g_unitfilter    = UnitFilter((1 << c_targetFilterEnemy), (1 << c_targetFilterWorker));
//    g_unitgroup     = UnitGroup(null, 1, null, null, 0);
//    return true;
//}
//
//void TestVariables () {
//    trigger t;
//    t = TriggerCreate("ChangeVars");
//    TriggerAddEventChatMessage(t, 1, "testvar", true);
//}
//
////--------------------------------------------------------------------------------------------------
//// Events which are expected to fire
////
//bool g_testEventPlayerProperty      = false;
//bool g_testEventTimerPeriodic       = false;
//bool g_testEventTimerOneShot        = false;
//bool g_testEventUnitDamaged         = false;
//bool g_testEventUnitDied            = false;
//bool g_testEventUnitDecayed         = false;
//bool g_testEventUnitDetected        = false;
//bool g_testEventUnitAttacked        = false;
//bool g_testEventUnitConstruct       = false;
//bool g_testEventUnitTrain           = false;
//bool g_testEventUnitResearch        = false;
//bool g_testEventUnitIssuedOrder     = false;
//bool g_testEventUnitPropertyChanged = false;
//bool g_testEventUnitSelected        = false;
//bool g_testEventUnitRegion          = false;
//bool g_testEventUnitCargo           = false;
//bool g_testTriggerQueue             = false;
//
//bool CheckTestEvents_Trigger (bool c, bool a) {
//    CheckNativeError(g_testEventPlayerProperty,         "Player property event did not fire"        );
//    CheckNativeError(g_testEventTimerPeriodic,          "Periodic timer event did not fire"         );
//    CheckNativeError(g_testEventTimerOneShot,           "One-shot timer event did not fire"         );
//    CheckNativeError(g_testEventUnitDamaged,            "c_unitEventDamaged did not fire"           );
//    CheckNativeError(g_testEventUnitDied,               "c_unitEventDied did not fire"              );
//    //CheckNativeError(g_testEventUnitDecayed,            "c_unitEventDecayed did not fire"           );
//    //CheckNativeError(g_testEventUnitDetected,           "c_unitEventDetected did not fire"          );
//    //CheckNativeError(g_testEventUnitAttacked,           "c_unitEventAttacked did not fire"          );
//    CheckNativeError(g_testEventUnitConstruct,          "c_unitProgressTypeConstruct event did not fire"  );
//    CheckNativeError(g_testEventUnitTrain,              "c_unitProgressTypeTrain event did not fire"      );
//    //CheckNativeError(g_testEventUnitResearch,           "c_unitEventProgressResearch did not fire"  );
//    CheckNativeError(g_testEventUnitIssuedOrder,        "c_unitEventIssuedOrder did not fire"       );
//    CheckNativeError(g_testEventUnitPropertyChanged,    "c_unitEventPropertyChanged did not fire"   );
//    CheckNativeError(g_testEventUnitSelected,           "Unit selection event did not fire"         );
//    CheckNativeError(g_testEventUnitRegion,             "Unit region event did not fire"            );
//    CheckNativeError(g_testEventUnitCargo,              "Unit cargo event did not fire"             );
//    CheckNativeError(g_testTriggerQueue,                "Trigger Queue did not complete"            );
//    
//    Output(c_outputInfo, "TestNatives complete.");
//    return true;
//}
//
//void CheckTestEvents () {
//    trigger t = TriggerCreate("CheckTestEvents_Trigger");
//    TriggerAddEventTimeElapsed(t, c_totalTestDuration, c_timeReal);
//}
//
////--------------------------------------------------------------------------------------------------
//void TestConversions () {
//    int i;
//    fixed f;
//    string s;
//    color c1;
//    color c2;
//    
//    // IntToFixed
//    i = 333;
//    f = IntToFixed(i);
//    CheckNativeError(f == 333.0, "IntToFixed");
//    
//    // IntToString
//    s = IntToString(i);
//    CheckNativeError(StringEqual(s, "333", true), "IntToString");
//    
//    // FixedToInt
//    f = 444.0;
//    i = FixedToInt(f);
//    CheckNativeError(i == 444, "FixedToInt");
//    
//    // FixedToString
//    s = FixedToString(f, c_fixedPrecisionAny);
//    CheckNativeError(StringEqual(s, "444", true), "FixedToString");
//    
//    s = FixedToString(f, 2);
//    CheckNativeError(StringEqual(s, "444.00", true), "FixedToString");
//    
//    // StringToInt
//    s = "42";
//    i = StringToInt(s);
//    CheckNativeError(i == 42, "StringToInt");
//    
//    // StringToFixed
//    s = "42.8";
//    f = StringToFixed(s);
//    CheckNativeError(f == 42.8, "StringToFixed");
//    
//    // Color
//    c1 = Color(50, 75, 100);
//    
//    // ColorWithAlpha
//    c2 = ColorWithAlpha(50, 75, 100, 25);
//    
//    // ColorGetComponent
//    CheckNativeError(ApproxEqualEx(ColorGetComponent(c1, c_colorComponentRed), 50, 1), "ColorGetComponent(c_colorComponentRed)");
//    CheckNativeError(ApproxEqualEx(ColorGetComponent(c2, c_colorComponentGreen), 75, 1), "ColorGetComponent(c_colorComponentGreen)");
//    CheckNativeError(ApproxEqualEx(ColorGetComponent(c1, c_colorComponentBlue), ColorGetComponent(c2, c_colorComponentBlue), 1), "ColorGetComponent(c_colorComponentBlue)");
//    CheckNativeError(ApproxEqualEx(ColorGetComponent(c2, c_colorComponentAlpha), 25, 1), "ColorGetComponent(c_colorComponentAlpha)");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestStrings () {
//    string s;
//    string t;
//    int i;
//    
//    // StringLength
//    s = "Grunt";
//    i = StringLength(s);
//    CheckNativeError(i == 5, "StringLength");
//        
//    // StringCase
//    t = StringCase(s, true);
//    CheckNativeError(StringEqual(t, "GRUNT", true), "StringCase");
//        
//    t = StringCase(s, false);
//    CheckNativeError(StringEqual(t, "grunt", true), "StringCase");
//        
//    // StringSub
//    t = StringSub(s, 2, 4);
//    CheckNativeError(StringEqual(t, "run", true), "StringSub");
//    
//    // StringEqual
//    CheckNativeError(StringEqual("marine", "MaRiNe", false), "StringEqual");
//
//    // StringFind
//    s = "ultralisk";
//    CheckNativeError(StringFind(s, "tra", true) == 3, "StringFind");
//    
//    // StringContains
//    CheckNativeError(StringContains(s, "ultra", c_stringBegin, true), "StringContains");
//    CheckNativeError(StringContains(s, "lisk", c_stringEnd, true), "StringContains");
//    CheckNativeError(StringContains(s, "rali", c_stringAnywhere, true), "StringContains");
//
//    // StringWord
//    s = "klaatu barada nikto";
//    CheckNativeError(StringWord(s, 2) == "barada", "StringWord");
//
//    // StringReplace
//    t = StringReplace(s, "necktie", 15, 19);
//    CheckNativeError(t == "klaatu barada necktie", "StringReplace");
//
//    // StringReplaceWord
//    t = StringReplaceWord(s, "barada", "barracuda", c_stringReplaceAll, true);
//    CheckNativeError(t == "klaatu barracuda nikto", "StringReplaceWord");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestMath () {
//    int i;
//    fixed x;
//    
//    // SquareRoot
//    x = SquareRoot(81.0);
//    CheckNativeError(x == 9.0, "SquareRoot");
//    
//    // Pow
//    x = Pow(3.0, 4.0);
//    CheckNativeError(x == 81.0, "Pow");
//    
//    // ModF
//    x = ModF(81.0, 7.0);
//    CheckNativeError(x == 4.0, "Mod");
//    
//    // Sin
//    x = Sin(90.0);
//    CheckNativeError(ApproxEqual(x, 1.0), "Sin");
//    
//    // Cos
//    x = Cos(180.0);
//    CheckNativeError(ApproxEqual(x, -1.0), "Cos");
//    
//    // Tan
//    x = Tan(45.0);
//    CheckNativeError(ApproxEqual(x, 1.0), "Tan");
//    
//    // ASin
//    x = ASin(1.0);
//    CheckNativeError(ApproxEqual(x, 90.0), "ASin");
//    
//    // ACos
//    x = ACos(-1.0);
//    CheckNativeError(ApproxEqual(x, 180.0), "ACos");
//    
//    // ATan
//    x = ATan(1.0);
//    CheckNativeError(ApproxEqual(x, 45.0), "ATan");
//    
//    // ATan2
//    x = ATan2(1.0, 1.0);
//    CheckNativeError(ApproxEqual(x, 45.0), "ATan2");
//    
//    // RandomInt
//    i = RandomInt(45, 55);
//    CheckNativeError(i >= 45 && i <= 55, "RandomInt");
//    
//    // RandomFixed
//    x = RandomFixed(3.4, 5.7);
//    CheckNativeError(x >= 3.4 && x <= 5.7, "RandomFixed");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestPoints () {
//    point p;
//    point p2;
//    point p3;
//    fixed f;
//    
//    p = Point(1.2, 3.4);
//    
//    // PointGetX
//    f = PointGetX(p);
//    CheckNativeError(f == 1.2, "PointGetX");
//    
//    // PointGetY
//    f = PointGetY(p);
//    CheckNativeError(f == 3.4, "PointGetY");
//    
//    // PointWithOffset
//    p2 = PointWithOffset(p, 10.0, 20.0);
//    CheckNativeError(PointGetX(p2) == 11.2, "PointWithOffset");
//    CheckNativeError(PointGetY(p2) == 23.4, "PointWithOffset");
//    
//    // PointWithOffsetPolar
//    p2 = PointWithOffsetPolar(p, 10.0, 90.0);
//    CheckNativeError(ApproxEqual(PointGetX(p2),  1.2), "PointWithOffsetPolar");
//    CheckNativeError(ApproxEqual(PointGetY(p2), 13.4), "PointWithOffsetPolar");
//
//    // PointSet
//    PointSet(p2, p);
//    CheckNativeError(ApproxEqual(PointGetX(p2), 1.2), "PointSet");
//    CheckNativeError(ApproxEqual(PointGetY(p2), 3.4), "PointSet");
//    
//    // AngleBetweenPoints
//    f = AngleBetweenPoints(Point(75.0, 0.0), Point(150.0, 75.0));
//    CheckNativeError(f == 45.0, "AngleBetweenPoints");
//    
//    // DistanceBetweenPoints
//    f = DistanceBetweenPoints(Point(3.0, 3.0), Point(6.0, -1.0));
//    CheckNativeError(f == 5.0, "DistanceBetweenPoints");
//
//    // Native point addition
//    p2 = Point(5.6, 7.8);
//    p3 = p + p2;
//    CheckNativeError(ApproxEqual(PointGetX(p3),  6.8), "Native point addition");
//    CheckNativeError(ApproxEqual(PointGetY(p3), 11.2), "Native point addition");
//
//    // Native point subtraction
//    p3 = p2 - p;
//    CheckNativeError(ApproxEqual(PointGetX(p3),  4.4), "Native point subtraction");
//    CheckNativeError(ApproxEqual(PointGetY(p3),  4.4), "Native point subtraction");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestRegions () {
//    region r;
//    region rl;
//    region rh;
//    point p;
//    
//    // L-shaped region from two rects
//    //
//    rl = RegionRect(0, 1, 1, 4);
//    RegionAddRect(rl, true, 0, 0, 3, 1);
//    
//    // Square region with a hole in the center
//    rh = RegionEmpty();
//    RegionAddRect(rh, true, -2, -2, 2, 2);
//    RegionAddCircle(rh, false, Point(0, 0), 1);
//    
//    // RegionSetOffset/RegionGetOffset
//    RegionSetOffset(rh, Point(5, 6));
//    p = RegionGetOffset(rh);
//    CheckNativeError(PointGetX(p) == 5.0, "RegionGetOffset");
//    CheckNativeError(PointGetY(p) == 6.0, "RegionGetOffset");
//    
//    // RegionContainsPoint
//    CheckNativeError( RegionContainsPoint(rl, Point(1.5, 0.5)), "RegionContainsPoint");
//    CheckNativeError(!RegionContainsPoint(rl, Point(1.5, 1.5)), "RegionContainsPoint");
//    
//    CheckNativeError( RegionContainsPoint(rh, Point(4.1, 5.1)), "RegionContainsPoint");
//    CheckNativeError(!RegionContainsPoint(rh, Point(5.5, 6.0)), "RegionContainsPoint");
//    
//    // RegionGetBoundsMin
//    p = RegionGetBoundsMin(rh);
//    CheckNativeError(PointGetX(p) == 3.0, "RegionGetBoundsMin");
//    CheckNativeError(PointGetY(p) == 4.0, "RegionGetBoundsMin");
//    
//    // RegionGetBoundsMax
//    p = RegionGetBoundsMax(rl);
//    CheckNativeError(PointGetX(p) == 3.0, "RegionGetBoundsMax");
//    CheckNativeError(PointGetY(p) == 4.0, "RegionGetBoundsMax");
//    
//    // RegionGetCenter
//    p = RegionGetCenter(rh);
//    CheckNativeError(PointGetX(p) == 5.0, "RegionGetCenter");
//    CheckNativeError(PointGetY(p) == 6.0, "RegionGetCenter");
//    
//    p = RegionGetCenter(rl);
//    CheckNativeError(PointGetX(p) == 1.0, "RegionGetCenter");
//    CheckNativeError(PointGetY(p) == 1.5, "RegionGetCenter");
//    
//    // RegionEntireMap
//    r = RegionEntireMap();
//    p = RegionGetBoundsMax(r);
//    CheckNativeError(PointGetX(p) == 128.0, "RegionEntireMap");
//    CheckNativeError(PointGetY(p) == 128.0, "RegionEntireMap");
//}
//
////--------------------------------------------------------------------------------------------------
//bool TimerPeriodic (bool c, bool a) {
//    g_testEventTimerPeriodic = true;
//    return true;
//}
//
//bool TimerElapsed (bool c, bool a) {
//    g_testEventTimerOneShot = true;
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestTimers () {
//    timer t;
//    fixed f;
//    fixed dur;
//    trigger trig;
//    
//    // Timer
//    dur = 6.0;
//    t = TimerCreate();
//    TimerStart(t, dur, true, true);
//    
//    f = TimerGetElapsed(t);
//    CheckNativeError(f == 0.0, "TimerGetElapsed");
//    
//    f = TimerGetRemaining(t);
//    CheckNativeError(f == dur, "TimerGetRemaining");
//    
//    f = TimerGetDuration(t);
//    CheckNativeError(f == dur, "TimerGetDuration");
//    
//    trig = TriggerCreate("TimerPeriodic");
//    TriggerAddEventTimer(trig, t);
//    
//    // Time elapsed event
//    trig = TriggerCreate("TimerElapsed");
//    TriggerAddEventTimeElapsed(trig, 9, c_timeReal);
//}
//
////--------------------------------------------------------------------------------------------------
//bool PlayerPropChange (bool c, bool a) {
//    g_testEventPlayerProperty = true;
//    CheckNativeError(EventPlayer() == 1, "EventPlayer");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestPlayers () {
//    int i;
//    fixed f;
//    trigger t;
//    
//    // TriggerPlayerPropChange
//    t = TriggerCreate("PlayerPropChange");
//    TriggerPlayerPropChange(t, 1, c_playerPropGas);
//    
//    // PlayerModifyPropertyInt
//    PlayerModifyPropertyInt(1, c_playerPropGas, c_playerPropOperSetTo, 314);
//    
//    // PlayerGetPropertyInt
//    i = PlayerGetPropertyInt(1, c_playerPropGas);
//    CheckNativeError(i == 314, "PlayerGetPropertyInt");
//    
//    // PlayerGetPropertyFixed
//    f = PlayerGetPropertyFixed(1, c_playerPropGas);
//    CheckNativeError(f == 314.0, "PlayerGetPropertyFixed");
//    
//    // PlayerRace
//    // (we don't know specifically which race the player will be,
//    //  so just check for any of the recognized races)
//    //
//    CheckNativeError(
//        (PlayerRace(1) == "Prot") ||
//        (PlayerRace(1) == "Terr") ||
//        (PlayerRace(1) == "Zerg"),
//        "PlayerRace"
//    );
//    
//    // PlayerGetColorIndex
//    CheckNativeError(PlayerGetColorIndex(1, true) == 1, "PlayerGetColorIndex");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestPlayerGroups () {
//    playergroup g;
//    playergroup g2;
//    int i;
//    
//    // Note that player groups are always sorted
//    g = PlayerGroupEmpty();
//    PlayerGroupAdd(g, 7);
//    PlayerGroupAdd(g, 4);
//    PlayerGroupAdd(g, 9);
//    
//    // PlayerGroupCount
//    i = PlayerGroupCount(g);
//    CheckNativeError(i == 3, "PlayerGroupCount");
//    
//    // PlayerGroupPlayer
//    i = PlayerGroupPlayer(g, 2);
//    CheckNativeError(i == 7, "PlayerGroupPlayer");
//    
//    // PlayerGroupCopy
//    g2 = PlayerGroupCopy(g);
//    CheckNativeError(PlayerGroupPlayer(g2, 3) == 9, "PlayerGroupCopy");
//    
//    // PlayerGroupHasPlayer
//    CheckNativeError(PlayerGroupHasPlayer(g2, 4), "PlayerGroupHasPlayer");
//    
//    // PlayerGroupClear
//    PlayerGroupClear(g2);
//    CheckNativeError(PlayerGroupCount(g2) == 0, "PlayerGroupClear");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestOrders () {
//    order stop;
//    order move;
//    order patrol;
//    order attack;
//    unit u;
//    unit testUnit;
//    point p;
//    abilcmd a;
//    
//    testUnit = UnitGroupUnit(UnitGroup("CoCe", 1, null, null, 0), 1);
//    
//    // Create orders
//    stop = Order(AbilityCommand("stop", 0));
//    move = OrderTargetingPoint(AbilityCommand("move", 0), Point(111, 222));
//    patrol = OrderTargetingPoint(AbilityCommand("move", 1), Point(333, 444));
//    attack = OrderTargetingUnit(AbilityCommand("atck", 0), testUnit);
//    
//    // OrderGetAbilityCommand
//    a = OrderGetAbilityCommand(stop);
//    CheckNativeError(StringEqual(AbilityCommandGetAbility(a), "stop", true), "OrderGetAbilityCommand (abil)");
//    
//    // OrderGetCommand
//    a = OrderGetAbilityCommand(patrol);
//    CheckNativeError(AbilityCommandGetCommand(a) == 1, "OrderGetAbilityCommand (cmd)");
//    
//    // OrderGetTargetPoint
//    p = OrderGetTargetPoint(move);
//    CheckNativeError(p == Point(111, 222), "OrderGetTargetPoint");
//    
//    // OrderGetTargetUnit
//    u = OrderGetTargetUnit(attack);
//    CheckNativeError(u == testUnit, "OrderGetTargetUnit");
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitEventDeath (bool c, bool a) {
//    g_testEventUnitDied = true;
//    
//    CheckNativeError(EventUnitType() == c_unitEventDied, "EventUnitType (c_unitEventDied)");
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "Fire", true), "EventUnit (c_unitEventDied)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitDamage (bool c, bool a) {
//    g_testEventUnitDamaged = true;
//    
//    CheckNativeError(EventUnitType() == c_unitEventDamaged, "EventUnitType (c_unitEventDamaged)");
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "Fire", true), "EventUnit (c_unitEventDamaged)");
//    CheckNativeError(EventUnitDamageAmount() == 5, "EventUnitDamageAmount");
//    CheckNativeError(EventUnitDamageSourcePlayer() == 1, "EventUnitDamageSourcePlayer");
//    CheckNativeError(StringEqual(UnitGetType(EventUnitDamageSourceUnit()), "Mari", true), "EventUnitDamageSourceUnit");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitConstruct (bool c, bool a) {
//    g_testEventUnitConstruct = true;
//    
//    CheckNativeError(EventUnitProgressType() == c_unitProgressTypeConstruct, "EventUnitProgressType (c_unitProgressTypeConstruct)");
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "SCV_", true), "EventUnit (c_unitProgressTypeConstruct)");
//    CheckNativeError(StringEqual(EventUnitProgressObjectType(), "Barr", true), "EventUnitProgressObjectType (c_unitProgressTypeConstruct)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitTrain (bool c, bool a) {
//    g_testEventUnitTrain = true;
//    
//    CheckNativeError(EventUnitProgressType() == c_unitProgressTypeTrain, "EventUnitType (c_unitProgressTypeTrain)");
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "CoCe", true), "EventUnit (c_unitProgressTypeTrain)");
//    CheckNativeError(StringEqual(EventUnitProgressObjectType(), "SCV_", true), "EventUnitProgressObjectType (c_unitProgressTypeTrain)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitOrder (bool c, bool a) {
//    g_testEventUnitIssuedOrder = true;
//    
//    CheckNativeError(StringEqual(AbilityCommandGetAbility(OrderGetAbilityCommand(EventUnitOrder())), "move", true), "EventUnitOrder");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitPropChange (bool c, bool a) {
//    g_testEventUnitPropertyChanged = true;
//    
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "Fire", true), "EventUnit (property event)");
//    CheckNativeError(EventUnitProperty() == c_unitPropLife, "EventUnitProperty");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitRegion (bool c, bool a) {
//    g_testEventUnitRegion = true;
//    
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "Fire", true), "EventUnit (region event)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//bool OnUnitCargo (bool c, bool a) {
//    g_testEventUnitCargo = true;
//    
//    CheckNativeError(StringEqual(UnitGetType(EventUnit()), "Bunk", true), "EventUnit (cargo event)");
//    CheckNativeError(EventUnitState(), "EventUnitState (cargo event)");
//    CheckNativeError(StringEqual(UnitGetType(EventUnitCargo()), "Ghos", true), "EventUnitCargo (cargo event)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//unit g_unitSelect = null;
//bool UnitSelectTrigger (bool c, bool a) {
//    UnitSelect(g_unitSelect, 1, true);
//    return true;
//}
//
//bool UnitIsSelectedTrigger (bool c, bool a) {
//    CheckNativeError(UnitIsSelected(g_unitSelect, 1), "UnitSelect/UnitIsSelected");
//    return true;
//}
//
//bool UnitClearSelectionTrigger (bool c, bool a) {
//    UnitClearSelection(1);
//    return true;
//}
//
//bool OnUnitSelected (bool c, bool a) {
//    g_testEventUnitSelected = true;
//    CheckNativeError(EventPlayer() == 1, "EventPlayer (selection event)");
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestUnits () {
//    bool b;
//    string s;
//    int i;
//    fixed f;
//    point p;
//    unit u;
//    unit bat;
//    unit marine;
//    unit bunk;
//    trigger t;
//    
//    // UnitCreate
//    UnitCreate(5, "Mari", c_unitCreateAlive, 1, Point(64, 64), 135.0);
//    marine = UnitLastCreated();
//    
//    // UnitKill
//    UnitCreate(1, "Batt", c_unitCreateAlive, 1, Point(66, 64), 0);
//    UnitKill(UnitLastCreated());
//    
//    // UnitIsAlive
//    CheckNativeError(UnitIsAlive(marine), "UnitIsAlive");
//    
//    // UnitGetType
//    s = UnitGetType(marine);
//    CheckNativeError(StringEqual(s, "Mari", true), "UnitGetType");
//    
//    // UnitTypeGetName
//    OutputText(c_outputInfo, StringToText("UnitGetName(marine) = ") + UnitTypeGetName(s));
//    
//    // UnitGetOwner
//    i = UnitGetOwner(marine);
//    CheckNativeError(i == 1, "UnitGetOwner");
//    
//    // UnitSetOwner
//    UnitCreate(1, "Fire", c_unitCreateAlive, 1, Point(64, 61), 0);
//    bat = UnitLastCreated();
//    UnitSetOwner(bat, 2, true);
//    
//    // c_unitEventDamaged
//    t = TriggerCreate("OnUnitDamage");
//    TriggerAddEventUnit(t, bat, c_unitEventDamaged);
//    
//    // c_unitEventDied
//    t = TriggerCreate("OnUnitEventDeath");
//    TriggerAddEventUnit(t, bat, c_unitEventDied);
//    
//    // TriggerAddEventUnitProperty
//    t = TriggerCreate("OnUnitPropChange");
//    TriggerAddEventUnitProperty(t, bat, c_unitPropLife);
//    
//    // UnitGetPosition
//    p = UnitGetPosition(bat);
//    CheckNativeError(PointGetX(p) == 64.0, "UnitGetPosition");
//    CheckNativeError(PointGetY(p) == 61.0, "UnitGetPosition");
//    
//    // UnitSetPosition
//    UnitSetPosition(marine, Point(61, 61));
//    p = UnitGetPosition(marine);
//    CheckNativeError(PointGetX(p) == 61.0, "UnitGetPosition");
//    CheckNativeError(PointGetY(p) == 61.0, "UnitGetPosition");
//    
//    // UnitGetFacing
//    f = UnitGetFacing(marine);
//    CheckNativeError(f == 135.0, "UnitGetFacing");
//    
//    // UnitSetFacing
//    UnitSetFacing(marine, 45.0, 0.0);
//    f = UnitGetFacing(marine);
//    CheckNativeError(f == 45.0, "UnitSetFacing");
//    
//    // UnitSetPropertyInt
//    UnitSetPropertyInt(marine, c_unitPropLife, 1);
//    i = UnitGetPropertyInt(marine, c_unitPropLife, c_unitPropCurrent);
//    CheckNativeError(i == 1, "UnitSetPropertyInt");
//    
//    // UnitAbilityExists
//    UnitCreate(1, "Zeal", c_unitCreateAlive, 1, Point(60, 70), 0);
//    u = UnitLastCreated();
//    b = UnitAbilityExists(u, "move");
//    CheckNativeError(b, "UnitAbilityExists");
//    
//    // UnitAbilityEnable
//    UnitAbilityEnable(u, "move", false);
//    b = UnitAbilityCheck(u, "move", true);
//    CheckNativeError(!b, "UnitAbilityEnable");
//    
//    // UnitMoverExists
//    CheckNativeError(UnitMoverExists(u, "Ground"), "UnitMoverExists");
//    CheckNativeError(!UnitMoverExists(u, "Fly"), "UnitMoverExists");
//    
//    // UnitTestPlane
//    CheckNativeError(UnitTestPlane(u, c_planeGround), "UnitTestPlane");
//    CheckNativeError(!UnitTestPlane(u, c_planeAir), "UnitTestPlane");
//    
//    // TriggerAddEventUnitOrder
//    t = TriggerCreate("OnUnitOrder");
//    TriggerAddEventUnitOrder(t, null, AbilityCommand("move", 1));
//    
//    // UnitIssueOrder
//    UnitCreate(1, "Fire", c_unitCreateAlive, 1, Point(55, 58), 0);
//    u = UnitLastCreated();
//    UnitIssueOrder(u, OrderTargetingPoint(AbilityCommand("move", 1), Point(75, 58)), c_orderQueueAddToEnd);
//    
//    // UnitSetTeamColorIndex
//    UnitSetTeamColorIndex(u, 3);
//    UnitResetTeamColorIndex(u);
//    
//    // UnitSelect
//    // - Can't be done during map init
//    g_unitSelect = u;
//    t = TriggerCreate("UnitSelectTrigger");
//    TriggerAddEventTimeElapsed(t, 1, c_timeReal);
//    
//    // UnitIsSelected
//    t = TriggerCreate("UnitIsSelectedTrigger");
//    TriggerAddEventTimeElapsed(t, 2, c_timeReal);
//    
//    // UnitClearSelection
//    t = TriggerCreate("UnitClearSelectionTrigger");
//    TriggerAddEventTimeElapsed(t, 8, c_timeReal);
//    
//    // TriggerAddEventUnitSelected
//    t = TriggerCreate("OnUnitSelected");
//    TriggerAddEventUnitSelected(t, g_unitSelect, 1, true);
//    
//    // TriggerAddEventUnitRegion
//    t = TriggerCreate("OnUnitRegion");
//    TriggerAddEventUnitRegion(t, u, RegionRect(60, 55, 70, 61), true);
//    
//    // TriggerAddEventUnitProgress, c_unitProgressTypeConstruct
//    t = TriggerCreate("OnUnitConstruct");
//    TriggerAddEventUnitProgress(t, null, c_unitProgressTypeConstruct, c_unitProgressStageStart);
//    
//    PlayerModifyPropertyInt(1, c_playerPropMinerals, c_playerPropOperSetTo, 500);
//    UnitCreate(1, "SCV_", c_unitCreateAlive, 1, Point(40, 62), 0);
//    u = UnitLastCreated();
//    UnitIssueOrder(u, OrderTargetingPoint(AbilityCommand("tbld", 4), Point(40, 62)), c_orderQueueAddToEnd);
//    
//    // TriggerAddEventUnitProgress, c_unitProgressTypeTrain
//    t = TriggerCreate("OnUnitTrain");
//    TriggerAddEventUnitProgress(t, null, c_unitProgressTypeTrain, c_unitProgressStageStart);
//    
//    UnitCreate(2, "SuDe", c_unitCreateAlive, 1, Point(40, 40), 0);
//    u = UnitGroupUnit(UnitGroup("CoCe", 1, null, null, 0), 1);
//    UnitIssueOrder(u, Order(AbilityCommand("cctr", 0)), c_orderQueueAddToEnd);
//    
//    // TriggerAddEventUnitCargo
//    UnitCreate(1, "Bunk", c_unitCreateAlive, 1, Point(32, 96), 0);
//    bunk = UnitLastCreated();
//    
//    UnitCreate(1, "Ghos", c_unitCreateAlive, 1, Point(36, 96), 0);
//    u = UnitLastCreated();
//    UnitIssueOrder(bunk, OrderTargetingUnit(AbilityCommand("bunk", 0), u), c_orderQueueAddToEnd);
//    
//    t = TriggerCreate("OnUnitCargo");
//    TriggerAddEventUnitCargo(t, bunk, true);
//    
//    // UnitMagazineArm
//    UnitCreate(1, "LaunchFacility", c_unitCreateAlive, 1, Point(32, 102), 0);
//    u = UnitLastCreated();
//    
//    UnitMagazineArm(u, "ArmSiloWithNuke", 0, 2);
//    CheckNativeError(UnitMagazineCount(u, "ArmSiloWithNuke") == 2, "UnitMagazineArm");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestUnitFilters () {
//    unitfilter f;
//    int state;
//    
//    // UnitFilter
//    f = UnitFilter((1 << c_targetFilterMinerals), 0);
//    
//    state = UnitFilterGetState(f, c_targetFilterMinerals);
//    CheckNativeError(state == c_unitFilterRequired, "UnitFilter (required)");
//    
//    state = UnitFilterGetState(f, c_targetFilterInvulnerable);
//    CheckNativeError(state == c_unitFilterAllowed, "UnitFilter (allowed)");
//    
//    // UnitFilterSetState
//    UnitFilterSetState(f, c_targetFilterInvulnerable, c_unitFilterExcluded);
//    state = UnitFilterGetState(f, c_targetFilterInvulnerable);
//    CheckNativeError(state == c_unitFilterExcluded, "UnitFilterSetState (excluded)");
//}
//
////--------------------------------------------------------------------------------------------------
//void TestUnitGroups () {
//    unitgroup g;
//    unitgroup g2;
//    int i;
//    unit u;
//    
//    g = UnitGroup("SCV_", 1, null, null, 0);
//    
//    // UnitGroupCount
//    i = UnitGroupCount(g, c_unitCountAll);
//    CheckNativeError(i == 7, "UnitGroupCount");
//    
//    // UnitGroupCount (alive)
//    i = UnitGroupCount(g, c_unitCountAlive);
//    CheckNativeError(i == 7, "UnitGroupCount (alive)");
//    
//    // UnitGroupUnit
//    CheckNativeError(StringEqual(UnitGetType(UnitGroupUnit(g, 1)), "SCV_", true), "UnitGroupUnit");
//
//    // UnitGroupRandomUnit
//    CheckNativeError(StringEqual(UnitGetType(UnitGroupRandomUnit(g, c_unitCountAlive)), "SCV_", true), "UnitGroupRandomUnit");
//    CheckNativeError(UnitGroupRandomUnit(g, c_unitCountDead) == null, "UnitGroupRandomUnit");
//
//    // UnitGroupFilter
//    g2 = UnitGroupFilter("SCV_", 1, g, null, 4);
//    CheckNativeError(UnitGroupCount(g2, c_unitCountAll) == 4, "UnitGroupFilter");
//    
//    // UnitGroupCopy
//    g2 = UnitGroupCopy(g);
//    CheckNativeError(UnitGroupCount(g2, c_unitCountAll) == UnitGroupCount(g, c_unitCountAll), "UnitGroupCopy");
//    
//    // UnitGroupHasUnit
//    u = UnitGroupUnit(g, 2);
//    CheckNativeError(UnitGroupHasUnit(g2, u), "UnitGroupHasUnit");
//    
//    // UnitGroupClear
//    UnitGroupClear(g2);
//    CheckNativeError(UnitGroupCount(g2, c_unitCountAll) == 0, "UnitGroupClear");
//}
//
////--------------------------------------------------------------------------------------------------
//bool TestDisplayText (bool a, bool c) {
//    DisplayText(PlayerGroupSingle(1), 2, StringToText("Test message from player 2"));
//    return true;
//}
//
//bool TestClearText (bool a, bool c) {
//    int i = 0;
//    while (i < 10) {
//        DisplayText(PlayerGroupSingle(1), c_playerAny, StringToText("Spam Message #" + IntToString(i + 1)));
//        i = i + 1;
//    }
//    
//    i = 5;
//    while (i > 0) {
//        DisplayText(PlayerGroupSingle(1), c_playerAny, StringToText("Clearing in " + IntToString(i) + " seconds"));
//        i = i - 1;
//        Wait(1, false);
//    }
//    
//    ClearText(PlayerGroupSingle(1));
//    return true;
//}
//
//bool TestGameOver (bool a, bool c) {
//    GameOver(1, c_gameOverVictory, true, true);
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestGame () {
//    trigger t;
//
//    // DisplayText
//    t = TriggerCreate("TestDisplayText");
//    TriggerAddEventTimeElapsed(t, 0.01, c_timeReal);
//    
//    // ClearText
//    t = TriggerCreate("TestClearText");
//    TriggerAddEventChatMessage(t, 1, "spam", true);
//    
//    // GameOver
//    t = TriggerCreate("TestGameOver");
//    TriggerAddEventChatMessage(t, 1, "testgameover", true);
//}
//
////--------------------------------------------------------------------------------------------------
//bool TestMinimapPing (bool a, bool c) {
//    MinimapPing(
//        PlayerGroupSingle(1),
//        Point(RandomFixed(0, 128), RandomFixed(0, 128)),
//        2,
//        Color(RandomFixed(0, 100), RandomFixed(0, 100), RandomFixed(0, 100))
//    );
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestMinimap() {
//    trigger t;
//    
//    // MinimapPing
//    t = TriggerCreate("TestMinimapPing");
//    TriggerAddEventChatMessage(t, 1, "testping", true);
//}

//--------------------------------------------------------------------------------------------------
bool TestActorTrigger (bool a, bool c) {
    unit marine;
    unit mercHaven;
    actorscope as;
    actorscope as2;
    actorscope as3;
    actorscope as4;
    actorscope as5;
    actorscope as6;
    actorscope as7;
    actor act;
    actor act2;
    actor act3;
    text ot;

//    ot = ActorScopeGetText(as);
//    if (ot == null) {
//        OutputText(c_outputError, StringToText("null"));
//    }
//    else {
//        OutputText(c_outputError, ot);
//    }

//    ot = ActorGetText(act);
//    if (ot == null) {
//        OutputText(c_outputError, StringToText("null"));
//    }
//    else {
//        OutputText(c_outputError, ot);
//    }

//    act = ActorFromScope(as, "Splax");
//    act = ActorFromScope(as, "_Unit");
//    ActorSend(act, "SetTintColor 0,255,0");
//    ActorCreate(as, "ModelHosted", "Hydralisk", "");

//    UnitCreate(1, "BlackMarket", c_unitCreateAlive, 1, Point(60, 60), 0);
//    mercHaven = UnitLastCreated();
//    as = ActorScopeFromUnit(mercHaven);

//    act = ActorFromScope(as, "_Unit");
//    as2 = ActorScopeFromActor(act);
//    ActorSend(act, "SetTintColor 0,255,0");

//    act = ActorCreate(null, "Model", "Hydralisk", "");
//    ActorSend(act, "SetBearingsH 64,64,0");
//    as2 = ActorScopeFromActor(act);
//    ActorScopeOrphan(as2);

// Tests ::LastCreated.
//    UnitCreate(1, "BlackMarket", c_unitCreateAlive, 1, Point(60, 60), 0);
//    mercHaven = UnitLastCreated();
//    as = ActorScopeFromUnit(mercHaven);
//    act = ActorFromScope(as, "MercHavenChick");
//    act = ActorFromActor(act, "::Host");
//    act = ActorFromActor(act, "::Host");
//    ActorSend(act, "SetTintColor 0,255,0");
//    act = ActorCreate(as, "Model", "Hydralisk", "");
//    ActorSend(act, "SetBearingsH 64,64 0");
//    act = ActorFrom("::LastCreated");
//    ActorSend(act, "SetBearingsH 64,64 2");

//    act = ActorCreate(null, "Model", "Hydralisk", "");
//    as = ActorScopeFrom("::LastCreated");
//    ActorSend(act, "SetBearingsH 64,64 0");
//    ActorScopeSend(as, "SetTintColor 0,255,0");

//    UnitCreate(1, "BlackMarket", c_unitCreateAlive, 1, Point(60, 60), 0);
//    mercHaven = UnitLastCreated();
//    as = ActorScopeFromUnit(mercHaven);
//    ot = ActorScopeGetText(as);
//    OutputText(c_outputError, ot);
//    act = ActorFromScope(as, "MercHavenChick");
//    act = ActorFromActor(act, "::Host");
//    ActorSendTo(act, "::Host", "SetTintColor 0,255,0");
//    act = ActorCreate(as, "Model", "Hydralisk", "");
//    ActorSend(act, "SetBearingsH 64,64 0");
//    act = ActorFrom("::LastCreated");
//    ot = ActorGetText(act);
//    OutputText(c_outputError, ot);
//    ActorSend(act, "SetBearingsH 64,64 2");
//    act = ActorFromScope(as, "Monster");
//    ot = ActorGetText(act);
//    OutputText(c_outputError, ot);

//    act = ActorCreate(null, "Model", "Hydralisk", "");
//    as = ActorScopeFrom("::LastCreated");
//    ActorSend(act, "SetBearingsH 64,64 0");
//    ActorScopeSend(as, "SetTintColor 0,255,255");

//    act = ActorCreate(null, "List", "", "", "");
//    as = ActorScopeFrom("::LastCreated");

//    act2 = ActorCreate(as, "Model", "Pylon", "", "");
//    ActorRefSet(act, "::ContentsAdd", act2);

//    act2 = ActorCreate(as, "Model", "Baneling", "", "");
//    ActorRefSet(act, "::ContentsAdd", act2);

//    act2 = ActorCreate(as, "Model", "Colossus", "", "");
//    ActorSend(act, "ListAdd ::LastCreated");

//    ActorSendTo(act, "::Contents", "SetBearingsH 75,50 0");
//    ActorSendTo(act, "::Contents", "SetTintColor 0,255,0");

    act = ActorCreate(null, "Model", "Hydralisk", "", "");
    ActorSend(act, "SetBearingsH 64,64 2");
    ActorRefSet(null, "::global.Launch", act);

    act2 = ActorCreate(null, "Model", "Hydralisk", "", "");
    ActorSend(act2, "SetBearingsH 68,64 2");
    ActorRefSet(null, "::global.Impact", act2);

    act3 = ActorCreate(null, "Beam", "ColossusAttackBeam", "::global.Launch", "::global.Impact");

    act = ActorRefGet(null, "::global.Impact");
    ot = ActorGetText(act);
    OutputText(c_outputError, ot);

    act2 = ActorRefGet(null, "::global.Launch");
    ot = ActorGetText(act2);
    OutputText(c_outputError, ot);

    act3 = ActorRefGet(act3, "::HostLaunch");
    ot = ActorGetText(act3);
    OutputText(c_outputError, ot);

    return true;
}

//--------------------------------------------------------------------------------------------------
void TestActors () {
    trigger t;
    t = TriggerCreate("TestActorTrigger");
    TriggerAddEventTimeElapsed(t, 2.0, c_timeReal);
}

////--------------------------------------------------------------------------------------------------
//bool TestAnimsTrigger (bool a, bool c) {
//    unit marine;
//    string out;
//
//    UnitCreate(1, "Mari", c_unitCreateAlive, 1, Point(57, 115), 0);
//    marine = UnitLastCreated();
//
//    // Basic set.
//    Output(c_outputAnim, "Play 'Walk'.");
//    AnimPlay(marine, "Walk", 0, c_animBlendTimeDefault);
//    Wait(0.667, false);
//    
//    // Multi-prop set.
//    Output(c_outputAnim, "Play 'Stand Right'.");
//    AnimPlay(marine, "Stand Right", 0, c_animBlendTimeDefault);
//    Wait(0.333, false);
//
//    // Basic play.
//    Output(c_outputAnim, "Play 'Attack'.");
//    AnimPlay(marine, "Attack", 0, c_animBlendTimeDefault);
//    Wait(1.000, false);
//
//    // Multi-prop play.
//    Output(c_outputAnim, "Play 'Silentkill'.");
//    AnimPlay(marine, "Death Silentkill", 0, c_animBlendTimeDefault);
//    Wait(2.000, false);
//    
//    // Playing with flags.
//
//// $PCG; Rarities are currently commented out in the toolchain.
//    Output(c_outputAnim, "Play most frequent 'Walk' forever (but cut out at 5 loops).");
//    AnimPlay(marine, "Walk", c_animFlagPlayForever, c_animBlendTimeDefault);
//    Wait(0.667 * 5, false);
//
//    // Using props.
//    Output(c_outputAnim, "Playing 'Walk' using flags to override 'Left' prop.");
//    AnimEnableProps(marine, "Left", true);
//    AnimPlay(marine, "Walk", c_animFlagIgnoreProps, c_animBlendTimeDefault);
//    AnimEnableProps(marine, "Left", false);
//    Wait(0.333, false);
//    
//    // Checking prop stats and clearing props.
//    Output(c_outputAnim, "Adding prop 'Left'.");
//    AnimEnableProps(marine, "Left", true);
//
//    Output(c_outputAnim, "Clearing prop 'Left'.");
//    AnimClearProps(marine);
//
//    // Time scale test.
//    Output(c_outputAnim, "Play 'Walk' and set time scale to 5.3.");
//    AnimPlay(marine, "Walk", 0, c_animBlendTimeDefault);
//    AnimSetTimeScale(marine, 0, 5.3);
//
//    // Time routines.
//    Output(c_outputAnim, "Play 'Attack' and set duration to 4.5.");
//    AnimPlay(marine, "Attack", 0, c_animBlendTimeDefault);
//    AnimSetDuration(marine, 0, 4.5);
//
//    Output(c_outputAnim, "Play 'Attack' and set time to 0.25.");
//    AnimPlay(marine, "Attack", 0, c_animBlendTimeDefault);
//    AnimSetTime(marine, 0.25, false);
//    Wait(0.1, false);
//
//    Output(c_outputAnim, "Play 'Walk' and set time scale to 2.0");
//    AnimPlay(marine, "Walk", 0, c_animBlendTimeDefault);
//    AnimSetDuration(marine, 0, 2.0);
//    AnimSetTime(marine, 1.0, true);
//    Wait(0.1, false);
//
//    Output(c_outputAnim, "Play 'Attack' and pause at 0.3");
//    AnimPlay(marine, "Attack", 0, c_animBlendTimeDefault);
//    AnimSetPauseTime(marine, 0.3);
//
//    Output(c_outputAnim, "Clear pause time.");
//    AnimClearPauseTime(marine);
//
//    return true;
//}
//
////--------------------------------------------------------------------------------------------------
//void TestAnims () {
//    trigger t;
//    t = TriggerCreate("TestAnimsTrigger");
//    TriggerAddEventTimeElapsed(t, 2.0, c_timeReal);
//}
//
////--------------------------------------------------------------------------------------------------
//region g_revealRegion = null;
//revealer g_revealer = null;
//int g_revealCounter = 0;
//
//bool TestVisTrigger (bool a, bool c) {
//    //if (g_revealer == null) {
//    //    return false;
//    //}
//        
//    // VisRevealerEnable
//    VisRevealerEnable(g_revealer, g_revealCounter < 4 || g_revealCounter > 6);
//    
//    // VisRevealerUpdate
//    RegionSetOffset(g_revealRegion, Point(g_revealCounter, g_revealCounter));
//    VisRevealerUpdate(g_revealer);
//    
//    // VisRevealerDestroy
//    if (g_revealCounter > 20) {
//        VisRevealerDestroy(g_revealer);
//        g_revealer = null;
//    }
//    
//    g_revealCounter = g_revealCounter + 1;
//    return true;
//}
//
//bool TestExploreArea (bool a, bool c) {
//    VisExploreArea(1, RegionRect(4, 108, 20, 124), true);
//    VisExploreArea(1, RegionCircle(Point(12, 116), 4), false);
//    return true;
//}
//
//void TestVisibility () {
//    revealer r;
//    trigger t;
//    
//    // VisExploreArea (can't be done during map init)
//    t = TriggerCreate("TestExploreArea");
//    TriggerAddEventTimeElapsed(t, 1, c_timeReal);
//    
//    // VisRevealArea
//    VisRevealArea(1, RegionRect(4, 4, 12, 12), 10);
//    
//    // VisRevealerCreate
//    g_revealRegion = RegionCircle(Point(64, 12), 8);
//    g_revealer = VisRevealerCreate(1, g_revealRegion);
//    
//    // VisRevealerLastCreated
//    r = VisRevealerLastCreated();
//    CheckNativeError(r == g_revealer, "VisRevealerLastCreated");
//    
//    t = TriggerCreate("TestVisTrigger");
//    TriggerAddEventTimePeriodic(t, 1, c_timeGame);
//}
//
////--------------------------------------------------------------------------------------------------
//bool TestSoundTrigger (bool c, bool a) {
//    sound s;
//    
//    // SoundPlay
//    SoundPlay(SoundInfo("CalldownLaunch", c_soundIndexAny, null, 100));
//    
//    // SoundCreate
//    s = SoundCreate(
//        SoundInfo3d(
//            "ScoreVictoryMusicZerg",
//            c_soundIndexAny,
//            PlayerGroupSingle(1),
//            20,
//            Point(16, 16),
//            0
//        )
//    );
//    
//    // SoundLastCreated
//    CheckNativeError(SoundLastCreated() == s, "SoundLastCreated");
//    
//    // SoundStart
//    SoundStart(s, c_soundIndexAny);
//    
//    // SoundSetVolume
//    // SoundSetPosition
//    Wait(2, false);
//    SoundSetVolume(s, 40);
//    SoundSetPosition(s, Point(16, 112), 0);
//    
//    Wait(2, false);
//    SoundSetVolume(s, 60);
//    SoundSetPosition(s, Point(112, 112), 0);
//    
//    Wait(2, false);
//    SoundSetVolume(s, 80);
//    SoundSetPosition(s, Point(112, 16), 0);
//    
//    Wait(2, false);
//    SoundSetVolume(s, 100);
//    SoundSetPosition(s, Point(16, 16), 0);
//    
//    // SoundStop
//    Wait(2, false);
//    SoundStop(s, false);
//    
//    // SoundDestroy
//    SoundDestroy(s);
//    return true;
//}
//
//void TestSound () {
//    trigger t;
//    t = TriggerCreate("TestSoundTrigger");
//    TriggerAddEventChatMessage(t, 1, "testsound", true);
//}
//
////--------------------------------------------------------------------------------------------------
//bool TestMusicTrigger (bool c, bool a) {
//    // SoundMusicPlay
//    SoundMusicPlay(c_musicTypeNormal, "ScoreVictoryMusicTerr", c_soundIndexAny, true);
//    
//    // SoundMusicSetVolume
//    Wait(2, false);
//    SoundMusicSetVolume(c_musicTypeNormal, 50);
//    
//    Wait(2, false);
//    SoundMusicSetVolume(c_musicTypeNormal, 100);
//    
//    // SoundMusicStop
//    Wait(2, false);
//    SoundMusicStop(c_musicTypeNormal, true);
//    return true;
//}
//
//void TestMusic () {
//    trigger t;
//    t = TriggerCreate("TestMusicTrigger");
//    TriggerAddEventChatMessage(t, 1, "testmusic", true);
//}
//
////--------------------------------------------------------------------------------------------------
//bool TestCameraTrigger (bool c, bool a) {
//    camerainfo cam;
//    fixed val;
//    point p;
//    
//    // CameraInfoDefault
//    cam = CameraInfoDefault();
//    val = CameraInfoGetValue(cam, c_cameraValueFarClip);
//    CheckNativeError(ApproxEqual(val, 160), "CameraInfoDefault");
//    
//    // CameraInfoSetValue
//    CameraInfoSetValue(cam, c_cameraValueDistance, 75);
//    val = CameraInfoGetValue(cam, c_cameraValueDistance);
//    CheckNativeError(ApproxEqual(val, 75), "CameraInfoSetValue");
//    
//    // CameraInfoSetTarget
//    CameraInfoSetTarget(cam, Point(64, 110));
//    p = CameraInfoGetTarget(cam);
//    CheckNativeError(p == Point(64, 110), "CameraInfoSetTarget");
//    
//    // CameraApplyInfo
//    CameraApplyInfo(1, cam, 6, true);
//    Wait(6, false);
//    
//    // CameraPan
//    CameraPan(1, Point(96, 110), 3, false);
//    Wait(3, false);
//    
//    // CameraSetValue
//    CameraSetValue(1, c_cameraValueRoll, 180, 4);
//    Wait(4, false);
//    
//    // Reset to default camera
//    Wait(2, false);
//    CameraApplyInfo(1, CameraInfoDefault(), 0, false);
//    return true;
//}
//
//bool TestCameraLock (bool c, bool a) {
//    CameraLock(1, true);
//    return true;
//}
//
//bool TestCameraUnlock (bool c, bool a) {
//    CameraLock(1, false);
//    return true;
//}
//
//bool TestCameraSave (bool c, bool a) {
//    CameraSave(1);
//    return true;
//}
//
//bool TestCameraRestore (bool c, bool a) {
//    CameraRestore(1, 1);
//    return true;
//}
//
//void TestCamera () {
//    trigger t;
//    t = TriggerCreate("TestCameraTrigger");
//    TriggerAddEventChatMessage(t, 1, "camtest", true);
//    
//    t = TriggerCreate("TestCameraLock");
//    TriggerAddEventChatMessage(t, 1, "camlock", true);
//    
//    t = TriggerCreate("TestCameraUnlock");
//    TriggerAddEventChatMessage(t, 1, "camunlock", true);
//
//    t = TriggerCreate("TestCameraSave");
//    TriggerAddEventChatMessage(t, 1, "camsave", true);
//
//    t = TriggerCreate("TestCameraRestore");
//    TriggerAddEventChatMessage(t, 1, "camrestore", true);
//}
//
////--------------------------------------------------------------------------------------------------
//bool TriggerQueue1 (bool c, bool a) {
//    TriggerQueueEnter();
//    Output(c_outputInfo, "TriggerQueue1");
//    Wait(1, false);
//    TriggerQueueExit();
//    return true;
//}
//
//bool TriggerQueue2 (bool c, bool a) {
//    TriggerQueueEnter();
//    Output(c_outputInfo, "TriggerQueue2");
//    Wait(2, false);
//    TriggerQueueExit();
//    return true;
//}
//
//bool TriggerQueue3 (bool c, bool a) {
//    TriggerQueueEnter();
//    Output(c_outputInfo, "TriggerQueue3");
//    Wait(3, false);
//    g_testTriggerQueue = true;
//    TriggerQueueExit();
//    return true;
//}
//
//bool TestTriggerQueuePause (bool c, bool a) {
//    TriggerQueuePause(true);
//    return true;
//}
//
//bool TestTriggerQueueResume (bool c, bool a) {
//    TriggerQueuePause(false);
//    return true;
//}
//
//void TestTriggerQueue () {
//    trigger t;
//
//    t = TriggerCreate("TestTriggerQueuePause");
//    TriggerAddEventChatMessage(t, 1, "qpause", true);
//
//    t = TriggerCreate("TestTriggerQueueResume");
//    TriggerAddEventChatMessage(t, 1, "qresume", true);
//
//    TriggerExecute(TriggerCreate("TriggerQueue1"), true, false);
//    TriggerExecute(TriggerCreate("TriggerQueue2"), true, false);
//    TriggerExecute(TriggerCreate("TriggerQueue3"), true, false);
//}

//--------------------------------------------------------------------------------------------------
void TestAll () {
    //TestVariables();
    //TestConversions();
    //TestStrings();
    //TestMath();
    //TestPoints();
    //TestRegions();
    //TestTimers();
    //TestPlayers();
    //TestPlayerGroups();
    //TestOrders();
    //TestUnits();
    //TestUnitFilters();
    //TestUnitGroups();
    //TestGame();
    //TestMinimap();

    TestActors();

    //TestAnims();
    //TestVisibility();
    //TestSound();
    //TestMusic();
    //TestCamera();
    //TestTriggerQueue();
}

//--------------------------------------------------------------------------------------------------
bool OnGameInit (bool c, bool a) {
    CameraPan(1, Point(64, 64), 0, false);
    TestAll();
    return true;
}

//--------------------------------------------------------------------------------------------------
void TestNatives () {
    trigger t;

//    TriggerDebugWindowOpen(true);
    OutputInit();
    MeleeInitResourcesForPlayer(1, "Terr");
    MeleeInitUnitsForPlayer(1, "Terr", PlayerStartLocation(1));
    
    t = TriggerCreate("OnGameInit");
    TriggerAddEventMapInit(t);

    //CheckTestEvents();
}
