Skip to content

Commit

Permalink
Create SeqTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Jan 5, 2025
1 parent e23e1e6 commit 351bdd8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions kala-collection/src/main/java/kala/collection/Seq.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import java.util.*;
import java.util.function.*;
import java.util.stream.Stream;

@SuppressWarnings("unchecked")
public interface Seq<@Covariant E> extends Collection<E>, OrderedTraversable<E>, SeqLike<E>, AnySeq<E> {
Expand Down Expand Up @@ -100,6 +101,10 @@ static <E> Seq<E> narrow(Seq<? extends E> seq) {
return ImmutableSeq.from(it);
}

static <E> @NotNull Seq<E> from(@NotNull Stream<? extends E> stream) {
return ImmutableSeq.from(stream);
}

static <E> @NotNull Seq<E> fill(int n, E value) {
return ImmutableSeq.fill(n, value);
}
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/kala/collection/SeqTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2025 Glavo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kala.collection;

import kala.collection.factory.CollectionFactory;
import kala.collection.immutable.ImmutableSeq;
import kala.collection.immutable.ImmutableSeqTestTemplate;

public final class SeqTest implements ImmutableSeqTestTemplate {
@Override
public <E> CollectionFactory<E, ?, ImmutableSeq<E>> factory() {
return ImmutableSeq.factory();
}

@Override
public void classNameTest() {
}
}
1 change: 0 additions & 1 deletion src/test/template/kala/collection/SeqTestTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ default void fromTest() {
final MethodHandle fromIterator = lookup.findStatic(klass, "from", MethodType.methodType(klass, Iterator.class));
final MethodHandle fromStream = lookup.findStatic(klass, "from", MethodType.methodType(klass, Stream.class));


for (Integer[] data : data1()) {
final List<Integer> dataList = Arrays.asList(data);

Expand Down

0 comments on commit 351bdd8

Please sign in to comment.