<commit_before>package de.m_bleil.javafx.properties;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import javafx.beans.property.SimpleBooleanProperty;

import org.junit.Test;

public class InspectSimpleProperty {

	@Test
	public void inspect_setValue_method_for_SimpleBooleanProperty() {
		Boolean trueValue = Boolean.valueOf(true);
		Boolean wrappedValue, secondWrappedValue;
		SimpleBooleanProperty boolProperty = new SimpleBooleanProperty();

		// note: stores no reference to trueValue, uses
		// BooleanProprety#set(trueValue.getBooleanValue()) - take a look at source code
		boolProperty.setValue(trueValue);

		wrappedValue = boolProperty.getValue();
		assertThat(wrappedValue, is(sameInstance(trueValue)));

		// construct a new Boolean instance
		trueValue = new Boolean(true);
		boolProperty.setValue(trueValue);

		secondWrappedValue = boolProperty.getValue();
		assertThat(secondWrappedValue, is(not(sameInstance(trueValue))));
		assertThat(secondWrappedValue, is(sameInstance(wrappedValue)));
	}<commit_msg>updated sample for SimpleBooleanProperty, added sample for SimpleListProperty<commit_after>package de.m_bleil.javafx.properties;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import org.junit.Test;

public class InspectSimpleProperty {

	@Test
	public void inspect_setValue_method_for_SimpleBooleanProperty() {
		Boolean firstTrueValue = Boolean.valueOf(true);
		Boolean firstWrappedValue, secondWrappedValue;
		SimpleBooleanProperty boolProperty = new SimpleBooleanProperty();

		// note: stores no reference to trueValue, uses
		// BooleanProprety#set(trueValue.getBooleanValue()) - take a look at source code
		boolProperty.setValue(firstTrueValue);

		firstWrappedValue = boolProperty.getValue();
		// because firstTrueValue was constructed with Boolean.valueOf(true)
		assertThat(firstWrappedValue, is(sameInstance(firstTrueValue)));

		// construct a new Boolean instance
		Boolean secondTrueValue = new Boolean(true);
		boolProperty.setValue(secondTrueValue);

		// boolProperty "uses" for true the first created Boolean object with attribute true, here
		// it is trueValue
		secondWrappedValue = boolProperty.getValue();
		assertThat(secondWrappedValue, is(not(sameInstance(secondTrueValue))));
		// but
		assertThat(secondWrappedValue, is(sameInstance(firstWrappedValue)));
		assertThat(secondWrappedValue, is(sameInstance(firstTrueValue)));
	}

	@Test
	public void inspect_setValue_method_for_SimpleListProperty() {
		SimpleListProperty<String> stringListProperty = new SimpleListProperty<>();
		ObservableList<String> stringList, oldStringList;

		stringList = FXCollections.observableArrayList("item1", "item2", "item3");

		// note: stores a reference to wrappedList
		stringListProperty.set(stringList);
		ObservableList<String> wrappedStringList = stringListProperty.get();
		assertThat(wrappedStringList, is(sameInstance(stringList)));

		stringList = FXCollections.observableArrayList("chapter1", "chapter2", "chapter3");
		oldStringList = stringListProperty.get();
		assertThat(stringList, is(not(sameInstance(oldStringList))));
		assertThat(stringList, is(not(sameInstance(wrappedStringList))));
		assertThat(oldStringList, is(sameInstance(wrappedStringList)));
	}
{'fraction_non_alphanumeric': 0.09731446722494946, 'fraction_numerical': 0.0017326017903551833, 'mean_word_length': 6.963218390804598, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3634459', 'n_tokens_mistral': 1007, 'n_tokens_neox': 948, 'n_words': 204}