public static void VerifyMatch(EcmaValue pattern, EcmaValue flags, EcmaValue input, object[] expected, int index) { EcmaValue re = default; That(() => re = RegExp.Construct(pattern, flags), Throws.Nothing, FormatArguments(Undefined, new[] { pattern, flags })); RuntimeObject fn = TestContext.CurrentContext.Test.Arguments.FirstOrDefault() as RuntimeObject; if (fn == null || fn.IsIntrinsicFunction(WellKnownObject.RegExpPrototype, "test")) { fn = re.ToObject().GetMethod("exec"); } EcmaValue actual = fn.Call(re, input); if (expected != null) { That(actual, Is.EquivalentTo(expected), "RegExp={0}, Input={1}", re, input); That(actual["index"], Is.EqualTo(index), "RegExp={0}, Input={1}", re, input); } else { That(actual, Is.EqualTo(Null), "RegExp={0}, Input={1}", re, input); } }