mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 10:14:57 +01:00
Trying to make split file tests of lex functionality shorter and easier to read. numeric_literals.carbon in particular has an example of why I'm interested in this (at the bottom). This also switches from `[]` list format to `-` list format so that the trailing `]` is removed. Trimming comments in tokenized_buffer.h because (1) it feels like it's giving too much detail about what's printed, which has drifted slightly and (2) it also feels like it's trying to justify YAML output, when that's just what we're doing in general. --------- Co-authored-by: Geoff Romer <gromer@google.com>
53 lines
4.7 KiB
Plaintext
53 lines
4.7 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// Trailing comments should produce errors, but we should continue to parse (and
|
|
// diagnose) code errors beyond them.
|
|
|
|
var a: i32 = 1; // trailing comment
|
|
var b: 32 = 13; // more trailing comment
|
|
var c: i32 = 0.4; // still more trailing comment
|
|
|
|
// We keep the auto-update marker below the above so check lines don't disrupt
|
|
// the trailing comment lines with similar prefixes.
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lex/testdata/fail_trailing_comments.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lex/testdata/fail_trailing_comments.carbon
|
|
// CHECK:STDERR: fail_trailing_comments.carbon:[[@LINE-11]]:19: error: trailing comments are not permitted [TrailingComment]
|
|
// CHECK:STDERR: var a: i32 = 1; // trailing comment
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR:
|
|
// CHECK:STDERR: fail_trailing_comments.carbon:[[@LINE-14]]:19: error: trailing comments are not permitted [TrailingComment]
|
|
// CHECK:STDERR: var b: 32 = 13; // more trailing comment
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR:
|
|
// CHECK:STDERR: fail_trailing_comments.carbon:[[@LINE-17]]:19: error: trailing comments are not permitted [TrailingComment]
|
|
// CHECK:STDERR: var c: i32 = 0.4; // still more trailing comment
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDOUT: - filename: fail_trailing_comments.carbon
|
|
// CHECK:STDOUT: tokens:
|
|
// CHECK:STDOUT: - { index: 1, kind: 'Var', line: {{ *}}[[@LINE-24]], column: 1, indent: 1, spelling: 'var', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-25]], column: 5, indent: 1, spelling: 'a', identifier: 0, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 3, kind: 'Colon', line: {{ *}}[[@LINE-26]], column: 6, indent: 1, spelling: ':' }
|
|
// CHECK:STDOUT: - { index: 4, kind: 'IntTypeLiteral', line: {{ *}}[[@LINE-27]], column: 8, indent: 1, spelling: 'i32', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 5, kind: 'Equal', line: {{ *}}[[@LINE-28]], column: 12, indent: 1, spelling: '=', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 6, kind: 'IntLiteral', line: {{ *}}[[@LINE-29]], column: 14, indent: 1, spelling: '1', value: `1`, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 7, kind: 'Semi', line: {{ *}}[[@LINE-30]], column: 15, indent: 1, spelling: ';' }
|
|
// CHECK:STDOUT: - { index: 8, kind: 'Var', line: {{ *}}[[@LINE-30]], column: 1, indent: 1, spelling: 'var', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 9, kind: 'Identifier', line: {{ *}}[[@LINE-31]], column: 5, indent: 1, spelling: 'b', identifier: 1, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 10, kind: 'Colon', line: {{ *}}[[@LINE-32]], column: 6, indent: 1, spelling: ':' }
|
|
// CHECK:STDOUT: - { index: 11, kind: 'IntLiteral', line: {{ *}}[[@LINE-33]], column: 8, indent: 1, spelling: '32', value: `32`, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 12, kind: 'Equal', line: {{ *}}[[@LINE-34]], column: 11, indent: 1, spelling: '=', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 13, kind: 'IntLiteral', line: {{ *}}[[@LINE-35]], column: 13, indent: 1, spelling: '13', value: `13`, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 14, kind: 'Semi', line: {{ *}}[[@LINE-36]], column: 15, indent: 1, spelling: ';' }
|
|
// CHECK:STDOUT: - { index: 15, kind: 'Var', line: {{ *}}[[@LINE-36]], column: 1, indent: 1, spelling: 'var', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 16, kind: 'Identifier', line: {{ *}}[[@LINE-37]], column: 5, indent: 1, spelling: 'c', identifier: 2, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 17, kind: 'Colon', line: {{ *}}[[@LINE-38]], column: 6, indent: 1, spelling: ':' }
|
|
// CHECK:STDOUT: - { index: 18, kind: 'IntTypeLiteral', line: {{ *}}[[@LINE-39]], column: 8, indent: 1, spelling: 'i32', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 19, kind: 'Equal', line: {{ *}}[[@LINE-40]], column: 12, indent: 1, spelling: '=', has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 20, kind: 'RealLiteral', line: {{ *}}[[@LINE-41]], column: 14, indent: 1, spelling: '0.4', value: `4*10^-1`, has_leading_space: true }
|
|
// CHECK:STDOUT: - { index: 21, kind: 'Semi', line: {{ *}}[[@LINE-42]], column: 17, indent: 1, spelling: ';' }
|