use of com.google.template.soy.data.restricted.FloatData in project closure-templates by google.
the class ListImplTest method testListMethods.
@Test
public void testListMethods() {
StringData BLAH_0 = StringData.forValue("blah");
FloatData PI = FloatData.forValue(3.14);
SoyValue BLAH_2 = StringData.forValue("blah");
SoyList list = ListImpl.forProviderList(EMPTY);
assertThat(list.length()).isEqualTo(0);
assertThat(list.asJavaList()).isEmpty();
assertThat(list.asResolvedJavaList()).isEmpty();
assertThat(list.get(0)).isNull();
assertThat(list.getProvider(0)).isNull();
list = ListImpl.forProviderList(ImmutableList.of(BLAH_0, PI, BLAH_2));
// At this point, list should be [BLAH_0, PI, BLAH_2].
assertThat(list.length()).isEqualTo(3);
assertThat(list.asJavaList()).isEqualTo(ImmutableList.of(BLAH_0, PI, BLAH_2));
assertThat(list.asResolvedJavaList()).isEqualTo(ImmutableList.of(BLAH_0, PI, BLAH_2));
assertThat(list.get(0)).isSameAs(BLAH_0);
assertThat(list.get(0)).isNotSameAs(BLAH_2);
// not same, but they compare equal
assertThat(list.get(0)).isEqualTo(BLAH_2);
assertThat(list.getProvider(1).resolve().floatValue()).isWithin(0.0).of(3.14);
}
use of com.google.template.soy.data.restricted.FloatData in project closure-templates by google.
the class EasyListImplTest method testListMethods.
@Test
public void testListMethods() {
StringData BLAH_0 = StringData.forValue("blah");
FloatData PI = FloatData.forValue(3.14);
SoyValue BLAH_2 = StringData.forValue("blah");
SoyEasyList list = new EasyListImpl();
assertThat(list.length()).isEqualTo(0);
assertThat(list.asJavaList()).isEmpty();
assertThat(list.asResolvedJavaList()).isEmpty();
assertThat(list.get(0)).isNull();
assertThat(list.getProvider(0)).isNull();
list.add(BLAH_0);
list.add(PI);
list.add(BLAH_2);
// At this point, list should be [BLAH_0, PI, BLAH_2].
assertThat(list.length()).isEqualTo(3);
assertThat(list.asJavaList()).isEqualTo(ImmutableList.of(BLAH_0, PI, BLAH_2));
assertThat(list.asResolvedJavaList()).isEqualTo(ImmutableList.of(BLAH_0, PI, BLAH_2));
assertThat(list.get(0)).isSameAs(BLAH_0);
assertThat(list.get(0)).isNotSameAs(BLAH_2);
// not same, but they compare equal
assertThat(list.get(0)).isEqualTo(BLAH_2);
assertThat(list.getProvider(1).resolve().floatValue()).isWithin(0.0).of(3.14);
}
Aggregations