multiline_string_literals.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // For multiline string literals, force autoupdates to the end so that we don't
  6. // accidentally mix diagnostics with the literal.
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lex/testdata/multiline_string_literals.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lex/testdata/multiline_string_literals.carbon
  13. // --- fail_indent_mismatch.carbon
  14. '''
  15. a
  16. '''
  17. // --- fail_quotes.carbon
  18. """
  19. a
  20. """
  21. // --- AUTOUPDATE-SPLIT
  22. // CHECK:STDERR: fail_indent_mismatch.carbon:3:1: error: indentation does not match that of the closing `'''` in multi-line string literal [MismatchedIndentInString]
  23. // CHECK:STDERR: a
  24. // CHECK:STDERR: ^
  25. // CHECK:STDERR:
  26. // CHECK:STDERR: fail_quotes.carbon:2:1: error: use `'''` delimiters for a multi-line string literal, not `"""` [MultiLineStringWithDoubleQuotes]
  27. // CHECK:STDERR: """
  28. // CHECK:STDERR: ^
  29. // CHECK:STDERR:
  30. // CHECK:STDOUT: - filename: fail_indent_mismatch.carbon
  31. // CHECK:STDOUT: tokens:
  32. // CHECK:STDOUT: - { index: 1, kind: "StringLiteral", line: {{ *}}2, column: 3, indent: 3, spelling: "'''\na\n '''", value: "a\n", has_leading_space: true }
  33. // CHECK:STDOUT: - filename: fail_quotes.carbon
  34. // CHECK:STDOUT: tokens:
  35. // CHECK:STDOUT: - { index: 1, kind: "StringLiteral", line: {{ *}}2, column: 1, indent: 1, spelling: "\"\"\"\na\n\"\"\"", value: "a\n", has_leading_space: true }