Created
July 31, 2018 08:25
-
-
Save icy/64ec1838929d448d9f874d1e8261e56a to your computer and use it in GitHub Desktop.
UFCS-unittest.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]); | |
/* | |
The latest test raises error: Error: no property g for type string[] | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link: https://forum.dlang.org/post/zkywlxmtrndlwefdtwoq@forum.dlang.org