tree: b6364e16fd342bcb53e266e9ab8a7e5fe173eef8 [path history] [tgz]
  1. expected/
  2. input/
  3. argument_refinement_10_test.dart
  4. argument_refinement_11_test.dart
  5. argument_refinement_12_test.dart
  6. argument_refinement_13_test.dart
  7. argument_refinement_14_test.dart
  8. argument_refinement_15_test.dart
  9. argument_refinement_16_test.dart
  10. argument_refinement_17_test.dart
  11. argument_refinement_18_test.dart
  12. argument_refinement_19_test.dart
  13. argument_refinement_1_test.dart
  14. argument_refinement_20_test.dart
  15. argument_refinement_21_test.dart
  16. argument_refinement_22_test.dart
  17. argument_refinement_23_test.dart
  18. argument_refinement_24_test.dart
  19. argument_refinement_25_test.dart
  20. argument_refinement_26_test.dart
  21. argument_refinement_27_test.dart
  22. argument_refinement_28_test.dart
  23. argument_refinement_2_test.dart
  24. argument_refinement_3_test.dart
  25. argument_refinement_4_test.dart
  26. argument_refinement_5_test.dart
  27. argument_refinement_6_test.dart
  28. argument_refinement_7_test.dart
  29. argument_refinement_8_test.dart
  30. argument_refinement_9_test.dart
  31. argument_refinement_num_10_test.dart
  32. argument_refinement_num_11_test.dart
  33. argument_refinement_num_12_test.dart
  34. argument_refinement_num_13_test.dart
  35. argument_refinement_num_14_test.dart
  36. argument_refinement_num_15_test.dart
  37. argument_refinement_num_16_test.dart
  38. argument_refinement_num_17_test.dart
  39. argument_refinement_num_1_test.dart
  40. argument_refinement_num_2_test.dart
  41. argument_refinement_num_3_test.dart
  42. argument_refinement_num_4_test.dart
  43. argument_refinement_num_5_test.dart
  44. argument_refinement_num_6_test.dart
  45. argument_refinement_num_7_test.dart
  46. argument_refinement_num_8_test.dart
  47. argument_refinement_num_9
  48. argument_refinement_num_9_test.dart
  49. basic_10_test.dart
  50. basic_11_test.dart
  51. basic_12_test.dart
  52. basic_13_test.dart
  53. basic_14_test.dart
  54. basic_15_test.dart
  55. basic_16_test.dart
  56. basic_1_test.dart
  57. basic_2_test.dart
  58. basic_3_test.dart
  59. basic_4_test.dart
  60. basic_5_test.dart
  61. basic_6_test.dart
  62. basic_7_test.dart
  63. basic_8_test.dart
  64. basic_9_test.dart
  65. closures_10_test.dart
  66. closures_11_test.dart
  67. closures_12_test.dart
  68. closures_13_test.dart
  69. closures_14_test.dart
  70. closures_15_test.dart
  71. closures_16_test.dart
  72. closures_1_test.dart
  73. closures_2_test.dart
  74. closures_3_test.dart
  75. closures_4_test.dart
  76. closures_5_test.dart
  77. closures_6_test.dart
  78. closures_7_test.dart
  79. closures_8_test.dart
  80. closures_9_test.dart
  81. codeUnitAt_1_test.dart
  82. codeUnitAt_2_test.dart
  83. constructor_10_test.dart
  84. constructor_11_test.dart
  85. constructor_12_test.dart
  86. constructor_13_test.dart
  87. constructor_14_test.dart
  88. constructor_15_test.dart
  89. constructor_1_test.dart
  90. constructor_2_test.dart
  91. constructor_3_test.dart
  92. constructor_4_test.dart
  93. constructor_5_test.dart
  94. constructor_6_test.dart
  95. constructor_7_test.dart
  96. constructor_8_test.dart
  97. constructor_9_test.dart
  98. control_flow_1_test.dart
  99. control_flow_2_test.dart
  100. control_flow_3_test.dart
  101. control_flow_4_test.dart
  102. control_flow_5_test.dart
  103. control_flow_6_test.dart
  104. control_flow_7_test.dart
  105. control_flow_8_test.dart
  106. control_flow_9_test.dart
  107. gvn_1_test.dart
  108. interceptors_1_test.dart
  109. interceptors_2_test.dart
  110. literals_1_test.dart
  111. operators2_1_test.dart
  112. operators2_2_test.dart
  113. operators2_3_test.dart
  114. operators2_4_test.dart
  115. operators2_5_test.dart
  116. operators2_6_test.dart
  117. operators2_7_test.dart
  118. operators2_8_test.dart
  119. operators_1_test.dart
  120. operators_2_test.dart
  121. operators_3_test.dart
  122. operators_4_test.dart
  123. operators_5_test.dart
  124. operators_6_test.dart
  125. operators_7_test.dart
  126. operators_8_test.dart
  127. optimize_indexers_test.dart
  128. README.md
  129. redundant_condition_test.dart
  130. runner.dart
  131. runtime_types_1_test.dart
  132. runtime_types_2_test.dart
  133. runtime_types_3_test.dart
  134. runtime_types_4_test.dart
  135. supercall_1_test.dart
  136. supercall_2_test.dart
  137. supercall_3_test.dart
  138. up_to_date_test.dart
  139. update_all.dart
tests/compiler/dart2js/cps_ir/README.md

CPS IR unit tests

This folder contains unit tests of the CPS IR. These tests run the compiler with the cps IR and check for the output of a specific function (typically main).

To make our lives easier, most files here are autogenerated. You should never have to edit a file under expected/ or any file with an AUTOGENERATED header (including the _test.dart files).

See instructions below to add or update tests.

Adding a new test

Every test has 3 files: an input file, a test runner file, and an expectation file. The last two are auto-generated. Here is how:

  • add a file under input/ with a unique name, such as foo_bar.dart. Do not include _test in the name of this file, otherwise the test framework will think this test needs to be run directly in the vm and in a browser, that's not our goal.

  • generate the corresponding test file, by running the up_to_date_test.dart passing update as an argument:

dart tests/compiler/dart2js/cps_ir/up_to_date_test.dart update

This will generate a file foo_bar_test.dart on this folder.

  • generate the expectations of the test file by running the generated test file with update as an argument:
dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/foo_bar_test.dart update

This will generate a file expected/foo_bar.js with the expected output.

Checking a method other than main

By default, the test expectations will be generated to contain just the body of the main function. If you wish to check for a different element, include a comment at the top of the input test like this:

// Method to test: function(foo)

The trailing text should match the string representation of a compiler element.

Note: this format will likely change in the future. We would like to have a canonical way to refer to elements that is independent of the internal compiler implementation, we also want a way to specify more than just one element, and a way to specify that an element has been tree-shaken.

Updating a single test expectation

To update the expectations of a test, simply regenerate it by running the test file with update as an argument:

dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/foo_bar_test.dart update

This will override the file expected/foo_bar.js file with the new output.

If a test fails because the expectations are out of date, you'll see this suggestion in the failure message too.

Updating all test expectations

For convenience, we also provide a script to update all expectations at once.

dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/update_all.dart

It is equivalent to update each test individually. This script can be handy when making cross-cutting changes that affect the output of most tests.