<commit_before>// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Tests for basic functionality.

library basic_tests;

import 'js_backend_cps_ir.dart';

const List<TestEntry> tests = const [
  const TestEntry(r"""
main() {
  var e = 1;
  var l = [1, 2, 3];
  var m = {'s': 1};

  print('(' ')');
  print('(${true})');
  print('(${1})');
  print('(${[1, 2, 3]})');
  print('(${{'s': 1}})');
  print('($e)');
  print('($l)');
  print('($m)');
}""",r"""
function() {
  var l = [1, 2, 3], m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]);
  P.print("()");
  P.print("(" + true + ")");
  P.print("(" + 1 + ")");
  P.print("(" + H.S([1, 2, 3]) + ")");
  P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")");
  P.print("(" + 1 + ")");
  P.print("(" + H.S(l) + ")");
  P.print("(" + H.S(m) + ")");
  return null;
}"""),
  const TestEntry("""
foo(a, [b = "b"]) => b;
bar(a, {b: "b", c: "c"}) => c;
main() {
  foo(0);
  foo(1, 2);
  bar(3);
  bar(4, b: 5);
  bar(6, c: 7);
  bar(8, b: 9, c: 10);
}
""",
"""
function() {
  V.foo(0, "b");
  V.foo(1, 2);
  V.bar(3, "b", "c");
  V.bar(4, 5, "c");
  V.bar(6, "b", 7);
  V.bar(8, 9, 10);
  return null;
}"""),
  const TestEntry(
  """
foo(a) {
  return a;
}
main() {
  var a = 10;
  var b = 1;
  var t;
  t = a;
  a = b;
  b = t;
  print(a);
  print(b);
  print(b);
  print(foo(a));
}
  """,
  """
function() {
  var a = 10, b = 1;
  P.print(b);
  P.print(a);
  P.print(a);
  P.print(V.foo(b));
  return null;
}"""),
  const TestEntry(
  """
foo() { return 42; }
main() { return foo(); }
  """,
  """function() {
  return V.foo();
}"""),
  const TestEntry("main() {}"),
  const TestEntry("main() { return 42; }"),
  const TestEntry("main() { return; }", """
function() {
  return null;
}"""),
  // Constructor invocation
  const TestEntry("""
main() {
  print(new Set());
  print(new Set.from([1, 2, 3]));
}""", r"""
function() {
  P.print(P.LinkedHashSet_LinkedHashSet(null));
  P.print(P.LinkedHashSet_LinkedHashSet$from([1, 2, 3], null));
  return null;
}"""),
  // Call synthetic constructor.
  const TestEntry("""
class C {}<commit_msg>Fix cps-ir copmilation unit test.<commit_after>// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Tests for basic functionality.

library basic_tests;

import 'js_backend_cps_ir.dart';

const List<TestEntry> tests = const [
  const TestEntry(r"""
main() {
  var e = 1;
  var l = [1, 2, 3];
  var m = {'s': 1};

  print('(' ')');
  print('(${true})');
  print('(${1})');
  print('(${[1, 2, 3]})');
  print('(${{'s': 1}})');
  print('($e)');
  print('($l)');
  print('($m)');
}""",r"""
function() {
  var l = [1, 2, 3], m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]);
  P.print("()");
  P.print("(" + true + ")");
  P.print("(" + 1 + ")");
  P.print("(" + H.S([1, 2, 3]) + ")");
  P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")");
  P.print("(" + 1 + ")");
  P.print("(" + H.S(l) + ")");
  P.print("(" + H.S(m) + ")");
  return null;
}"""),
  const TestEntry("""
foo(a, [b = "b"]) => b;
bar(a, {b: "b", c: "c"}) => c;
main() {
  foo(0);
  foo(1, 2);
  bar(3);
  bar(4, b: 5);
  bar(6, c: 7);
  bar(8, b: 9, c: 10);
}
""",
"""
function() {
  V.foo(0, "b");
  V.foo(1, 2);
  V.bar(3, "b", "c");
  V.bar(4, 5, "c");
  V.bar(6, "b", 7);
  V.bar(8, 9, 10);
  return null;
}"""),
  const TestEntry(
  """
foo(a) {
  return a;
}
main() {
  var a = 10;
  var b = 1;
  var t;
  t = a;
  a = b;
  b = t;
  print(a);
  print(b);
  print(b);
  print(foo(a));
}
  """,
  """
function() {
  var a = 10, b = 1;
  P.print(b);
  P.print(a);
  P.print(a);
  P.print(V.foo(b));
  return null;
}"""),
  const TestEntry(
  """
foo() { return 42; }
main() { return foo(); }
  """,
  """function() {
  return V.foo();
}"""),
  const TestEntry("main() {}"),
  const TestEntry("main() { return 42; }"),
  const TestEntry("main() { return; }", """
function() {
  return null;
}"""),
  // Constructor invocation
  const TestEntry("""
main() {
  print(new Set());
  print(new Set.from([1, 2, 3]));
}""", r"""
function() {
  P.print(P.LinkedHashSet_LinkedHashSet(null, null, null, null));
  P.print(P.LinkedHashSet_LinkedHashSet$from([1, 2, 3], null));
  return null;
}"""),
  // Call synthetic constructor.
  const TestEntry("""
class C {}
{'fraction_non_alphanumeric': 0.2773897861195984, 'fraction_numerical': 0.027935399388913137, 'mean_word_length': 3.3073308270676693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1368653', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1947, 'n_words': 483}