make more tests green

This commit is contained in:
Andreas Rumpf 2018-08-13 12:29:03 +02:00
commit 7f49364fd0
16 changed files with 39 additions and 102 deletions

View file

@ -74,14 +74,14 @@ type
## nothing prevents you from accessing directly the type of field you want
## if you expect only one kind.
case kind*: Tparam_kind
of PK_EMPTY: nil
of PK_EMPTY: discard
of PK_INT: int_val*: int
of PK_BIGGEST_INT: big_int_val*: BiggestInt
of PK_FLOAT: float_val*: float
of PK_BIGGEST_FLOAT: big_float_val*: BiggestFloat
of PK_STRING: str_val*: string
of PK_BOOL: bool_val*: bool
of PK_HELP: nil
of PK_HELP: discard
Tcommandline_results* = object of RootObj ## \
## Contains the results of the parsing.
@ -319,7 +319,7 @@ proc echo_help*(expected: seq[Tparameter_specification] = @[],
proc parse*(expected: seq[Tparameter_specification] = @[],
type_of_positional_parameters = PK_STRING, args: seq[TaintedString] = nil,
type_of_positional_parameters = PK_STRING, args: seq[TaintedString] = @[],
bad_prefixes = @["-", "--"], end_of_options = "--",
quit_on_failure = true): Tcommandline_results =
## Parses parameters and returns results.
@ -339,7 +339,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[],
##
## The args sequence should be the list of parameters passed to your program
## without the program binary (usually OSes provide the path to the binary as
## the zeroth parameter). If args is nil, the list will be retrieved from the
## the zeroth parameter). If args is empty, the list will be retrieved from the
## OS.
##
## If there is any kind of error and quit_on_failure is true, the quit proc
@ -358,7 +358,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[],
# Prepare the input parameter list, maybe get it from the OS if not available.
var args = args
if args == nil:
if args.len == 0:
let total_params = paramCount()
#echo "Got no explicit args, retrieving from OS. Count: ", total_params
newSeq(args, total_params)

View file

@ -145,7 +145,7 @@ proc importHandling(data: JsonNode): THandlingRecord
proc importBullet(data: JsonNode; errors: var seq[string]): PBulletRecord
proc importSoul(data: JsonNode): TSoulRecord
proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord
proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord
proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = ""): PSoundRecord
## this is the only pipe between lobby and main.nim
proc getActiveState*(): TGameState =
@ -514,7 +514,7 @@ proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord
let expl = data["explode"]
result.anim = importAnim(expl, errors)
result.sound = importSound(expl, errors, "sound")
proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord =
proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = ""): PSoundRecord =
if data.kind == JObject:
checkKey(data, fieldName)
result = newSound(data[fieldName].str, errors)

View file

@ -92,8 +92,8 @@ proc newGuiContainer*(pos: TVector2f): PGuiContainer =
result = newGuiContainer()
result.setPosition pos
proc free*(container: PGuiContainer) =
container.widgets = nil
container.buttons = nil
container.widgets = @[]
container.buttons = @[]
proc add*(container: PGuiContainer; widget: PGuiObject) =
container.widgets.add(widget)
proc add*(container: PGuiContainer; button: PButton) =