SingletonLongStream implements LongStream { @Override public long[] toArray() { checkConsumed(); final long[] result = new long[1]; result[0] = element; return result; } private  SingletonLongStream(long element); static LongStream of(long element); @Override LongStream filter(LongPredicate predicate); @Override LongStream map(LongUnaryOperator mapper); @Override Stream<U> mapToObj(LongFunction<? extends U> mapper); @Override IntStream mapToInt(LongToIntFunction mapper); @Override DoubleStream mapToDouble(LongToDoubleFunction mapper); @Override LongStream flatMap(LongFunction<? extends LongStream> mapper); @Override LongStream distinct(); @Override LongStream sorted(); @Override LongStream peek(LongConsumer action); @Override LongStream limit(long maxSize); @Override LongStream skip(long n); @Override void forEach(LongConsumer action); @Override void forEachOrdered(LongConsumer action); @Override long[] toArray(); @Override long reduce(long identity, LongBinaryOperator op); @Override OptionalLong reduce(LongBinaryOperator op); @Override R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner); @Override long sum(); @Override OptionalLong min(); @Override OptionalLong max(); @Override long count(); @Override OptionalDouble average(); @Override LongSummaryStatistics summaryStatistics(); @Override boolean anyMatch(LongPredicate predicate); @Override boolean allMatch(LongPredicate predicate); @Override boolean noneMatch(LongPredicate predicate); @Override OptionalLong findFirst(); @Override OptionalLong findAny(); @Override DoubleStream asDoubleStream(); @Override Stream<Long> boxed(); @Override LongStream sequential(); @Override LongStream parallel(); @Override PrimitiveIterator.OfLong iterator(); @Override Spliterator.OfLong spliterator(); @Override boolean isParallel(); @Override LongStream unordered(); @Override LongStream onClose(Runnable closeHandler); @Override void close(); LongStream takeWhile(LongPredicate predicate); LongStream dropWhile(LongPredicate predicate);  }
@Test void toArray() { assertArrayEquals(reference.toArray(), instance.toArray()); assertThrows(IllegalStateException.class, () -> instance.toArray()); }