package jetbrains.mps.baseLanguage.methodReferences.test.tests;

/*Generated by MPS */

import org.junit.jupiter.api.Test;
import jetbrains.mps.internal.collections.runtime.Sequence;
import java.util.Collections;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import java.util.ArrayList;
import java.math.BigInteger;
import org.junit.Assert;

public class BoundsTypes_Test {
  @Test
  public void test_testLowerBoundType() throws Exception {
    Iterable<Integer> seqInt = Sequence.fromIterable(Sequence.fromIterable(Collections.<Integer>emptyList())).select((number) -> LowerBounded.identity(number));
    Iterable<Number> seqNum = Sequence.fromIterable(Sequence.fromIterable(Collections.<Number>emptyList())).select((number) -> LowerBounded.identity(number));
    Iterable<Double> seqDouble = Sequence.fromIterable(Sequence.fromIterable(Collections.<Double>emptyList())).select((number) -> LowerBounded.identity(number));
  }
  @Test
  public void test_testUpperBoundType() throws Exception {
    List<List<Number>> list = ListSequence.fromListAndArray(new ArrayList<List<Number>>(), ListSequence.fromListAndArray(new ArrayList<Number>(), 3, new BigInteger("7")));
    Iterable<Object> seqNum = ListSequence.fromList(list).select((number) -> UpperBounded.process(number));
    Assert.assertEquals(Sequence.fromIterable(seqNum).first(), 3);
  }
  public static class LowerBounded {
    public static <U extends Number> U identity(U number) {
      return number;
    }
  }

  public static class UpperBounded {
    public static Object process(List<? super Integer> number) {
      return as_27nxyu_a0a0a4(number.get(0), Object.class);
    }
    private static <T> T as_27nxyu_a0a0a4(Object o, Class<T> type) {
      return (type.isInstance(o) ? (T) o : null);
    }
  }

}
