<commit_before>@test
shared void comprehensions() {
  //Used in initializers
  value s1 = [ for (w in {"hello", "world"}) for (c in w) c.string ];
  value s2 = [ for (w in {"hello", "world"}) for (c in w) if (c in "hw") c.uppercased ];
  value s3 = [ for (c in "hello") c.string ];
  //simple invocation
  check(Array{for (c in "hello") c.string}==Array{"h", "e", "l", "l", "o"}, "comprehensions 1");
  //named arg invocation - not callable anymore with a comprehension
  /*check(array {
    for (c in "hello") c.string
  } == Array("h", "e", "l", "l", "o"), "comprehensions 2");*/
  check(s1=={ "h", "e", "l", "l", "o", "w", "o", "r", "l", "d" }.sequence, "comprehensions 3");
  check(s2=={ 'H', 'W' }.sequence, "comprehensions 4");
  check(s3=={ "h", "e", "l", "l", "o" }.sequence, "comprehensions 5");
  check([for (y in 1..5) for (x in 1..5) if (x>y) x*y]=={2, 3, 4, 5, 6, 8, 10, 12, 15, 20}.sequence, "comprehensions 6");
  check([for (x in 1..6) if (x % 2 == 0) for (y in 1..3) x*y]=={2,4,6,4,8,12,6,12,18}.sequence, "comprehensions 7");
  check([for (x in 1..6) if (x % 2 == 0) for (y in 1..3) if ((x*y)%3==0) x*y]=={6,12,6,12,18}.sequence, "comprehensions 8");
  check([for (x in 1..10) if (x%2==0) if (x>5) x]=={6,8,10}.sequence, "comprehensions 9");
  variable Object varcomp = s1;
  check(varcomp is Iterable<Anything>, "comprehension is Iterable");
  check([for (x in {null, "hello", "goodbye"}) if (exists x) if (x.size>5) x]=={"goodbye"}.sequence, "comprehensions w/exists 1");
  check([for (x in {"a", "", "c"}) if (exists c=x[0]) c.uppercased]=={'A', 'C'}.sequence, "comprehensions w/exists 2");
  check([for (x in {"a", "", "c"}) if (!x.empty) x.uppercased]=={"A", "C"}.sequence, "comprehensions w/nonempty 1");
  check([for (x in {"a", "", "c"}) if (!x.empty) x.uppercased]=={"A", "C"}.sequence, "comprehensions w/nonempty 2");
  check([for (x in {1,2,"3.1",4}) if (is String x) x.reversed]=={"1.3"}.sequence, "comprehensions w/is 1");
  check([for (x in {1.1,2.2,3,4.4}) if (is Integer i=x) i*2]=={6}.sequence, "comprehensions w/is 2");
  check(Array{for (k->v in entries(["a","b","c","d","e"])) if (k%2==0) v.uppercased}==Array({"A","C","E"}), "key-value comprehensions");
  // comprehension nested inside comprehension
  check([for(i in 1..2)[for(j in 1..2)"``i``,``j``"]]==[["1,1","1,2"],["2,1","2,2"]], "nested comprehension ``[for(i in 1..2)[for(j in 1..2)"``i``,``j``"]]`` instead of {{1,1,1,2},{2,1,2,2}}");
  //comprehensions beginning with if clause: ceylon-spec#869
  {String*}? strings = { "Hello", "beautiful", "World" };
  value existingStrings = strings;
  assert (exists existingStrings);
  check([if (is {String*} strings) strings] == { existingStrings }.sequence, "comprehensions starting with if 1: if");
  check([if (is {String*} strings) for (string in strings) string] == existingStrings.sequence, "comprehensions starting with if 2: if for");
  check([if (is {String*} strings) for (string in strings) if (exists first=string.first, first.uppercase) string] == {"Hello", "World"}.sequence, "comprehensions starting with if 3: if for if");
  check([if (2 + 2 == 4) if ((1..10).size==10) if (is {String*} strings) for (string in strings) string.uppercased] == {"HELLO", "BEAUTIFUL", "WORLD"}.sequence, "comprehensions starting with if 4: if if if for");
  check([if (1+1==2) if (2+2==5) if (2+3==5) true] == empty, "comprehensions starting with if 5: if ifFalse if");
  check([if (1+1==2) if (2+2==4) if (2+2==5) true] == empty, "comprehensions starting with if 6: if if ifFalse");
  check([if (2+2==5) if (1+1==2) if (2+2==4) true] == empty, "comprehensions starting with if 7: ifFalse if if");
  variable value test=0;
  function f() => test++>0;
  check(test==0, "comprehensions starting with if 8: general laziness");
  f();
  check(test==1, "comprehensions starting with if 8: variable capture");
  check([if (f()) 1] == {1}.sequence, "comprehensions starting with if 8: collection");
  check(test==3, "comprehensions starting with if 8: evaluation");
  test = 2;
  check(![if (!f()) 1] nonempty, "comprehensions starting with if 8: nonemptiness");
  check(test==3, "comprehensions starting with if 8: evaluation 2");
  test = 3;
  value c = {if (f()) if (!f()) 1};<commit_msg>fix a test (why did it pass before?)<commit_after>@test
shared void comprehensions() {
  //Used in initializers
  value s1 = [ for (w in {"hello", "world"}) for (c in w) c.string ];
  value s2 = [ for (w in {"hello", "world"}) for (c in w) if (c in "hw") c.uppercased ];
  value s3 = [ for (c in "hello") c.string ];
  //simple invocation
  check(Array{for (c in "hello") c.string}==Array{"h", "e", "l", "l", "o"}, "comprehensions 1");
  //named arg invocation - not callable anymore with a comprehension
  /*check(array {
    for (c in "hello") c.string
  } == Array("h", "e", "l", "l", "o"), "comprehensions 2");*/
  check(s1=={ "h", "e", "l", "l", "o", "w", "o", "r", "l", "d" }.sequence, "comprehensions 3");
  check(s2=={ 'H', 'W' }.sequence, "comprehensions 4");
  check(s3=={ "h", "e", "l", "l", "o" }.sequence, "comprehensions 5");
  check([for (y in 1..5) for (x in 1..5) if (x>y) x*y]=={2, 3, 4, 5, 6, 8, 10, 12, 15, 20}.sequence, "comprehensions 6");
  check([for (x in 1..6) if (x % 2 == 0) for (y in 1..3) x*y]=={2,4,6,4,8,12,6,12,18}.sequence, "comprehensions 7");
  check([for (x in 1..6) if (x % 2 == 0) for (y in 1..3) if ((x*y)%3==0) x*y]=={6,12,6,12,18}.sequence, "comprehensions 8");
  check([for (x in 1..10) if (x%2==0) if (x>5) x]=={6,8,10}.sequence, "comprehensions 9");
  variable Object varcomp = s1;
  check(varcomp is Iterable<Anything>, "comprehension is Iterable");
  check([for (x in {null, "hello", "goodbye"}) if (exists x) if (x.size>5) x]=={"goodbye"}.sequence, "comprehensions w/exists 1");
  check([for (x in {"a", "", "c"}) if (exists c=x[0]) c.uppercased]=={'A', 'C'}.sequence, "comprehensions w/exists 2");
  check([for (x in {"a", "", "c"}) if (!x.empty) x.uppercased]=={"A", "C"}.sequence, "comprehensions w/nonempty 1");
  check([for (x in {"a", "", "c"}) if (!x.empty) x.uppercased]=={"A", "C"}.sequence, "comprehensions w/nonempty 2");
  check([for (x in {1,2,"3.1",4}) if (is String x) x.reversed]=={"1.3"}.sequence, "comprehensions w/is 1");
  check([for (x in {1.1,2.2,3,4.4}) if (is Integer i=x) i*2]=={6}.sequence, "comprehensions w/is 2");
  check(Array{for (k->v in entries(["a","b","c","d","e"])) if (k%2==0) v.uppercased}==Array({"A","C","E"}), "key-value comprehensions");
  // comprehension nested inside comprehension
  check([for(i in 1..2)[for(j in 1..2)"``i``,``j``"]]==[["1,1","1,2"],["2,1","2,2"]], "nested comprehension ``[for(i in 1..2)[for(j in 1..2)"``i``,``j``"]]`` instead of {{1,1,1,2},{2,1,2,2}}");
  //comprehensions beginning with if clause: ceylon-spec#869
  {String*}? strings = { "Hello", "beautiful", "World" };
  value existingStrings = strings;
  assert (exists existingStrings);
  check([if (is {String*} strings) strings] == { existingStrings }.sequence, "comprehensions starting with if 1: if");
  check([if (is {String*} strings) for (string in strings) string] == existingStrings.sequence, "comprehensions starting with if 2: if for");
  check([if (is {String*} strings) for (string in strings) if (exists first=string.first, first.uppercase) string] == {"Hello", "World"}.sequence, "comprehensions starting with if 3: if for if");
  check([if (2 + 2 == 4) if ((1..10).size==10) if (is {String*} strings) for (string in strings) string.uppercased] == {"HELLO", "BEAUTIFUL", "WORLD"}.sequence, "comprehensions starting with if 4: if if if for");
  check([if (1+1==2) if (2+2==5) if (2+3==5) true] == empty, "comprehensions starting with if 5: if ifFalse if");
  check([if (1+1==2) if (2+2==4) if (2+2==5) true] == empty, "comprehensions starting with if 6: if if ifFalse");
  check([if (2+2==5) if (1+1==2) if (2+2==4) true] == empty, "comprehensions starting with if 7: ifFalse if if");
  variable value test=0;
  function f() => test++>0;
  check(test==0, "comprehensions starting with if 8: general laziness");
  f();
  check(test==1, "comprehensions starting with if 8: variable capture");
  check([if (f()) 1] == {1}.sequence, "comprehensions starting with if 8: collection");
  check(test==2, "comprehensions starting with if 8: evaluation");
  check(![if (!f()) 1] nonempty, "comprehensions starting with if 8: nonemptiness");
  check(test==3, "comprehensions starting with if 8: evaluation 2");
  test = 3;
  value c = {if (f()) if (!f()) 1};
{'fraction_non_alphanumeric': 0.23955991955518752, 'fraction_numerical': 0.045309357624512006, 'mean_word_length': 4.778537252221462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7456994', 'n_tokens_mistral': 3475, 'n_tokens_neox': 3215, 'n_words': 1002}