diff --git a/src/config.nim b/src/config.nim index 40281d9..64ec5c1 100644 --- a/src/config.nim +++ b/src/config.nim @@ -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) diff --git a/tests/test1.nim b/tests/notest1.nim similarity index 100% rename from tests/test1.nim rename to tests/notest1.nim diff --git a/tests/test2.nim b/tests/notest2.nim similarity index 100% rename from tests/test2.nim rename to tests/notest2.nim diff --git a/tests/test3.nim b/tests/test3.nim new file mode 100644 index 0000000..e520e86 --- /dev/null +++ b/tests/test3.nim @@ -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"