<commit_before>package org.sbrubbles.variablegenerics;

import static org.junit.Assert.assertArrayEquals;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.javaruntype.type.Types;
import org.junit.Test;

public class ConsTest {
  private static class FailedSonOfCons<First, Rest> extends Cons<First, Rest> {
    // empty block
  }
  
  private static class LimpingSonOfCons<Rest> extends Cons<String, Rest> {
    // empty block
  }
  
  private static class FrozenSonOfCons extends Cons<String, Number> {
    // empty block
  }
  
  private static class FrozenGrandsonOfCons extends Cons<String, Number> {
    // empty block
  }
  
  @Test
  public void ctorWithTwoTypes() {
    Cons<String, Number> cons = new Cons<String, Number>() {};
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER },
        cons.getTypes().toArray());
  }
  
  @Test
  public void ctorWithFiveTypes() {
    Cons<String, Cons<Number, Cons<Object, Cons<Object[], Serializable>>>> cons = 
      new Cons<String, Cons<Number, Cons<Object, Cons<Object[], Serializable>>>>() {};
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER, Types.OBJECT, Types.ARRAY_OF_OBJECT, Types.SERIALIZABLE },
        cons.getTypes().toArray());
  }
  
  @Test
  public void ctorWithCompositeTypes() {
    Cons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>> cons = 
      new Cons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() {};
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.LIST_OF_NUMBER, Types.OBJECT, Types.MAP_OF_STRING_INTEGER },
        cons.getTypes().toArray());
  }
  
  @Test(expected = InvalidTypeException.class)
  public void namedSubclass() {
    new FailedSonOfCons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>();
  }
  
  @Test(expected = UnexpectedTypeException.class)
  public void anonymousSubclassOfANamedSubclass() {
    new FailedSonOfCons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() {};
  }
  
  @Test(expected = UnexpectedTypeException.class)
  public void oneTypeVariableFixedFromAnonymousSubclassOfANamedSubclass() {
    new LimpingSonOfCons<Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() {};
  }
  
  @Test(expected = MissingTypeParametersException.class)
  public void bothTypeVariablesFixedFromAnonymousSubclassOfANamedSubclass() {
    new FrozenSonOfCons() {};
  }
  
  @Test(expected = MissingTypeParametersException.class)
  public void bothTypeVariablesFixedFromAnonymousSubclassOfANamedSubclassOfANamedSubclass() {
    new FrozenGrandsonOfCons() {};
  }
  
  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Test(expected = UnsupportedOperationException.class)
  public void immutableGetTypes() {
    Cons<String, Number> cons = new Cons<String, Number>() {};
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER },
        cons.getTypes().toArray());
    
    ((List) cons.getTypes()).add(Types.ARRAY_OF_BIG_DECIMAL);
  }
}<commit_msg>Removing some annoying warnings.<commit_after>package org.sbrubbles.variablegenerics;

import static org.junit.Assert.assertArrayEquals;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.javaruntype.type.Types;
import org.junit.Test;

public class ConsTest {
  private static class FailedSonOfCons<First, Rest> extends Cons<First, Rest> {
    // empty block
  }
  
  private static class LimpingSonOfCons<Rest> extends Cons<String, Rest> {
    // empty block
  }
  
  private static class FrozenSonOfCons extends Cons<String, Number> {
    // empty block
  }
  
  private static class FrozenGrandsonOfCons extends Cons<String, Number> {
    // empty block
  }
  
  @Test
  public void ctorWithTwoTypes() {
    Cons<String, Number> cons = new Cons<String, Number>() { /**/ };
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER },
        cons.getTypes().toArray());
  }
  
  @Test
  public void ctorWithFiveTypes() {
    Cons<String, Cons<Number, Cons<Object, Cons<Object[], Serializable>>>> cons = 
      new Cons<String, Cons<Number, Cons<Object, Cons<Object[], Serializable>>>>() { /**/ };
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER, Types.OBJECT, Types.ARRAY_OF_OBJECT, Types.SERIALIZABLE },
        cons.getTypes().toArray());
  }
  
  @Test
  public void ctorWithCompositeTypes() {
    Cons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>> cons = 
      new Cons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() { /**/ };
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.LIST_OF_NUMBER, Types.OBJECT, Types.MAP_OF_STRING_INTEGER },
        cons.getTypes().toArray());
  }
  
  @Test(expected = InvalidTypeException.class)
  public void namedSubclass() {
    new FailedSonOfCons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>();
  }
  
  @Test(expected = UnexpectedTypeException.class)
  public void anonymousSubclassOfANamedSubclass() {
    new FailedSonOfCons<String, Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() { /**/ };
  }
  
  @Test(expected = UnexpectedTypeException.class)
  public void oneTypeVariableFixedFromAnonymousSubclassOfANamedSubclass() {
    new LimpingSonOfCons<Cons<List<Number>, Cons<Object, Map<String, Integer>>>>() { /**/ };
  }
  
  @Test(expected = MissingTypeParametersException.class)
  public void bothTypeVariablesFixedFromAnonymousSubclassOfANamedSubclass() {
    new FrozenSonOfCons() { /**/ };
  }
  
  @SuppressWarnings("synthetic-access")
  @Test(expected = MissingTypeParametersException.class)
  public void bothTypeVariablesFixedFromAnonymousSubclassOfANamedSubclassOfANamedSubclass() {
    new FrozenGrandsonOfCons() { /**/ };
  }
  
  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Test(expected = UnsupportedOperationException.class)
  public void immutableGetTypes() {
    Cons<String, Number> cons = new Cons<String, Number>() { /**/ };
    
    assertArrayEquals(
        new Object[] { Types.STRING, Types.NUMBER },
        cons.getTypes().toArray());
    
    ((List) cons.getTypes()).add(Types.ARRAY_OF_BIG_DECIMAL);
  }
}
{'fraction_non_alphanumeric': 0.13049074818986323, 'fraction_numerical': 0.0, 'mean_word_length': 4.116049382716049, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5214919', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1894, 'n_words': 380}