@Test
    public void positionalConstructors() throws Exception {
        assertRejected(new ProxyWhitelist(), "new java.lang.Boolean java.lang.String", "['true'] as Boolean");
        assertEvaluate(new StaticWhitelist("new java.lang.Boolean java.lang.String"), true, "['true'] as Boolean");
        String cc = "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedCast java.lang.Class java.lang.Object boolean boolean boolean";
        assertRejected(new StaticWhitelist(cc), "new java.lang.Boolean java.lang.String", "Boolean x = ['true']; x");
        assertEvaluate(new StaticWhitelist(cc, "new java.lang.Boolean java.lang.String"), true, "Boolean x = ['true']; x");
        assertRejected(new ProxyWhitelist(), "new java.util.TreeMap java.util.Map", "[k: 1] as TreeMap");
        assertEvaluate(new StaticWhitelist("new java.util.TreeMap java.util.Map"), Collections.singletonMap("k", 1), "[k: 1] as TreeMap");
        assertRejected(new StaticWhitelist(cc), "new java.util.TreeMap java.util.Map", "TreeMap x = [k: 1]; x");
        assertEvaluate(new StaticWhitelist(cc, "new java.util.TreeMap java.util.Map"), Collections.singletonMap("k", 1), "TreeMap x = [k: 1]; x");
        // These go through a different code path:
        assertEvaluate(new ProxyWhitelist(), Arrays.asList(1), "[1] as LinkedList");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList("v"), "['v'] as LinkedList");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList(1), "LinkedList x = [1]; x");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "LinkedList x = ['v']; x");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList(1), "int[] a = [1]; a as LinkedList");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList("v"), "String[] a = ['v']; a as LinkedList");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "String[] a = ['v']; LinkedList x = a; x");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "String[] a = ['v']; LinkedList x = a; x");
        /* TODO casting arrays is not yet supported:
        assertRejected(new StaticWhitelist(cc), "new java.lang.Boolean java.lang.String", "String[] a = ['true']; Boolean x = a; x");
        assertEvaluate(new StaticWhitelist(cc, "new java.lang.Boolean java.lang.String"), true, "String[] a = ['true']; Boolean x = a; x");
        assertRejected(new ProxyWhitelist(), "new java.lang.Boolean java.lang.String", "String[] a = ['true']; a as Boolean");
        assertEvaluate(new StaticWhitelist("new java.lang.Boolean java.lang.String"), true, "String[] a = ['true']; a as Boolean");
        */
        /* TODO tuple assignment is not yet supported:
        assertRejected(new ProxyWhitelist(), "new java.util.LinkedList java.util.Collection", "String[] a = ['v']; def (LinkedList x, int y) = [a, 1]; x");
        assertEvaluate(new StaticWhitelist("new java.util.LinkedList java.util.Collection"), Arrays.asList("v"), "String[] a = ['v']; def (LinkedList x, int y) = [a, 1]; x");
        */
    }
@Test
    public void positionalConstructors() throws Exception {
        assertRejected(new ProxyWhitelist(), "new java.lang.Boolean java.lang.String", "['true'] as Boolean");
        assertEvaluate(new StaticWhitelist("new java.lang.Boolean java.lang.String"), true, "['true'] as Boolean");
        String cc = "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedCast java.lang.Class java.lang.Object boolean boolean boolean";
        assertRejected(new StaticWhitelist(cc), "new java.lang.Boolean java.lang.String", "Boolean x = ['true']; x");
        assertEvaluate(new StaticWhitelist(cc, "new java.lang.Boolean java.lang.String"), true, "Boolean x = ['true']; x");
        assertRejected(new ProxyWhitelist(), "new java.util.TreeMap java.util.Map", "[k: 1] as TreeMap");
        assertEvaluate(new StaticWhitelist("new java.util.TreeMap java.util.Map"), Collections.singletonMap("k", 1), "[k: 1] as TreeMap");
        assertRejected(new StaticWhitelist(cc), "new java.util.TreeMap java.util.Map", "TreeMap x = [k: 1]; x");
        assertEvaluate(new StaticWhitelist(cc, "new java.util.TreeMap java.util.Map"), Collections.singletonMap("k", 1), "TreeMap x = [k: 1]; x");
       
        assertEvaluate(new ProxyWhitelist(), Arrays.asList(1), "[1] as LinkedList");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList("v"), "['v'] as LinkedList");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList(1), "LinkedList x = [1]; x");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "LinkedList x = ['v']; x");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList(1), "int[] a = [1]; a as LinkedList");
        assertEvaluate(new ProxyWhitelist(), Arrays.asList("v"), "String[] a = ['v']; a as LinkedList");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "String[] a = ['v']; LinkedList x = a; x");
        assertEvaluate(new StaticWhitelist(cc), Arrays.asList("v"), "String[] a = ['v']; LinkedList x = a; x");
       
       
    }
@test public void positionalconstructors() throws exception { assertrejected(new proxywhitelist(), "new java.lang.boolean java.lang.string", "['true'] as boolean"); assertevaluate(new staticwhitelist("new java.lang.boolean java.lang.string"), true, "['true'] as boolean"); string cc = "staticmethod org.kohsuke.groovy.sandbox.impl.checker checkedcast java.lang.class java.lang.object boolean boolean boolean"; assertrejected(new staticwhitelist(cc), "new java.lang.boolean java.lang.string", "boolean x = ['true']; x"); assertevaluate(new staticwhitelist(cc, "new java.lang.boolean java.lang.string"), true, "boolean x = ['true']; x"); assertrejected(new proxywhitelist(), "new java.util.treemap java.util.map", "[k: 1] as treemap"); assertevaluate(new staticwhitelist("new java.util.treemap java.util.map"), collections.singletonmap("k", 1), "[k: 1] as treemap"); assertrejected(new staticwhitelist(cc), "new java.util.treemap java.util.map", "treemap x = [k: 1]; x"); assertevaluate(new staticwhitelist(cc, "new java.util.treemap java.util.map"), collections.singletonmap("k", 1), "treemap x = [k: 1]; x"); assertevaluate(new proxywhitelist(), arrays.aslist(1), "[1] as linkedlist"); assertevaluate(new proxywhitelist(), arrays.aslist("v"), "['v'] as linkedlist"); assertevaluate(new staticwhitelist(cc), arrays.aslist(1), "linkedlist x = [1]; x"); assertevaluate(new staticwhitelist(cc), arrays.aslist("v"), "linkedlist x = ['v']; x"); assertevaluate(new proxywhitelist(), arrays.aslist(1), "int[] a = [1]; a as linkedlist"); assertevaluate(new proxywhitelist(), arrays.aslist("v"), "string[] a = ['v']; a as linkedlist"); assertevaluate(new staticwhitelist(cc), arrays.aslist("v"), "string[] a = ['v']; linkedlist x = a; x"); assertevaluate(new staticwhitelist(cc), arrays.aslist("v"), "string[] a = ['v']; linkedlist x = a; x"); }