public void TestNewInnerGenericClass() { CSNode root = ParseScript("CSScript.Test.GenericOne<int>.Inner<float, string> a = new CSScript.Test.GenericOne<int>.Inner<float, string>(3.3f, \"hoge\");"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(CSScript.Test.GenericOne <int> .Inner <float, string>), obj.Type); Assert.AreEqual(3.3f, obj.GetAs <CSScript.Test.GenericOne <int> .Inner <float, string> > ()._a); Assert.AreEqual("hoge", obj.GetAs <CSScript.Test.GenericOne <int> .Inner <float, string> > ()._b); }
public void TestLocalVariable() { CSNode root = ParseScript("int a = 33; int b = a;"); CSObject obj = root.Evaluate(); Assert.AreEqual("b", obj.Name); Assert.AreEqual(33, obj.GetAs <int> ()); }
public void TestStaticProperty() { CSNode root = ParseScript("CSScript.Test.Simple.Hoge = \"HelloWorld\"; CSScript.Test.Simple.Hoge;"); CSObject obj = root.Evaluate(); Assert.AreEqual("Hoge", obj.Name); Assert.AreEqual("HelloWorld", obj.GetAs <string> ()); }
public void TestLocalVariable2() { CSNode root = ParseScript("CSScript.Test.Simple s = new CSScript.Test.Simple(33); int b = s._a;"); CSObject obj = root.Evaluate(); Assert.AreEqual("b", obj.Name); Assert.AreEqual(33, obj.GetAs <int> ()); }
public void TestStaticVariable() { CSNode root = ParseScript("CSScript.Test.Simple.HELLO = \"HelloWorld\"; CSScript.Test.Simple.HELLO;"); CSObject obj = root.Evaluate(); Assert.AreEqual("HELLO", obj.Name); Assert.AreEqual("HelloWorld", obj.GetAs <string> ()); }
public void TestTypeIntArray() { CSNode root = ParseScript("int[] a = new int[3];"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(int[]), obj.Type); Assert.AreEqual(3, obj.GetAs <int[]> ().Length); }
public void TestTypeDictionaryAraray() { CSNode root = ParseScript("System.Collections.Generic.Dictionary<string, int>[] a = new System.Collections.Generic.Dictionary<string, int>[3];"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(System.Collections.Generic.Dictionary <string, int>[]), obj.Type); Assert.AreEqual(3, obj.GetAs <System.Collections.Generic.Dictionary <string, int>[]> ().Length); }
public void TestNewInnerClass() { CSNode root = ParseScript("CSScript.Test.Simple.Inner a = new CSScript.Test.Simple.Inner (33);"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(CSScript.Test.Simple.Inner), obj.Type); Assert.AreEqual(33, obj.GetAs <CSScript.Test.Simple.Inner> ()._a); }
public void TypedVarSimple() { CSNode root = ParseScript("CSScript.Test.Simple a = new CSScript.Test.Simple(3);"); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(typeof(Simple), obj.Type); Assert.AreEqual(3, obj.GetAs <Simple> ()._a); }
public void NewArrayList() { CSNode root = ParseScript("var a = new System.Collections.Generic.List<int>[2];"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(List <int>[]), obj.Type); List <int>[] arr = obj.GetAs <List <int>[]> (); Assert.AreEqual(2, arr.Length); }
public void TestStaticMethod () { CSNode root = ParseScript ( "string a = CSScript.Test.Simple.StaticMethod(\"moge\");" ); CSObject obj = root.Evaluate (); Assert.AreEqual ("a", obj.Name); Assert.AreEqual ("moge", obj.GetAs<string> ()); }
public void NewArrayInt() { CSNode root = ParseScript("var a = new int[32];"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(int[]), obj.Type); int[] arr = obj.GetAs <int[]> (); Assert.AreEqual(32, arr.Length); }
public void TestStaticVariable2() { CSNode root = ParseScript( "CSScript.Test.GenericOne<int>._s = new CSScript.Test.Simple (34);" + "int a = CSScript.Test.GenericOne<int>._s._a;"); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(34, obj.GetAs <int> ()); }
public void TestMethodInt () { CSNode root = ParseScript ( "CSScript.Test.Simple s = new CSScript.Test.Simple(55);\n" + "int a = s.GetInt();" ); CSObject obj = root.Evaluate (); Assert.AreEqual ("a", obj.Name); Assert.AreEqual (55, obj.GetAs<int> ()); }
public void TestLocalVariable3() { CSNode root = ParseScript( "CSScript.Test.Simple s = new CSScript.Test.Simple(33);\n" + "CSScript.Test.GenericOne<CSScript.Test.Simple> g = new CSScript.Test.GenericOne<CSScript.Test.Simple>(s);\n" + "int b = g._pa._a;"); CSObject obj = root.Evaluate(); Assert.AreEqual("b", obj.Name); Assert.AreEqual(33, obj.GetAs <int> ()); }
public void NewInitializerClassArray() { CSNode root = ParseScript("var a = new CSScript.Test.Simple[]{new CSScript.Test.Simple(1), new CSScript.Test.Simple(2)};"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(Simple[]), obj.Type); Simple[] arr = obj.GetAs <Simple[]> (); Assert.AreEqual(2, arr.Length); Assert.AreEqual(1, arr[0]._a); Assert.AreEqual(2, arr[1]._a); }
public void TestListInt() { CSNode root = ParseScript( "System.Collections.Generic.List<int> aa = new System.Collections.Generic.List<int>(){1,2,3,4};" + "int a = aa[2];" ); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(3, obj.GetAs <int> ()); }
public void TypedVarDictionary() { CSNode root = ParseScript("System.Collections.Generic.Dictionary<string,int> a \n" + "= new System.Collections.Generic.Dictionary<string,int>(){\n" + "{\"hoge\", 3}\n" + "};" ); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(typeof(System.Collections.Generic.Dictionary <string, int>), obj.Type); Assert.AreEqual(3, obj.GetAs <System.Collections.Generic.Dictionary <string, int> > () ["hoge"]); }
public void TestDictionaryAssign() { CSNode root = ParseScript( "System.Collections.Generic.Dictionary<string, CSScript.Test.Simple> aa = new System.Collections.Generic.Dictionary<string, CSScript.Test.Simple> ();" + "aa[\"moge\"] = new CSScript.Test.Simple(55);" + "int a = aa[\"moge\"]._a;\n" ); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(55, obj.GetAs <int> ()); }
public void NewInitializerIntArray() { CSNode root = ParseScript("var a = new int[]{1,2,3};"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(int[]), obj.Type); int[] arr = obj.GetAs <int[]> (); Assert.AreEqual(3, arr.Length); Assert.AreEqual(1, arr[0]); Assert.AreEqual(2, arr[1]); Assert.AreEqual(3, arr[2]); }
public void TestDictionary() { CSNode root = ParseScript( "System.Collections.Generic.Dictionary<string, CSScript.Test.Simple> aa = new System.Collections.Generic.Dictionary<string, CSScript.Test.Simple> (){\n" + " {\"hoge\", new CSScript.Test.Simple(33)},\n"+ " {\"moge\", new CSScript.Test.Simple(44)},\n"+ "};\n" + "int a = aa[\"moge\"]._a;\n" ); CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(44, obj.GetAs <int> ()); }
public void TestArrayInt() { CSNode root = ParseScript( "int[] aa = new int[]{1,2,3,4};" + "int a = aa[2];" ); List <int> a = new List <int> () { 1, 2, 3, 4 }; CSObject obj = root.Evaluate(); Assert.AreEqual("a", obj.Name); Assert.AreEqual(3, obj.GetAs <int> ()); }
public void NewInitializerClass() { CSNode root = ParseScript("var a = new CSScript.Test.Simple(){" + "_a = 4," + "_s = \"doge\"," + "_i = new CSScript.Test.Simple(66)," + "};"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(Simple), obj.Type); Simple s = obj.GetAs <Simple> (); Assert.AreEqual(4, s._a); Assert.AreEqual("doge", s._s); Assert.AreEqual(66, s._i._a); }
public void NewInitializerDictionary() { CSNode root = ParseScript("var a = new System.Collections.Generic.Dictionary<string, CSScript.Test.Simple>(){" + " {\"hoge\", new CSScript.Test.Simple (1)}," + " {\"moge\", new CSScript.Test.Simple (2)}," + "};"); CSObject obj = root.Evaluate(); Assert.AreEqual(typeof(Dictionary <string, Simple>), obj.Type); Dictionary <string, Simple> dict = obj.GetAs <Dictionary <string, Simple> > (); Assert.AreEqual(2, dict.Count); Assert.AreEqual(1, dict["hoge"]._a); Assert.AreEqual(2, dict["moge"]._a); }