diff options
author | Nicolas Williams <nico@cryptonector.com> | 2014-12-30 13:13:30 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-12-31 20:09:53 -0600 |
commit | ae7f8d6ab9d29bd72f462fdafa4d7a9270706d3b (patch) | |
tree | 3be6c09d87619b65f87e13e4bee4cdf24b064639 /tests/modules | |
parent | 7dc34b92aff7a38e16c0ef608238d03e1ac3d213 (diff) |
Further module system revamp (fix #659)
To import a module now use:
# Import module.jq file:
import "relative/path/to/module" as foo;
# Use the module's defs as foo::<def-name>
To import a JSON file:
# Read file.json:
import "relative/path/to/file" as $foo;
#
# Use as $foo::foo
Using `-L` now drops the builtin library path and appends the requested
path to the empty array (or the result of an earlier `-L`).
Support for the `$JQ_LIBRARY_PATH` environment variable has been
removed.
Diffstat (limited to 'tests/modules')
-rw-r--r-- | tests/modules/a.jq | 2 | ||||
-rw-r--r-- | tests/modules/c/c.jq | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/tests/modules/a.jq b/tests/modules/a.jq index 1bf8d069..01e3c1bb 100644 --- a/tests/modules/a.jq +++ b/tests/modules/a.jq @@ -1,2 +1,2 @@ -module a {version:1.7}; +module {version:1.7}; def a: "a"; diff --git a/tests/modules/c/c.jq b/tests/modules/c/c.jq index d5000067..4a6a8ed3 100644 --- a/tests/modules/c/c.jq +++ b/tests/modules/c/c.jq @@ -1,12 +1,14 @@ -module c {whatever:null}; -import a as foo; -import d as d {search:"./"}; -import d {search:"./"}; -import e as e {search:"./../lib/jq"}; -import f as f {search:"./../lib/jq"}; +module {whatever:null}; +import "a" as foo; +import "d" as d {search:"./"}; +import "d" as d2{search:"./"}; +import "e" as e {search:"./../lib/jq"}; +import "f" as f {search:"./../lib/jq"}; +import "data" as $d; def a: 0; def c: - if meh != d::meh then error("import into namespace doesn't work") + if $d::d[0] != {this:"is a test",that:"is too"} then error("data import is busted") + elif d2::meh != d::meh then error("import twice doesn't work") elif foo::a != "a" then error("foo::a didn't work as expected") elif d::meh != "meh" then error("d::meh didn't work as expected") elif e::bah != "bah" then error("e::bah didn't work as expected") |