Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'type error during .tst.restore when mocking data namespace within the global namespace #4

Open
danielkrizian opened this issue Jan 1, 2021 · 0 comments · May be fixed by #5
Open

Comments

@danielkrizian
Copy link

Mocking the data namespace (without the leading dot):

$ cat test.q
.tst.desc["Mocking"]{
 should["support data namespace within the global namespace"]{
  `myns.a mock `foo;
  `myns.b mock `bar;
  };
 };

throws a 'type error (namespaces with the leading dot work fine).
Exploring the environment reveals the root cause:

$ testq --fail-hard test.q
'type
  [9]  /home/dk/conda/q/lib/qspec-1.3.3/mock.q:28: .tst.restore:
 / Drop each fully qualified symbol from its respective namespace
 if[count removeList;(.[;();_;]') . flip ((` sv -1 _;last) @\: ` vs) each removeList];
                                  ^
 `.tst.removeList set ();
q.tst))`myns.a`myns.b in removeList
11b
q.tst))-3!myns
"()"
q.tst))get `..myns
 | ::
a| `foo
b| `bar
q.tst))flip ((` sv -1 _;last) @\: ` vs) each `myns.a`myns.b
myns myns
a    b   
q.tst)).[`myns;();_;`a]               / failure
'type
  [11] .[`myns;();_;`a]
       ^
q.tst)).[`..myns;();_;`a]             / success
`..myns
q.tst))get `..myns
 | ::
b| `bar

Data namespaces (the ones without the leading dot) within removeList are malformed. Instead of `ns.a`ns.b , their fully-qualified name should be `..ns.a`..ns.b.

The related code: https://github.com/nugend/qspec/blob/master/lib/mock.q#L9-L11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant