params.carbon 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/check/testdata/choice/params.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/params.carbon
  10. // --- fail_todo_empty_params.carbon
  11. library "[[@TEST_NAME]]";
  12. choice Always {
  13. // CHECK:STDERR: fail_todo_empty_params.carbon:[[@LINE+4]]:8: error: semantics TODO: `empty parameter list should make a member function` [SemanticsTodo]
  14. // CHECK:STDERR: Sunny()
  15. // CHECK:STDERR: ^~
  16. // CHECK:STDERR:
  17. Sunny()
  18. }
  19. let mood: Always = Always.Sunny;
  20. // --- fail_todo_params.carbon
  21. library "[[@TEST_NAME]]";
  22. choice C {
  23. Alt1,
  24. // CHECK:STDERR: fail_todo_params.carbon:[[@LINE+4]]:7: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo]
  25. // CHECK:STDERR: Alt2(a: i32, b: i64),
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  27. // CHECK:STDERR:
  28. Alt2(a: i32, b: i64),
  29. Alt3,
  30. }
  31. // --- fail_todo_generic_params.carbon
  32. library "[[@TEST_NAME]]";
  33. choice C(T:! type) {
  34. // CHECK:STDERR: fail_todo_generic_params.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo]
  35. // CHECK:STDERR: Alt(a: T)
  36. // CHECK:STDERR: ^~~~~~
  37. // CHECK:STDERR:
  38. Alt(a: T)
  39. }
  40. // --- fail_todo_self_param.carbon
  41. library "[[@TEST_NAME]]";
  42. choice C {
  43. // CHECK:STDERR: fail_todo_self_param.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo]
  44. // CHECK:STDERR: Alt(a: Self*)
  45. // CHECK:STDERR: ^~~~~~~~~~
  46. // CHECK:STDERR:
  47. Alt(a: Self*)
  48. }