Skip to content
Snippets Groups Projects
Commit 20a026b1 authored by Adam Welc's avatar Adam Welc
Browse files

Rewritten parameter casts for the vector builtin.

parent 3881ae40
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,8 @@ public abstract class Vector extends RBuiltinNode {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg("length").asIntegerVector().mustBe(singleElement()).findFirst();
casts.arg("mode").defaultError(RError.SHOW_CALLER, RError.Message.INVALID_ARGUMENT, "mode").asStringVector().mustBe(singleElement()).findFirst();
casts.arg("length").defaultError(RError.SHOW_CALLER, RError.Message.INVALID_ARGUMENT, "length").asIntegerVector().mustBe(singleElement()).findFirst();
}
protected RType modeToType(String mode) {
......
......@@ -65,6 +65,11 @@ public class TestBuiltin_vector extends TestBase {
assertEval("{ vector(\"numeric\", length=4) }");
assertEval("{ vector(length=3) }");
assertEval("{ x<-as.vector(3); y<-vector(length=x) }");
assertEval("{ vector(character()) }");
assertEval("{ vector(c(\"numeric\", \"numeric\")) }");
assertEval("{ vector(\"numeric\", integer()) }");
assertEval("{ vector(\"numeric\", c(7, 42)) }");
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment