Skip to content

Commit

Permalink
First attempt to reduce test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Aug 8, 2023
1 parent b013bde commit 469ed76
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ var IDENTIFIER_PATTERN = re(r"(*U)^(?!\d)(\w+)$")
proc isIdentifier(s: string): bool =
s.match(IDENTIFIER_PATTERN).isSome

proc parsePath(s: string): ASTNode =
proc parsePath*(s: string): ASTNode =

proc fail(loc: Location) =
raise newConfigError(&"invalid path: {s}", loc)
Expand Down
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions tests/test3.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright 2016-2023 by Vinay Sajip. All Rights Reserved.
#
import complex
import os
import strutils
import tables
import times
import typetraits
import unittest

import ../src/config

proc dataFilePath(paths: varargs[string]): string =
"tests" / "resources" / paths.join("/")

#
# Config
#

proc CV(s: string): ConfigValue =
ConfigValue(kind: StringValue, stringValue: s)


test "main config":
var p = dataFilePath("derived", "main.cfg")
var cfg = newConfig()
cfg.includePath.add(dataFilePath("base"))
cfg.loadFile(p)

var lcfg = cfg.getSubConfig("logging")
var ev = CV("bar")
check ev == lcfg.get("foo.bar", ev)
#ev.stringValue = "bozz"
echo "Before test"
discard parsePath("handlers.debug.lvl")
#check ev == lcfg.get("handlers.debug.lvl", ev)
echo "After test"

0 comments on commit 469ed76

Please sign in to comment.