var.carbon 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  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/class/var.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/class/var.carbon
  10. class Foo {
  11. var x: i32;
  12. var y: i32 = 0;
  13. }
  14. // CHECK:STDOUT: - filename: var.carbon
  15. // CHECK:STDOUT: parse_tree: [
  16. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  17. // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'},
  18. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Foo'},
  19. // CHECK:STDOUT: {kind: 'ClassDefinitionStart', text: '{', subtree_size: 3},
  20. // CHECK:STDOUT: {kind: 'FieldIntroducer', text: 'var'},
  21. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'},
  22. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  23. // CHECK:STDOUT: {kind: 'FieldNameAndType', text: ':', subtree_size: 3},
  24. // CHECK:STDOUT: {kind: 'FieldDecl', text: ';', subtree_size: 5},
  25. // CHECK:STDOUT: {kind: 'FieldIntroducer', text: 'var'},
  26. // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'},
  27. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  28. // CHECK:STDOUT: {kind: 'FieldNameAndType', text: ':', subtree_size: 3},
  29. // CHECK:STDOUT: {kind: 'FieldInitializer', text: '='},
  30. // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
  31. // CHECK:STDOUT: {kind: 'FieldDecl', text: ';', subtree_size: 7},
  32. // CHECK:STDOUT: {kind: 'ClassDefinition', text: '}', subtree_size: 16},
  33. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  34. // CHECK:STDOUT: ]