コード例 #1
0
        public void BuiltinFunctionsTest()
        {
            var workingCases = new IntegerTests[]
            {
                new() { Input = "length(\"\");", Expected = 0 },
                new() { Input = "length('something');", Expected = 9 },
                new() { Input = "length('hello world');", Expected = 11 }
            };
            var casesWithErrors = new OperatorTest[]
            {
                new() { Input = "length(1);", Expected = "[SC8] invalid operation: {op} has no length." },
                new() { Input = "length('one', '2');", Expected = "[SC7] wrong number of arguments: expected 1, got 2" }
            };

            foreach (var lengthWorkingTest in workingCases)
            {
                StaticTests.TestBuiltinFunction(lengthWorkingTest.Input, lengthWorkingTest.Expected);
            }

            foreach (var casesWithError in casesWithErrors)
            {
                StaticTests.TestBuiltinFunction(casesWithError.Input, casesWithError.Expected);
            }
        }
    }
}