It seems List.Buffer.snoc (and friends) are meant only to be used through chained calls with a final call to toList(). However, it is possible and sometimes useful to call toList() more than once. In those cases it seem to be returning bogus:
Affects FJ 4.4.
enum Uni {UNI}
@Test
public void test_List_Buffer_snoc() {
List.Buffer<Uni> lb0 = List.Buffer.<Uni>empty();
List.Buffer<Uni> lb1 = lb0.snoc(Uni.UNI);
List<Uni> ls1 = lb1.toList();
assertEquals(1, ls1.length()); //As expected, ls1.length() == 1
List.Buffer<Uni> lb2 = lb1.snoc(Uni.UNI);
List<Uni> ls2 = lb2.toList();
assertEquals(1, ls1.length()); // But, ls1.length() == 3 !
assertEquals(2, ls2.length()); // Also, ls2.length() == 0 !
}
It seems List.Buffer.snoc (and friends) are meant only to be used through chained calls with a final call to toList(). However, it is possible and sometimes useful to call toList() more than once. In those cases it seem to be returning bogus:
Affects FJ 4.4.