Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions wurst/StdlibIngameTests.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function testNestedZeroedDamage()
check(outerAmount > 1., "the outer hit kept its own amount (" + outerAmount.toString(1) + ")")
check(not DamageEvent.isFiring(), "no damage instance left on the stack")

note("DAMAGED fired " + reducedCalls.toString() + " time(s); zeroed nested hit "
note("DAMAGED fired " + reducedCalls + " time(s); zeroed nested hit "
+ (innerReducedFired ? "DID" : "did NOT") + " reach reduced listeners")

destroy ul
Expand Down Expand Up @@ -395,9 +395,9 @@ function testGroupNesting()
if nearest != null
innerCalls++

check(outerCount >= 4, "outer enumeration visited every unit (" + outerCount.toString() + ")")
check(outerCount >= 4, "outer enumeration visited every unit (" + outerCount + ")")
check(innerCalls == outerCount, "nested enumeration ran exactly once per outer unit ("
+ innerCalls.toString() + " vs " + outerCount.toString() + ")")
+ innerCalls + " vs " + outerCount + ")")

for i = 0 to 3
probes[i].remove()
Expand All @@ -421,7 +421,7 @@ function testTimedLoopStopBeforeStart()
probe.startTimedLoop()

doAfter(0.5) ->
check(probe.ticks > 0, "onTimedLoop runs after stop-then-start (ticks " + probe.ticks.toString() + ")")
check(probe.ticks > 0, "onTimedLoop runs after stop-then-start (ticks " + probe.ticks + ")")
probe.stopTimedLoopAndDestroy()

function testTimedLoopDoubleStart()
Expand All @@ -433,7 +433,7 @@ function testTimedLoopDoubleStart()

doAfter(0.5) ->
check(tripled.ticks == single.ticks, "three starts tick as often as one ("
+ tripled.ticks.toString() + " vs " + single.ticks.toString() + ")")
+ tripled.ticks + " vs " + single.ticks + ")")
single.stopTimedLoopAndDestroy()
tripled.stopTimedLoopAndDestroy()

Expand Down Expand Up @@ -477,10 +477,10 @@ public function runStdlibIngameTests()
testTimedLoopDoubleStart()

doAfter(1.5) ->
print("|cff8888ff=== " + (checksRun - checksFailed).toString() + "/" + checksRun.toString()
print("|cff8888ff=== " + (checksRun - checksFailed) + "/" + checksRun
+ " checks passed ===|r")
if checksFailed > 0
print("|cffff4444" + checksFailed.toString() + " check(s) FAILED|r")
print("|cffff4444" + checksFailed + " check(s) FAILED|r")

/** Registers "-stdlibtest" as a chat command that runs the suite. */
public function registerStdlibIngameTestCommand()
Expand All @@ -495,3 +495,4 @@ init
doAfter(1.) ->
runStdlibIngameTests()
registerStdlibIngameTestCommand()

2 changes: 0 additions & 2 deletions wurst/_handles/DestructableTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package DestructableTests
import Destructable
import Wurstunit

@Test function testDestructables()
let destr = createDestructable(0, ZERO2, 0 .fromDeg(), 1, -1)
Expand Down
1 change: 0 additions & 1 deletion wurst/_handles/DialogTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package DialogTests
import Dialog
import Wurstunit

@Test function testDialog()
let dia = createDialog()
Expand Down
2 changes: 0 additions & 2 deletions wurst/_handles/EffectTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package EffectTests
import Effect
import Wurstunit

@Test function testEffect()
let eff = addEffect("testPath", vec2(12,32))
Expand Down
7 changes: 4 additions & 3 deletions wurst/_handles/Framehandle.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ constant BLZ_FRAMENAME_MAXLENGTH = 560
/** Returns whether the frame name length is valid or not */
function verifyFrameNameLength(string name) returns boolean
if name.length() > BLZ_FRAMENAME_MAXLENGTH
error("Trying to address frame with exceeding maximum frame name length (" + BLZ_FRAMENAME_MAXLENGTH.toString() + ") for: " + name)
error("Trying to address frame with exceeding maximum frame name length (" + BLZ_FRAMENAME_MAXLENGTH + ") for: " + name)
return false
return true

Expand Down Expand Up @@ -178,12 +178,12 @@ public function createGlueTextButton(string name, framehandle owner, string inhe
/** Returns the named command button frame.
In WC3 1.32+, moving command buttons through origin frames can glitch, so the named frames are usually safer. */
public function getCommandButton(int index) returns framehandle
return getFrame("CommandButton_" + index.toString(), 0)
return getFrame("CommandButton_" + index, 0)

/** Returns the named inventory button frame.
In WC3 1.32+, moving item buttons through origin frames can glitch, so the named frames are usually safer. */
public function getInventoryButton(int index) returns framehandle
return getFrame("InventoryButton_" + index.toString(), 0)
return getFrame("InventoryButton_" + index, 0)

/** Destroys a frame.
Unsafe for most multiplayer UI because destroying frames can desync or destabilize frame state after save/load.
Expand Down Expand Up @@ -674,3 +674,4 @@ public function framehandle.getChildrenCount() returns int
The index must be in the range 0 <= index < getChildrenCount(). Out-of-bounds access can crash. */
public function framehandle.getChild(int index) returns framehandle
return BlzFrameGetChild(this, index)

2 changes: 0 additions & 2 deletions wurst/_handles/PlayerTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package PlayerTests
import Player
import Wurstunit

@Test function testPlayer()
let p = Player(0)
Expand Down
2 changes: 0 additions & 2 deletions wurst/_handles/PlayercolorTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package PlayercolorTests
import Playercolor
import Wurstunit

@Test public function testToInt()
PLAYER_COLOR_RED.toInt().assertEquals(0)
Expand Down
3 changes: 2 additions & 1 deletion wurst/_handles/QuestTests.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function QuestState.toString() returns string

function QuestState.assertEquals(QuestState want)
if this != want
testFail("Expected <" + want.toString() + ">, Actual <" + this.toString() + ">")
testFail("Expected <" + want + ">, Actual <" + this + ">")

@Test function testSetState()
let q = new Quest(false /* required */)
Expand All @@ -44,3 +44,4 @@ function QuestState.assertEquals(QuestState want)
q.setDescription("")
q.setIcon("")
q.setTitle("")

2 changes: 0 additions & 2 deletions wurst/_handles/RectTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package RectTests
import Rect
import Wurstunit


@Test
Expand Down
3 changes: 2 additions & 1 deletion wurst/_handles/primitives/PrimitivesTests.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function testBoolean()
@Test
function testArrayLength()
let _x = [1, 2, 3]
print("length: " + _x.length.toString())
print("length: " + _x.length)
_x.length.assertEquals(3)

@Test
Expand All @@ -60,3 +60,4 @@ function testXor()
xor(true, false).assertEquals(true)
xor(false, true).assertEquals(true)
xor(false, false).assertEquals(false)

3 changes: 2 additions & 1 deletion wurst/_handles/primitives/String.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public function string.format(vararg string replacements) returns string
var result = this
var i = 0
for replacement in replacements
result = result.replace("{" + i.toString() + "}", replacement)
result = result.replace("{" + i + "}", replacement)
i++
return result

Expand Down Expand Up @@ -447,3 +447,4 @@ public function string.toLines() returns StringLines
return new StringLines(this, 0, this.countOccurences("\n") + 1)



25 changes: 13 additions & 12 deletions wurst/_wurst/Wurstunit.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ import Annotations
*/
public function int.assertEquals(int expected)
if this != expected
testFail("Expected <" + expected.toString() + ">, Actual <" + this.toString() + ">")
testFail("Expected <" + expected + ">, Actual <" + this + ">")

/**
* Asserts that the passed int is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function int.assertGreaterThan(int less)
if this <= less
testFail("Expected <" + this.toString() + "> to be greater than <" + less.toString() + ">")
testFail("Expected <" + this + "> to be greater than <" + less + ">")

/**
* Asserts that the passed int is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function int.assertGreaterThanOrEqual(int less)
if this < less
testFail("Expected <" + this.toString() + "> to be greater than or equal to <" + less.toString() + ">")
testFail("Expected <" + this + "> to be greater than or equal to <" + less + ">")

/**
* Asserts that the passed int is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function int.assertLessThan(int greater)
if this >= greater
testFail("Expected <" + this.toString() + "> to be less than <" + greater.toString() + ">")
testFail("Expected <" + this + "> to be less than <" + greater + ">")

/**
* Asserts that the passed int is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function int.assertLessThanOrEqual(int greater)
if this > greater
testFail("Expected <" + this.toString() + "> to be less than or equal to <" + greater.toString() + ">")
testFail("Expected <" + this + "> to be less than or equal to <" + greater + ">")

/**
* Asserts that two strings are equal. If they are not, an error is thrown with a message.
Expand All @@ -61,50 +61,50 @@ public function string.assertEquals(string expected)
*/
public function real.assertEquals(real expected)
if this != expected
testFail("Expected <" + expected.toString() + ">, Actual <" + this.toString() + ">")
testFail("Expected <" + expected + ">, Actual <" + this + ">")

/**
* Asserts that the passed real is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function real.assertGreaterThan(real less)
if this <= less
testFail("Expected <" + this.toString() + "> to be greater than <" + less.toString() + ">")
testFail("Expected <" + this + "> to be greater than <" + less + ">")

/**
* Asserts that the passed real is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function real.assertGreaterThanOrEqual(real less)
if this < less
testFail("Expected <" + this.toString() + "> to be greater than or equal to <" + less.toString() + ">")
testFail("Expected <" + this + "> to be greater than or equal to <" + less + ">")

/**
* Asserts that the passed real is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function real.assertLessThan(real greater)
if this >= greater
testFail("Expected <" + this.toString() + "> to be less than <" + greater.toString() + ">")
testFail("Expected <" + this + "> to be less than <" + greater + ">")

/**
* Asserts that the passed real is greater than the parameter. If they are not, an error is thrown with a message.
*/
public function real.assertLessThanOrEqual(real greater)
if this > greater
testFail("Expected <" + this.toString() + "> to be less than or equal to <" + greater.toString() + ">")
testFail("Expected <" + this + "> to be less than or equal to <" + greater + ">")

/**
* Asserts that two reals are equal to within a positive delta. If they are not, an error is thrown
* with a message.
*/
public function real.assertEquals(real expected, real delta)
if (this - expected).abs() > delta
testFail("Expected <" + expected.toString() + ">, Actual <" + this.toString() + " with delta " + delta.toString() + ">")
testFail("Expected <" + expected + ">, Actual <" + this + " with delta " + delta + ">")

/**
* Asserts that two booleans are equal. If they are not, an error is thrown with a message.
*/
public function boolean.assertEquals(boolean expected)
if this != expected
testFail("Expected <" + expected.toString() + ">, Actual <" + this.toString() + ">")
testFail("Expected <" + expected + ">, Actual <" + this + ">")

/** Asserts that this booleans is true. If it is not, an error is thrown with a message. */
public function boolean.assertTrue()
Expand All @@ -128,3 +128,4 @@ public function assertTrue(boolean b, string msg)
public function assertNotNull<T>(T t)
if t == null
testFail("Assertion failed: Reference was null.")

5 changes: 3 additions & 2 deletions wurst/closures/ClosureEvents.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function registerEventId(eventid evnt) returns int
else if evnt.isPlayerunitEvent()
registerPlayerUnitEvent(ConvertPlayerUnitEvent(eventId), function EventListener.generalEventCallback)
else if evnt != EVENT_PLAYER_LEAVE and evnt != EVENT_PLAYER_CHAT_FILTER and not evnt.isKeyboardEvent() and not evnt.isMouseEvent()
error("registering handleid: " + eventId.toString() + " non-playerunitevent. Except EVENT_PLAYER_LEAVE these are not supported right now.")
error("registering handleid: " + eventId + " non-playerunitevent. Except EVENT_PLAYER_LEAVE these are not supported right now.")
if evnt.isMouseEvent() and not EventListener.useMouseEvents
EventListener.useMouseEvents = true
for i = 0 to bj_MAX_PLAYERS - 1
Expand All @@ -290,7 +290,7 @@ public function unregisterEventsForUnit(unit u)
public function unregisterEvents(int id)
if id > 0
if EventListener.unitListenersFirsts[id] != null
Log.trace("unregister unit has listeners. startid: " + id.toString())
Log.trace("unregister unit has listeners. startid: " + id)
var listener = EventListener.unitListenersFirsts[id]
EventListener.unitListenersFirsts[id] = null
while listener != null
Expand Down Expand Up @@ -321,3 +321,4 @@ init
..registerPlayerChatEvent(players[i], "", false)

registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, null, () -> EventListener.onSpellEffect(), null)

1 change: 0 additions & 1 deletion wurst/closures/ClosureTimersTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ClosureTimersTests
import ClosureTimers
import Wurstunit

var x = 200

Expand Down
11 changes: 6 additions & 5 deletions wurst/data/ArrayList.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ public class ArrayList<T:>
/** Returns the element at the specified index (O(1)) */
function get(int index) returns T
if index < 0 or index >= size
error("ArrayList: Index out of bounds: " + index.toString())
error("ArrayList: Index out of bounds: " + index)

return store[startIndex + index]

/** Sets the element at the specified index (O(1)) */
function set(int index, T elem)
if index < 0 or index >= size
error("ArrayList: Index out of bounds: " + index.toString())
error("ArrayList: Index out of bounds: " + index)
store[startIndex + index] = elem

/** Reads the element at the given index via the [] operator (O(1)).
Expand Down Expand Up @@ -351,7 +351,7 @@ public class ArrayList<T:>
remaining elements left to preserve order (O(n)) */
function removeAtOrdered(int index) returns T
if index < 0 or index >= size
error("ArrayList: Index out of bounds: " + index.toString())
error("ArrayList: Index out of bounds: " + index)

let elem = store[startIndex + index]

Expand All @@ -373,7 +373,7 @@ public class ArrayList<T:>
/** Removes the element at the given index by swapping with last element (O(1) - DOES NOT PRESERVE ORDER!) */
function removeAtUnordered(int index) returns T
if index < 0 or index >= size
error("ArrayList: Index out of bounds: " + index.toString())
error("ArrayList: Index out of bounds: " + index)

let elem = store[startIndex + index]

Expand Down Expand Up @@ -510,7 +510,7 @@ public class ArrayList<T:>
/** Adds the given element at the given index - WARNING: O(n) operation! */
function addAt(T elem, int index)
if index < 0 or index > size
error("ArrayList: Index out of bounds: " + index.toString())
error("ArrayList: Index out of bounds: " + index)

if size >= capacity
grow()
Expand Down Expand Up @@ -773,3 +773,4 @@ public function ArrayList<string>.joinBy(string separator) returns string
/** Joins elements from a string list into one string */
public function ArrayList<string>.join() returns string
return this.joinBy("")

1 change: 0 additions & 1 deletion wurst/data/BitSetTests.wurst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package BitSetTests
import BitSet
import Wurstunit

@Test function testGet()
let set = bitset(45)
Expand Down
7 changes: 4 additions & 3 deletions wurst/data/LinkedList.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public class LinkedList<T>
An index equal to the list's size appends to the end. */
function addAt(T elem, int index)
if index < 0 or index > size
error("LinkedList: Index out of bounds: " + index.toString())
error("LinkedList: Index out of bounds: " + index)
let entryAtIndex = getEntryUnchecked(index)
let entry = new LLEntry<T>(elem, entryAtIndex.prev, entryAtIndex)
entryAtIndex.prev.next = entry
Expand Down Expand Up @@ -391,7 +391,7 @@ public class LinkedList<T>
function toString() returns string
if size == 0
return "[]"
let fold = foldl<string>("[", (i, q) -> q + (i castTo int).toString() + ",")
let fold = foldl<string>("[", (i, q) -> q + (i castTo int) + ",")
return fold.substring(0, fold.length()-1) + "]"

/** Removes all elements from the list */
Expand All @@ -412,7 +412,7 @@ public class LinkedList<T>
into the list, silently returning the wrong element. */
private function getEntry(int index) returns LLEntry<T>
if index < 0 or index >= size
error("LinkedList: Index out of bounds: " + index.toString())
error("LinkedList: Index out of bounds: " + index)
return getEntryUnchecked(index)

/** Walks to the entry at the given index without validating it.
Expand Down Expand Up @@ -646,3 +646,4 @@ public function LinkedList<string>.join() returns string

init
realToIndex(0.)

Loading