defined_method.carbon 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/generics/named_constraint/defined_method.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/generics/named_constraint/defined_method.carbon
  10. constraint Foo {
  11. fn Add[self: Self](b: Self) -> Self {}
  12. }
  13. // CHECK:STDOUT: - filename: defined_method.carbon
  14. // CHECK:STDOUT: parse_tree: [
  15. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  16. // CHECK:STDOUT: {kind: 'NamedConstraintIntroducer', text: 'constraint'},
  17. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Foo'},
  18. // CHECK:STDOUT: {kind: 'NamedConstraintDefinitionStart', text: '{', subtree_size: 3},
  19. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  20. // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'Add'},
  21. // CHECK:STDOUT: {kind: 'ImplicitParamListStart', text: '['},
  22. // CHECK:STDOUT: {kind: 'SelfValueName', text: 'self'},
  23. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  24. // CHECK:STDOUT: {kind: 'LetBindingPattern', text: ':', subtree_size: 3},
  25. // CHECK:STDOUT: {kind: 'ImplicitParamList', text: ']', subtree_size: 5},
  26. // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
  27. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'},
  28. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  29. // CHECK:STDOUT: {kind: 'LetBindingPattern', text: ':', subtree_size: 3},
  30. // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 5},
  31. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  32. // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
  33. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 15},
  34. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 16},
  35. // CHECK:STDOUT: {kind: 'NamedConstraintDefinition', text: '}', subtree_size: 20},
  36. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  37. // CHECK:STDOUT: ]