<commit_before>class TestList<Element>(Element... items) satisfies List<Element> {
    value elems = items.sequence;
    shared actual Boolean equals(Object other) { return false; }
    shared actual Element? item(Integer x) { return elems[x]; }
    shared actual TestList<Element> reversed { return TestList(elems.reversed...); }
    shared actual Integer hash { return elems.hash; }
    shared actual Integer? lastIndex { return elems.lastIndex; }
    shared actual TestList<Element> span(Integer a, Integer? b) { return TestList(elems.span(a, b)...); }
    shared actual TestList<Element> segment(Integer a, Integer b) { return TestList(elems.segment(a, b)...); }
    shared actual TestList<Element> clone { return TestList(items...); }
}

void lists() {
    value a = TestList(1,2,3,4);
    value b = TestList(1,2,3,4,5,6,7,8);
    //withLeading
    assert({}.withLeading()=={}, "Empty.withLeading()");
    assert({}.withLeading("A")=={"A"}, "Empty.withLeading(A)");
    assert({}.withLeading("A","B")=={"A","B"}, "Empty.withLeading(A,B)");
    assert(array().withLeading()=={}, "empty array.withLeading()");
    assert(array().withLeading(1,2)=={1,2}, "empty array.withLeading(1,2)");
    assert(array(1,2).withLeading()=={1,2}, "Array.withLeading()");
    assert(array(1,2).withLeading("A","B")=={"A","B",1,2}, "Array.withLeading(a,b)");
    assert({1,2}.withLeading()=={1,2}, "Sequence.withLeading()");
    assert({1,2}.withLeading("a","b")=={"a","b",1,2}, "Sequence.withLeading()");
    assert(Singleton(1).withLeading()=={1}, "Singleton.withLeading()");
    assert(Singleton(1).withLeading("a","b")=={"a","b",1}, "Singleton.withLeading(a,b)");
    assert((1..3).withLeading()==1..3, "Range.withLeading()");
    assert((1..3).withLeading("a","b")=={"a","b",1,2,3}, "Range.withLeading(a,b)");
    assert((1..3).withLeading(0).first==0, "Range.withLeading(a).first");
    assert("abc".withLeading()=="abc", "String.withLeading()");
    assert("abc".withLeading(1,2)=={1,2,`a`,`b`,`c`}, "String.withLeading(1,2)");
    assert("".withLeading()=="", "\"\".withLeading()");
    assert("".withLeading(1)=={1}, "\"\".withLeading(1)");

    //withTrailing
    assert({}.withTrailing()=={}, "Empty.withTrailing()");
    assert({}.withTrailing("A")=={"A"}, "Empty.withTrailing(A)");
    assert({}.withTrailing("A","B")=={"A","B"}, "Empty.withTrailing(A,B)");
    assert(array().withTrailing()=={}, "empty array.withTrailing()");
    assert(array().withTrailing(1,2)=={1,2}, "empty array.withTrailing(1,2)");
    assert(array(1,2).withTrailing()=={1,2}, "Array.withTrailing()");
    assert(array(1,2).withTrailing("A","B")=={1,2,"A","B"}, "Array.withTrailing(a,b)");
    assert({1,2}.withTrailing()=={1,2}, "Sequence.withTrailing()");
    assert({1,2}.withTrailing("a","b")=={1,2,"a","b"}, "Sequence.withTrailing()");
    assert(Singleton(1).withTrailing()=={1}, "Singleton.withTrailing()");
    assert(Singleton(1).withTrailing("a","b")=={1,"a","b"}, "Singleton.withTrailing(a,b)");
    assert((1..3).withTrailing()==1..3, "Range.withTrailing()");
    assert((1..3).withTrailing()==1..3, "Range.withTrailing()");
    assert((1..3).withTrailing(4).first==1, "Range.withTrailing(a).first");
    assert("abc".withTrailing()=="abc", "String.withTrailing()");
    assert("abc".withTrailing(1,2)=={`a`,`b`,`c`,1,2}, "String.withTrailing(1,2)");
    assert("".withTrailing()=="", "\"\".withTrailing()");
    assert("".withTrailing(1)=={1}, "\"\".withTrailing(1)");
}<commit_msg>Update withLeading/withTrailing tests to close #129<commit_after>class TestList<Element>(Element... items) satisfies List<Element> {
    value elems = items.sequence;
    shared actual Boolean equals(Object other) { return false; }
    shared actual Element? item(Integer x) { return elems[x]; }
    shared actual TestList<Element> reversed { return TestList(elems.reversed...); }
    shared actual Integer hash { return elems.hash; }
    shared actual Integer? lastIndex { return elems.lastIndex; }
    shared actual TestList<Element> span(Integer a, Integer? b) { return TestList(elems.span(a, b)...); }
    shared actual TestList<Element> segment(Integer a, Integer b) { return TestList(elems.segment(a, b)...); }
    shared actual TestList<Element> clone { return TestList(items...); }
}

void lists() {
    value a = TestList(1,2,3,4);
    value b = TestList(1,2,3,4,5,6,7,8);
    //withLeading
    assert({}.withLeading("A")=={"A"}, "Empty.withLeading(A)");
    assert(array().withLeading(1)=={1}, "empty array.withLeading(1)");
    assert(array(1,2).withLeading("A")=={"A",1,2}, "Array.withLeading(a)");
    assert({1,2}.withLeading("a")=={"a",1,2}, "Sequence.withLeading(a)");
    assert(Singleton(1).withLeading("a")=={"a",1}, "Singleton.withLeading(a)");
    assert((1..3).withLeading("a")=={"a",1,2,3}, "Range.withLeading(a)");
    assert((1..3).withLeading(0).first==0, "Range.withLeading(a).first");
    assert((1..3).withLeading(0).last==3, "Range.withLeading(a).last");
    assert("abc".withLeading(1)=={1,`a`,`b`,`c`}, "String.withLeading(1)");
    assert("".withLeading(1)=={1}, "\"\".withLeading(1)");

    //withTrailing
    assert({}.withTrailing("A")=={"A"}, "Empty.withTrailing(A)");
    assert(array().withTrailing(1)=={1}, "empty array.withTrailing(1)");
    assert(array(1,2).withTrailing("A")=={1,2,"A"}, "Array.withTrailing(a)");
    assert({1,2}.withTrailing("a")=={1,2,"a"}, "Sequence.withTrailing(a)");
    assert(Singleton(1).withTrailing("a")=={1,"a"}, "Singleton.withTrailing(a)");
    assert((1..3).withTrailing(4)=={1,2,3,4}, "Range.withTrailing(a)");
    assert((1..3).withTrailing(4).first==1, "Range.withTrailing(a).first");
    assert((1..3).withTrailing(4).last==4, "Range.withTrailing(a).last");
    assert("abc".withTrailing(1)=={`a`,`b`,`c`,1}, "String.withTrailing(1)");
    assert("".withTrailing(1)=={1}, "\"\".withTrailing(1)");
}
{'fraction_non_alphanumeric': 0.26244653550042774, 'fraction_numerical': 0.03216424294268606, 'mean_word_length': 5.7272727272727275, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3259691', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2180, 'n_words': 275}