01 
02 /*
03  *  Descripter 1.0 - Java Script Engines
04  *  Copyright (C) 2010-2015  Jianjun Liu (J.J.Liu)
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package org.descripter;
21 
22 import org.descripter.js.api.Core;
23 import org.descripter.js.api.Global;
24 
25 /**
26  * <p>Tests Descripting JavaScript.</p>
27  * 
28  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.descripter.org" target="_blank">http://www.descripter.org</a>
29  * @since Descripter 1.0
30  */
31 public class Descripters extends Global<Core>
32 {
33     /**
34      * <p>Constructs a {@link Global} script context of this type.</p>
35      * @param with The containing {@link Core} context.
36      * @since Descripter 1.0
37      */
38     public Descripters(Core with) {
39         super(with);
40     }
41 
42     /**
43      * <p>Executes the script context of this type.</p>
44      * @since Descripter 1.0
45      */
46     @Override
47     public void run() {
48 //      print(descript("org.descripter.Test", "return;return 'aaa';return 111 ;return new Object; return new String('aaaastr') ; return /asdgsdg/ig;"));
49 //      print(descript("org.descripter.Test", "return;"));
50 //      print(descript("org.descripter.Test", "return 'asd';"));
51 //      print(descript("org.descripter.Test", "return new String();return new String('asdgasd');return new Object;return new String('asdgasd');return new new Function;return new new new Function;return new Function('gsg')[1];"));
52 //      print(descript("org.descripter.Test", "return new new Function;"));
53 //      print(descript("org.descripter.Test", "return [Object, oo, 1 + 2, 'fasdg', true];"));
54 //      print(descript("org.descripter.Test", "return {gadgs:111,  fgdfgd:true,fgd:'gdg',,,};"));
55 //      print(descript("org.descripter.Test", "bbb=cc(),aaa=print('asd');if(true!=true){print('if');return 'gsdg';}else{print('else');gsgsd()};"));
56 //      print(descript("org.descripter.Test", "while(true){print('while');};"));
57 //      print(descript("org.descripter.Test", "return -1+55-(gggs++)+(--gsdgfff)+'gds'-3+666*2/5*6-9-8-gsgd--;return ++gsgas;return gasg--;with(gdgg){print('gggg')}throw vv;DOW:do{print('dowhile');break DOW;}while(true);"));
58 //      print(descript("org.descripter.Test", "DOW:do{print('dowhile');break DOW;}while((aaaa>=7)==false);"));
59 //      print(descript("org.descripter.Test", "return;var u=3,v=5,a;for(var aa=1;aa<=1;aa++){break;break DGSG;print('here');asdg();throw aa;}return v;"));
60 //      print(descript("org.descripter.Test", "function f(a,b){print(a);print(b);};f(11,'gsdgsg');"));
61 //      print(descript("org.descripter.Test", "try{DOW:do{print('dowhile');break DOW;}while((aaaa>=7)==false);throw 12;}catch(e){print(e);}finally{print('finally');};"));
62         print(descript("org.descripter.Test", "for(a in Object){print(a);};#System.out.println(\"Hello Hash!\");"));
63         print(descript("org.descripter.Test", "print(Math.sin(Math.PI/4));"));
64 //      print(descript("org.descripter.Test", "switch('gds'){case 'gf':{print('gf');}default:print('default');case 'gds':print('gds');}"));
65 //      print(descript("org.descripter.Test", "for(i=0;i<6;i++){print('for'+i);}"));
66     }
67 
68     /**
69      * <p>Creates and runs {@link Global} script contexts of the containing type.</p>
70      * @param args Ignored
71      * @since Descripter 1.0
72      */
73     public static void main(String[] args) {
74         Core c = new Core();
75         new Descripters(c).run();
76     }
77 }