Hi,

Can I define a new quick function to use inside a unittest block?

I have the following code:

[code]
auto foo(string[] sta) {
  return sta;
}

auto bar(string[] sta) {
  return sta;
}

auto h(string[] sta) {
  return sta.foo.bar;
}

unittest {
  import std.format;

  auto f = (string[] sta) => sta.foo.bar;
  auto g(string[] sta) {
    return sta.foo.bar;
  }

  assert(f(["test"]) == ["test"]);
  assert(g(["test"]) == ["test"]);
  assert(["test"].h == ["test"]);
  assert(["test"].g == ["test"]);
}
[/code]

(Src: https://gist.github.com/icy/64ec1838929d448d9f874d1e8261e56a)

The last test will fail: Error: no property g for type string[]

Please advise.

Thanks a lot.



Reply via email to