Skip to content

Commit

Permalink
Add switch expressions to the sourcemaps readable test.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 697769148
  • Loading branch information
rluble authored and copybara-github committed Nov 18, 2024
1 parent 0e90d3c commit 29f5ce6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,13 @@ enum Enum1 {

Enum1(int i) {}
}

private void testSwitchExpression() {
int v = 1;
int r =
switch (v) {
case 1, 2 -> 10;
default -> 20;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ class SourceMap extends j_l_Object {
m_testLocalClass__void_$p_sourcemap_SourceMap() {
$1LocalClass.$create__sourcemap_SourceMap(this);
}
/** @nodts */
m_testSwitchExpression__void_$p_sourcemap_SourceMap() {
let v = 1;
let r = (() =>{
switch (v) {
case 1: case 2:
return 10;
default:
return 20;
}
})();
}
//Default method forwarding stub.
/** @override @nodts @return {Comparator<T>} */
m_reversed__java_util_Comparator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@
[return 1;] => [return 1;] "sourcemap.SourceMap.simpleMethod"
[testLocalClass] => [m_testLocalClass__void_$p_sourcemap_SourceMap]
[new LocalClass();] => [$1LocalClass.$create__sourcemap_SourceMap(this);] "sourcemap.SourceMap.testLocalClass"
[testSwitchExpression] => [m_testSwitchExpression__void_$p_sourcemap_SourceMap]
[int v = 1;] => [let v = 1;] "sourcemap.SourceMap.testSwitchExpression"
[v] => [v] "v"
[int r =
switch (v) {
... default -> 20;
};] => [let r = (() =>{
switch (v) {
... }
})();] "sourcemap.SourceMap.testSwitchExpression"
[r] => [r] "r"
[10;] => [return 10;] "sourcemap.SourceMap.<lambda in testSwitchExpression>"
[20;] => [return 20;] "sourcemap.SourceMap.<lambda in testSwitchExpression>"
[SourceMap] => [m_reversed__java_util_Comparator]
[SourceMap] => [return /**@type {Comparator<T>}*/ (Comparator.m_reversed__$default__java_util_Comparator__java_util_Comparator(this));] "sourcemap.SourceMap.reversed"
[SourceMap] => [m_thenComparing__java_util_Comparator__java_util_Comparator]
Expand Down

0 comments on commit 29f5ce6

Please sign in to comment.