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
Branches
No related tags found
No related merge requests found
...@@ -47,7 +47,8 @@ public abstract class Vector extends RBuiltinNode { ...@@ -47,7 +47,8 @@ public abstract class Vector extends RBuiltinNode {
@Override @Override
protected void createCasts(CastBuilder casts) { 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) { protected RType modeToType(String mode) {
......
...@@ -65,6 +65,11 @@ public class TestBuiltin_vector extends TestBase { ...@@ -65,6 +65,11 @@ public class TestBuiltin_vector extends TestBase {
assertEval("{ vector(\"numeric\", length=4) }"); assertEval("{ vector(\"numeric\", length=4) }");
assertEval("{ vector(length=3) }"); assertEval("{ vector(length=3) }");
assertEval("{ x<-as.vector(3); y<-vector(length=x) }"); 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 @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment