void AssertTableValues(Table t)
        {
            Assert.AreEqual(DataType.Number, t.Get("aNumber").Type);
            Assert.AreEqual(1, t.Get("aNumber").Number);

            Assert.AreEqual(DataType.String, t.Get("aString").Type);
            Assert.AreEqual("2", t.Get("aString").String);

            Assert.AreEqual(DataType.Table, t.Get("anObject").Type);
            Assert.AreEqual(DataType.Table, t.Get("anArray").Type);

            Assert.AreEqual(DataType.String, t.Get("slash").Type);
            Assert.AreEqual("a/b", t.Get("slash").String);

            Table o = t.Get("anObject").Table;

            Assert.AreEqual(DataType.Number, o.Get("aNumber").Type);
            Assert.AreEqual(3, o.Get("aNumber").Number);

            Assert.AreEqual(DataType.String, o.Get("aString").Type);
            Assert.AreEqual("4", o.Get("aString").String);

            Table a = t.Get("anArray").Table;

            //				'anArray' : [ 5, '6', true, null, { 'aNumber' : 7, 'aString' : '8' } ]

            Assert.AreEqual(DataType.Number, a.Get(1).Type);
            Assert.AreEqual(5, a.Get(1).Number);

            Assert.AreEqual(DataType.String, a.Get(2).Type);
            Assert.AreEqual("6", a.Get(2).String);

            Assert.AreEqual(DataType.Boolean, a.Get(3).Type);
            Assert.IsTrue(a.Get(3).Boolean);

            Assert.AreEqual(DataType.Boolean, a.Get(3).Type);
            Assert.IsTrue(a.Get(3).Boolean);

            Assert.AreEqual(DataType.UserData, a.Get(4).Type);
            Assert.IsTrue(JsonNull.IsJsonNull(a.Get(4)));

            Assert.AreEqual(DataType.Table, a.Get(5).Type);
            Table s = a.Get(5).Table;

            Assert.AreEqual(DataType.Number, s.Get("aNumber").Type);
            Assert.AreEqual(7, s.Get("aNumber").Number);

            Assert.AreEqual(DataType.String, s.Get("aString").Type);
            Assert.AreEqual("8", s.Get("aString").String);

            Assert.AreEqual(DataType.Number, t.Get("aNegativeNumber").Type);
            Assert.AreEqual(-9, t.Get("aNegativeNumber").Number);
        }
示例#2
0
        public static DynValue isnull(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            DynValue vs = args[0];

            return(DynValue.NewBoolean((JsonNull.IsJsonNull(vs)) || (vs.IsNil())));
        }