Beispiel #1
0
        public void Contains()
        {
            var arr = new MondValue(MondValueType.Array);

            arr.ArrayValue.AddRange(new MondValue[] { 1, 2, 3, 4, 5 });

            Assert.True(arr.Contains(3));
            Assert.False(arr.Contains(10));

            var str = new MondValue("hello world");

            Assert.True(str.Contains("hello"));
            Assert.False(str.Contains("asdf"));

            var obj = new MondValue(new MondState());

            obj["__in"] = new MondFunction((state, args) => args[1].Type == MondValueType.Number);

            Assert.True(obj.Contains(3));
            Assert.False(obj.Contains("hello"));

            Assert.Throws <MondRuntimeException>(() => MondValue.False.Contains(0));
        }