fail_missing_matched_expr.carbon 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/match/fail_missing_matched_expr.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/match/fail_missing_matched_expr.carbon
  10. fn f() -> i32 {
  11. // CHECK:STDERR: fail_missing_matched_expr.carbon:[[@LINE+4]]:9: error: expected `(` after `match` [ExpectedParenAfter]
  12. // CHECK:STDERR: match {
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR:
  15. match {
  16. default => { return 1; }
  17. }
  18. return 0;
  19. }
  20. // CHECK:STDOUT: - filename: fail_missing_matched_expr.carbon
  21. // CHECK:STDOUT: parse_tree: [
  22. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  23. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  24. // CHECK:STDOUT: {kind: 'IdentifierNameMaybeBeforeSignature', text: 'f'},
  25. // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
  26. // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2},
  27. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  28. // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
  29. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7},
  30. // CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'},
  31. // CHECK:STDOUT: {kind: 'MatchConditionStart', text: 'match', has_error: yes},
  32. // CHECK:STDOUT: {kind: 'InvalidParse', text: '{', has_error: yes},
  33. // CHECK:STDOUT: {kind: 'MatchCondition', text: 'match', has_error: yes, subtree_size: 3},
  34. // CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
  35. // CHECK:STDOUT: {kind: 'MatchDefaultIntroducer', text: 'default'},
  36. // CHECK:STDOUT: {kind: 'MatchDefault', text: '=>', subtree_size: 2},
  37. // CHECK:STDOUT: {kind: 'MatchHandlerStart', text: '{', subtree_size: 3},
  38. // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
  39. // CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
  40. // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
  41. // CHECK:STDOUT: {kind: 'MatchHandler', text: '}', subtree_size: 7},
  42. // CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 13},
  43. // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
  44. // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
  45. // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
  46. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 24},
  47. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  48. // CHECK:STDOUT: ]