package Sequenic.T2.Obj; import org.junit.Test; import org.scribe.model.T3TestToken; import static org.junit.Assert.* ; import java.util.*; import Common.Common; import Sequenic.T2.Obj.XShow; import Sequenic.T3.T3Cmd; import Sequenic.T3.Generator.*; import Sequenic.T3.Sequence.Datatype.*; import static Sequenic.T3.Generator.GenCombinators.FirstOf; import static Sequenic.T3.Generator.Value.ValueMGCombinators.* ; public class T3TestXShow { static class Item { String id ; String type = "dummy" ; static int limit = 100 ; } static class Link extends Item { Link next ; Link(int k, Link next) { id = "id " + k ; this.next = next ; } } static Link cycle() { Link o = new Link(0, new Link(1, null)) ; o.next.next = o ; return o ; } static Link deep(int k) { Link o = null ; for (int i = 0 ; i s = new LinkedList() ; s.add(x) ; s.add(y) ; s.add(x) ; Object[] obs = { new Integer(1), "a string", RGB.RED, new Random(), // example of an object from XShow's compact-show list x, cycle(), deep(15), a, s } ; objects = obs ; }; Object o = objects[i % objects.length] ; //System.out.println("+++ generating " + o.getClass()) ; return o ; } static public Generator myvalgen = FirstOf( Integer(OneOf(-1,0,1,2,3,4,5)), Apply(T3TestXShow.class,"gen", OneOf(0,1,2,3,4,5,6,7,8)).WithChance(0.7) // .If(hasParamName("o")) --> ideally like this, but can't do this since we have to compile CUT in 1.7 .If(hasClass(Object.class)) ) ; public static void CUTconfigure() { //XShow.veryCompactShow.add(XShow.class) ; List includedFields = new LinkedList() ; includedFields.add("next") ; includedFields.add("id") ; XShow.showFilter.put(Link.class,includedFields) ; } public static void generate(String CUT, boolean withCustomgen, boolean injectOracle, int multiplier, Boolean adt) throws Exception { String cvgOption = "" ; String oracleOption = "" ; String adtOption = "" ; if (withCustomgen) cvgOption = " -cvg Sequenic.T2.Obj.T3TestXShow " ; if (!injectOracle) oracleOption =" -norc " ; if (adt!=null && adt) adtOption = " -adt true " ; else adtOption = " -adt false " ; CUTconfigure() ; T3Cmd.main("-reg -core 1 -fup 0 -ms " + multiplier // -pl 3 -vp -sl 3 + cvgOption + oracleOption + adtOption + " -sd " + Common.getCUTrootBindir() + " -d " + Common.getTrDir() + " " + CUT); } static String CUT = "Sequenic.T2.Obj.XShow" ; @Test public void testPlainWithOracles() throws Throwable { generate(CUT,false,true,50,true) ; generate(CUT,false,true,10,false) ; } @Test public void testWithCustomGenWithOracles() throws Throwable { generate(CUT,true,true,50,true) ; generate(CUT,true,true,10,false) ; } // without injected oracles: //@Test public void testPlain() throws Throwable { generate(CUT,false,false,50,true) ; generate(CUT,false,false,10,false) ; } // without injected oracles: //@Test public void testWithCustomGen() throws Throwable { generate(CUT,true,false,50,true) ; generate(CUT,true,false,10,false) ; } }