<commit_before>/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.xnode;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Test method of the Xintent class
 *
 * @author clementval
 */
public class XintentTest {

  @Test
  public void ctorTest() {
    assertEquals(Xintent.IN, Xintent.fromString("in"));
    assertEquals(Xintent.IN, Xintent.fromString("IN"));

    assertEquals(Xintent.OUT, Xintent.fromString("out"));
    assertEquals(Xintent.OUT, Xintent.fromString("OUT"));

    assertEquals(Xintent.INOUT, Xintent.fromString("inout"));
    assertEquals(Xintent.INOUT, Xintent.fromString("INOUT"));

    assertEquals(Xintent.INOUT, Xintent.fromString("inOUT"));

    assertEquals(Xintent.NONE, Xintent.fromString(null));
    assertEquals(Xintent.NONE, Xintent.fromString(""));

    assertEquals(Xname.INTENT_IN, Xintent.IN.toString());
    assertEquals(Xname.INTENT_OUT, Xintent.OUT.toString());
    assertEquals(Xname.INTENT_INOUT, Xintent.INOUT.toString());
    assertEquals("", Xintent.NONE.toString());
    assertEquals("", Xintent.ANY.toString());
  }

  @Test
  public void checkTest() {
    Xintent intent1 = Xintent.IN;
    Xintent intent2 = Xintent.OUT;
    Xintent intent3 = Xintent.INOUT;
    Xintent intent4 = Xintent.NONE;
    Xintent any = Xintent.ANY;

    assertTrue(intent1.isIntentIn());
    assertFalse(intent2.isIntentIn());
    assertTrue(intent3.isIntentIn());
    assertFalse(intent4.isIntentIn());

    assertFalse(intent1.isIntentOut());
    assertTrue(intent2.isIntentOut());
    assertTrue(intent3.isIntentOut());
    assertFalse(intent4.isIntentOut());

    assertTrue(intent1.isIntent());
    assertTrue(intent2.isIntent());
    assertTrue(intent3.isIntent());
    assertFalse(intent4.isIntent());

    assertFalse(intent1.isCompatible(intent2));
    assertTrue(intent1.isCompatible(intent3));
    assertFalse(intent1.isCompatible(intent4));
    assertTrue(intent1.isCompatible(any));

    assertFalse(intent2.isCompatible(intent1));
    assertTrue(intent2.isCompatible(intent3));
    assertFalse(intent2.isCompatible(intent4));
    assertTrue(intent2.isCompatible(any));

    assertTrue(intent3.isCompatible(intent1));
    assertTrue(intent3.isCompatible(intent2));
    assertFalse(intent3.isCompatible(intent4));
    assertTrue(intent3.isCompatible(any));

    assertFalse(intent4.isCompatible(intent1));
    assertFalse(intent4.isCompatible(intent2));
    assertFalse(intent4.isCompatible(intent3));
    assertTrue(intent4.isCompatible(any));

    assertTrue(any.isCompatible(intent1));
    assertTrue(any.isCompatible(intent2));
    assertTrue(any.isCompatible(intent3));
    assertTrue(any.isCompatible(intent4));

    assertFalse(intent1.isCompatible(null));<commit_msg>Add self compatibility check<commit_after>/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.xnode;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Test method of the Xintent class
 *
 * @author clementval
 */
public class XintentTest {

  @Test
  public void ctorTest() {
    assertEquals(Xintent.IN, Xintent.fromString("in"));
    assertEquals(Xintent.IN, Xintent.fromString("IN"));

    assertEquals(Xintent.OUT, Xintent.fromString("out"));
    assertEquals(Xintent.OUT, Xintent.fromString("OUT"));

    assertEquals(Xintent.INOUT, Xintent.fromString("inout"));
    assertEquals(Xintent.INOUT, Xintent.fromString("INOUT"));

    assertEquals(Xintent.INOUT, Xintent.fromString("inOUT"));

    assertEquals(Xintent.NONE, Xintent.fromString(null));
    assertEquals(Xintent.NONE, Xintent.fromString(""));

    assertEquals(Xname.INTENT_IN, Xintent.IN.toString());
    assertEquals(Xname.INTENT_OUT, Xintent.OUT.toString());
    assertEquals(Xname.INTENT_INOUT, Xintent.INOUT.toString());
    assertEquals("", Xintent.NONE.toString());
    assertEquals("", Xintent.ANY.toString());
  }

  @Test
  public void checkTest() {
    Xintent intent1 = Xintent.IN;
    Xintent intent2 = Xintent.OUT;
    Xintent intent3 = Xintent.INOUT;
    Xintent intent4 = Xintent.NONE;
    Xintent any = Xintent.ANY;

    assertTrue(intent1.isIntentIn());
    assertFalse(intent2.isIntentIn());
    assertTrue(intent3.isIntentIn());
    assertFalse(intent4.isIntentIn());

    assertFalse(intent1.isIntentOut());
    assertTrue(intent2.isIntentOut());
    assertTrue(intent3.isIntentOut());
    assertFalse(intent4.isIntentOut());

    assertTrue(intent1.isIntent());
    assertTrue(intent2.isIntent());
    assertTrue(intent3.isIntent());
    assertFalse(intent4.isIntent());

    assertTrue(intent1.isCompatible(intent1));
    assertFalse(intent1.isCompatible(intent2));
    assertTrue(intent1.isCompatible(intent3));
    assertFalse(intent1.isCompatible(intent4));
    assertTrue(intent1.isCompatible(any));

    assertFalse(intent2.isCompatible(intent1));
    assertTrue(intent2.isCompatible(intent2));
    assertTrue(intent2.isCompatible(intent3));
    assertFalse(intent2.isCompatible(intent4));
    assertTrue(intent2.isCompatible(any));

    assertTrue(intent3.isCompatible(intent1));
    assertTrue(intent3.isCompatible(intent2));
    assertTrue(intent3.isCompatible(intent3));
    assertFalse(intent3.isCompatible(intent4));
    assertTrue(intent3.isCompatible(any));

    assertFalse(intent4.isCompatible(intent1));
    assertFalse(intent4.isCompatible(intent2));
    assertFalse(intent4.isCompatible(intent3));
    assertTrue(intent4.isCompatible(intent4));
    assertTrue(intent4.isCompatible(any));

    assertTrue(any.isCompatible(intent1));
    assertTrue(any.isCompatible(intent2));
    assertTrue(any.isCompatible(intent3));
    assertTrue(any.isCompatible(intent4));
    assertTrue(any.isCompatible(any));

    assertFalse(intent1.isCompatible(null));
{'fraction_non_alphanumeric': 0.13781282139184092, 'fraction_numerical': 0.018512170037709975, 'mean_word_length': 5.129201680672269, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5391725', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1812, 'n_words': 243}