Beispiel #1
0
        private void VerifyErrorSpecial(CSharpSyntaxNode node, DirectiveInfo expected)
        {
            var diags = node.ErrorsAndWarnings();
            Assert.Equal(1, diags.Length);
            var actual = diags[0];
            Assert.Equal(expected.Number, actual.Code);

            // warning or not
            if (NodeStatus.IsWarning == (expected.Status & NodeStatus.IsWarning))
            {
                Assert.Equal(DiagnosticSeverity.Warning, actual.Severity);
            }

            // error message
            if (expected.Text != null)
            {
                Assert.Equal(expected.Text, actual.GetMessage(CultureInfo.InvariantCulture));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Verifies that the errors on the given CSharpSyntaxNode match the expected error codes and types
 /// </summary>
 /// <param name="node">The node that has errors</param>
 /// <param name="errors">The list of expected errors</param>
 private void VerifyDiagnostics(CSharpSyntaxNode node, List<TestError> errors)
 {
     VerifyDiagnostics(node.ErrorsAndWarnings(), errors);
 }
Beispiel #3
0
        private void VerifyErrorCode(CSharpSyntaxNode node, params int[] expected)
        {
            var actual = node.ErrorsAndWarnings().Select(e => e.Code).ToList();

            // no error
            if ((expected.Length == 0) && (actual.Count == 0))
            {
                return;
            }

            // Parser might give more errors than expected & that's fine
            Assert.InRange(actual.Count, expected.Length, int.MaxValue);

            // necessary?
            if (actual.Count < expected.Length)
            {
                return;
            }

            foreach (int i in expected)
            {
                Assert.Contains(i, actual); // no order
            }
        }