<commit_before>import ceylon.collection {
    ...
}
import ceylon.test {
    ...
}

void doTestMap(MutableMap<String,String> map) {
    assertEquals("{}", map.string);
    assertEquals(0, map.size);
    assertTrue(!map.defines("fu"), "a");
    assertEquals(null, map.put("fu", "bar"));
    assertEquals("{ fu->bar }", map.string);
    assertEquals(1, map.size);
    assertTrue(map.defines("fu"), "b");
    assertEquals("bar", map.put("fu", "gee"));
    assertEquals("{ fu->gee }", map.string);
    assertEquals(1, map.size);
    assertTrue(map.defines("fu"), "c");
    map.put("stef", "epardaud");
    assertEquals(2, map.size);
    assertTrue(map.defines("fu"), "d");
    assertTrue(map.defines("stef"), "e");
    assertEquals("epardaud", map["stef"]);
    assertEquals("gee", map["fu"]);
    assertEquals(null, map["bar"]);
    map.clear();
    assertEquals("{}", map.string);
    assertEquals(0, map.size);
    assertTrue(!map.defines("fu"), "f"); // equality
}

shared test void testMap(){
    doTestMap(TreeMap<String,String>((String x, String y)=>x<=>y));
    doTestMap(HashMap<String,String>());
}

shared test void testMapEquality() {
    assertEquals(HashMap{}, HashMap{});
    assertEquals(HashMap{"a"->1, "b"->2}, HashMap{"b"->2, "a"->1});<commit_msg>Added test for Map.clone<commit_after>import ceylon.collection {
    ...
}
import ceylon.test {
    ...
}

void doTestMap(MutableMap<String,String> map) {
    assertEquals("{}", map.string);
    assertEquals(0, map.size);
    assertTrue(!map.defines("fu"), "a");
    assertEquals(null, map.put("fu", "bar"));
    assertEquals("{ fu->bar }", map.string);
    assertEquals(1, map.size);
    assertTrue(map.defines("fu"), "b");
    assertEquals("bar", map.put("fu", "gee"));
    assertEquals("{ fu->gee }", map.string);
    assertEquals(1, map.size);
    assertTrue(map.defines("fu"), "c");
    map.put("stef", "epardaud");
    assertEquals(2, map.size);
    assertTrue(map.defines("fu"), "d");
    assertTrue(map.defines("stef"), "e");
    assertEquals("epardaud", map["stef"]);
    assertEquals("gee", map["fu"]);
    assertEquals(null, map["bar"]);
    map.clear();
    assertEquals("{}", map.string);
    assertEquals(0, map.size);
    assertTrue(!map.defines("fu"), "f");
    
    function toString(Integer i) => i.string;
    
    // clone test
    for (number in 1..100) {
        map.put(number.string, "#" + number.string);
    }
    value clone = map.clone();
    assertEquals(map, clone);
    map.remove("10");
    assertTrue(map.definesEvery((1..9).map(toString)));
    assertTrue(map.definesEvery((11..100).map(toString)));
    assertFalse(map.defines("10"));
    assertTrue(clone.definesEvery((1..100).map(toString)));
    
    clone.removeAll((60..70).map(toString));
    assertTrue(clone.definesEvery((1..59).map(toString)));
    assertTrue(clone.definesEvery((71..100).map(toString)));
    assertFalse(clone.definesAny((60..70).map(toString)));
    assertTrue(map.definesEvery((11..100).map(toString)));
}

shared test void testMap(){
    value treeMap = TreeMap<String,String>((String x, String y)=>x<=>y);
    doTestMap(treeMap);
    treeMap.assertInvariants();
    treeMap.clone().assertInvariants();
    doTestMap(HashMap<String,String>());
}

shared test void testMapEquality() {
    assertEquals(HashMap{}, HashMap{});
    assertEquals(HashMap{"a"->1, "b"->2}, HashMap{"b"->2, "a"->1});
{'fraction_non_alphanumeric': 0.21971496437054633, 'fraction_numerical': 0.0172209026128266, 'mean_word_length': 4.120060790273556, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '3622517', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1139, 'n_words': 181}