fail_errors.carbon 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/if/fail_errors.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if/fail_errors.carbon
  10. fn F() {
  11. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:6: ERROR: Expected `(` after `if`.
  12. // CHECK:STDERR: if a {}
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR:
  15. if a {}
  16. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:7: ERROR: Expected expression.
  17. // CHECK:STDERR: if () {}
  18. // CHECK:STDERR: ^
  19. // CHECK:STDERR:
  20. if () {}
  21. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:9: ERROR: Unexpected tokens before `)`.
  22. // CHECK:STDERR: if (b c) {}
  23. // CHECK:STDERR: ^
  24. // CHECK:STDERR:
  25. if (b c) {}
  26. if (d)
  27. // CHECK:STDERR: fail_errors.carbon:[[@LINE+7]]:1: ERROR: Expected braced code block.
  28. // CHECK:STDERR: }
  29. // CHECK:STDERR: ^
  30. // CHECK:STDERR:
  31. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:1: ERROR: Expected expression.
  32. // CHECK:STDERR: }
  33. // CHECK:STDERR: ^
  34. }
  35. // CHECK:STDOUT: - filename: fail_errors.carbon
  36. // CHECK:STDOUT: parse_tree: [
  37. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  38. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  39. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'F'},
  40. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  41. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
  42. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  43. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  44. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
  45. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  46. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  47. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  48. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  49. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  50. // CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes},
  51. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  52. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  53. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  54. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  55. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  56. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
  57. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  58. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  59. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  60. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  61. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  62. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'd'},
  63. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  64. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
  65. // CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
  66. // CHECK:STDOUT: {kind: 'ExprStatement', text: ')', has_error: yes, subtree_size: 2},
  67. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 4},
  68. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  69. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 32},
  70. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  71. // CHECK:STDOUT: ]