Skip to content

Commit ead4e41

Browse files
committed
Review feedback
1 parent a8e31dc commit ead4e41

File tree

9 files changed

+37
-39
lines changed

9 files changed

+37
-39
lines changed

user/super/com/google/gwt/emul/java/util/stream/DoubleStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ public boolean tryAdvance(DoubleConsumer action) {
330330

331331
default DoubleStream mapMulti(DoubleStream.DoubleMapMultiConsumer mapper) {
332332
return flatMap(element -> {
333-
List<Double> buffer = new ArrayList<>();
334-
mapper.accept(element, (DoubleConsumer) buffer::add);
335-
return buffer.stream().mapToDouble(n -> n);
333+
Builder builder = builder();
334+
mapper.accept(element, (DoubleConsumer) builder::add);
335+
return builder.build();
336336
});
337337
}
338338

user/super/com/google/gwt/emul/java/util/stream/IntStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ public boolean tryAdvance(IntConsumer action) {
379379

380380
default IntStream mapMulti(IntMapMultiConsumer mapper) {
381381
return flatMap(element -> {
382-
List<Integer> buffer = new ArrayList<>();
383-
mapper.accept(element, (IntConsumer) buffer::add);
384-
return buffer.stream().mapToInt(n -> n);
382+
Builder builder = builder();
383+
mapper.accept(element, (IntConsumer) builder::add);
384+
return builder.build();
385385
});
386386
}
387387

user/super/com/google/gwt/emul/java/util/stream/LongStream.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
import static javaemul.internal.InternalPreconditions.checkState;
1919

20-
import java.util.ArrayList;
2120
import java.util.Arrays;
2221
import java.util.Comparator;
23-
import java.util.List;
2422
import java.util.LongSummaryStatistics;
2523
import java.util.OptionalDouble;
2624
import java.util.OptionalLong;
@@ -377,9 +375,9 @@ public boolean tryAdvance(LongConsumer action) {
377375

378376
default LongStream mapMulti(LongStream.LongMapMultiConsumer mapper) {
379377
return flatMap(element -> {
380-
List<Long> buffer = new ArrayList<>();
381-
mapper.accept(element, (LongConsumer) buffer::add);
382-
return buffer.stream().mapToLong(n -> n);
378+
Builder builder = builder();
379+
mapper.accept(element, (LongConsumer) builder::add);
380+
return builder.build();
383381
});
384382
}
385383

user/test-super/com/google/gwt/emultest/super/com/google/gwt/emultest/java17/util/stream/DoubleStreamTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public void testMapMulti() {
2727
callback.accept(num + num);
2828
};
2929
assertEquals(new double[0],
30-
hideFromCompiler(DoubleStream.of()).mapMulti(doubling).toArray());
30+
DoubleStream.of().mapMulti(doubling).toArray());
3131
assertEquals(new double[]{1.0, 2.0, 3.0, 6.0},
32-
hideFromCompiler(DoubleStream.of(1.0, 3.0)).mapMulti(doubling).toArray());
32+
DoubleStream.of(1.0, 3.0).mapMulti(doubling).toArray());
3333
assertEquals(new double[0],
34-
hideFromCompiler(DoubleStream.of(1.0, 2.0)).mapMulti((a, b) -> {
35-
}).toArray());
34+
DoubleStream.of(1.0, 2.0).mapMulti((a, b) -> {}).toArray());
3635
}
3736
}

user/test-super/com/google/gwt/emultest/super/com/google/gwt/emultest/java17/util/stream/IntStreamTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ public void testMapMulti() {
2828
callback.accept(num + num);
2929
};
3030
assertEquals(new int[0],
31-
hideFromCompiler(IntStream.of()).mapMulti(doubling).toArray());
31+
IntStream.of().mapMulti(doubling).toArray());
3232
assertEquals(new int[]{1, 2, 3, 6},
33-
hideFromCompiler(IntStream.of(1, 3)).mapMulti(doubling).toArray());
33+
IntStream.of(1, 3).mapMulti(doubling).toArray());
3434
assertEquals(new int[0],
35-
hideFromCompiler(IntStream.of(1, 3)).mapMulti((a, b) -> {
36-
}).toArray());
35+
IntStream.of(1, 3).mapMulti((a, b) -> {}).toArray());
3736
}
3837
}

user/test-super/com/google/gwt/emultest/super/com/google/gwt/emultest/java17/util/stream/LongStreamTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public void testMapMulti() {
2727
callback.accept(num + num);
2828
};
2929
assertEquals(new long[0],
30-
hideFromCompiler(LongStream.of()).mapMulti(doubling).toArray());
30+
LongStream.of().mapMulti(doubling).toArray());
3131
assertEquals(new long[]{1L, 2L, 3L, 6L},
32-
hideFromCompiler(LongStream.of(1L, 3L)).mapMulti(doubling).toArray());
32+
LongStream.of(1L, 3L).mapMulti(doubling).toArray());
3333
assertEquals(new long[0],
34-
hideFromCompiler(LongStream.of(1L, 2L)).mapMulti((a, b) -> {
35-
}).toArray());
34+
LongStream.of(1L, 2L).mapMulti((a, b) -> {}).toArray());
3635
}
3736
}

user/test-super/com/google/gwt/emultest/super/com/google/gwt/emultest/java17/util/stream/StreamTest.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ public void testMapMulti() {
4040
callback.accept(str + str);
4141
};
4242
assertEquals(Arrays.asList(),
43-
this.<Stream<String>>hideFromCompiler(Stream.of()).<String>mapMulti(doubling).toList());
43+
Stream.<String>of().mapMulti(doubling).toList());
4444
assertEquals(Arrays.asList("a", "aa", "b", "bb"),
45-
hideFromCompiler(Stream.of("a", "b")).<String>mapMulti(doubling).toList());
45+
Stream.of("a", "b")).<String>mapMulti(doubling).toList());
4646
assertEquals(Arrays.asList(),
47-
hideFromCompiler(Stream.of("a", "b")).mapMulti((a, b) -> {
48-
}).toList());
47+
Stream.of("a", "b").mapMulti((a, b) -> {}).toList());
4948
}
5049

5150
public void testMapMultiToInt() {
@@ -54,12 +53,11 @@ public void testMapMultiToInt() {
5453
callback.accept(str.length() * 2);
5554
};
5655
assertEquals(new int[]{1, 2, 3, 6},
57-
hideFromCompiler(Stream.of("a", "bbb")).mapMultiToInt(doubling).toArray());
56+
Stream.of("a", "bbb").mapMultiToInt(doubling).toArray());
5857
assertEquals(new int[0],
59-
hideFromCompiler(Stream.<String>of()).mapMultiToInt(doubling).toArray());
58+
Stream.<String>of().mapMultiToInt(doubling).toArray());
6059
assertEquals(new int[0],
61-
hideFromCompiler(Stream.of("a", "b")).mapMultiToInt((a, b) -> {
62-
}).toArray());
60+
Stream.of("a", "b").mapMultiToInt((a, b) -> {}).toArray());
6361
}
6462

6563
public void testMapMultiToLong() {
@@ -68,11 +66,11 @@ public void testMapMultiToLong() {
6866
callback.accept(str.length() * 2L);
6967
};
7068
assertEquals(new long[]{1L, 2L, 3L, 6L},
71-
hideFromCompiler(Stream.of("a", "bbb")).mapMultiToLong(doubling).toArray());
69+
Stream.of("a", "bbb").mapMultiToLong(doubling).toArray());
7270
assertEquals(new long[0],
73-
hideFromCompiler(Stream.<String>of()).mapMultiToLong(doubling).toArray());
71+
Stream.<String>of().mapMultiToLong(doubling).toArray());
7472
assertEquals(new long[0],
75-
hideFromCompiler(Stream.of("a", "b")).mapMultiToLong((a, b) -> {
73+
Stream.of("a", "b").mapMultiToLong((a, b) -> {
7674
}).toArray());
7775
}
7876

@@ -82,11 +80,10 @@ public void testMapMultiToDouble() {
8280
callback.accept(str.length() * 2);
8381
};
8482
assertEquals(new double[]{1.0, 2.0, 3.0, 6.0},
85-
hideFromCompiler(Stream.of("a", "bbb")).mapMultiToDouble(doubling).toArray());
83+
Stream.of("a", "bbb").mapMultiToDouble(doubling).toArray());
8684
assertEquals(new double[0],
87-
hideFromCompiler(Stream.<String>of()).mapMultiToDouble(doubling).toArray());
85+
Stream.<String>of().mapMultiToDouble(doubling).toArray());
8886
assertEquals(new double[0],
89-
hideFromCompiler(Stream.of("a", "b")).mapMultiToDouble((a, b) -> {
90-
}).toArray());
87+
Stream.of("a", "b").mapMultiToDouble((a, b) -> {}).toArray());
9188
}
9289
}

user/test/com/google/gwt/emultest/EmulJava17Suite.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.google.gwt.emultest.java17.lang.CharSequenceTest;
1919
import com.google.gwt.emultest.java17.lang.StringTest;
20+
import com.google.gwt.emultest.java17.util.MapEntryTest;
2021
import com.google.gwt.emultest.java17.util.stream.CollectorsTest;
2122
import com.google.gwt.emultest.java17.util.stream.DoubleStreamTest;
2223
import com.google.gwt.emultest.java17.util.stream.IntStreamTest;
@@ -35,7 +36,8 @@
3536
StreamTest.class,
3637
DoubleStreamTest.class,
3738
IntStreamTest.class,
38-
LongStreamTest.class
39+
LongStreamTest.class,
40+
MapEntryTest.class
3941
})
4042
public class EmulJava17Suite {
4143
}

user/test/com/google/gwt/emultest/java17/lang/StringTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public void testIndent() {
3535
assertFalse(isGwtSourceLevel17());
3636
}
3737

38+
public void testStripIndent() {
39+
assertFalse(isGwtSourceLevel17());
40+
}
41+
3842
public void testTranslateEscapes() {
3943
assertFalse(isGwtSourceLevel17());
4044
}

0 commit comments

Comments
 (0)