make_tests.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #! /bin/bash
  2. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  3. # Exceptions. See /LICENSE for license information.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. # TODO: This is a short-term script to regenerate the test files for operators
  6. # while we're in a period where we expect the tests to have substantial churn.
  7. # Once the implementation of overloaded operators has stabilized, this script
  8. # and its template files should be removed.
  9. make_test() {
  10. HEADER="// This file was generated from $4. Run make_tests.sh to regenerate."
  11. sed "s,INTERFACE,$1,g; s,OP,$2,g; s,HEADER,$HEADER," "$4" > "$3.carbon"
  12. }
  13. make_unary_op_test() {
  14. make_test "$1" "$2" "$3" unary_op.carbon.tmpl
  15. }
  16. make_unary_stmt_test() {
  17. make_test "$1" "$2" "$3" unary_stmt.carbon.tmpl
  18. }
  19. make_binary_op_test() {
  20. make_test "$1" "$2" "$3" binary_op.carbon.tmpl
  21. }
  22. make_unary_op_test BitComplement '^' bit_complement
  23. make_unary_op_test Negate '-' negate
  24. make_unary_stmt_test Dec '--' dec
  25. make_unary_stmt_test Inc '++' inc
  26. make_binary_op_test Add '+' add
  27. make_binary_op_test BitAnd '\&' bit_and
  28. make_binary_op_test BitOr '|' bit_or
  29. make_binary_op_test BitXor '^' bit_xor
  30. make_binary_op_test Div '/' div
  31. make_binary_op_test LeftShift '<<' left_shift
  32. make_binary_op_test Mod '%' mod
  33. make_binary_op_test Mul '*' mul
  34. make_binary_op_test RightShift '>>' right_shift
  35. make_binary_op_test Sub '-' sub