<commit_before>/*
 * Copyright (c) 2019, 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.
 */
/**
 * @assertion We extend the list grammar to allow spread elements in addition to
 * regular elements:
 * listLiteral:
 *   const? typeArguments? '[' spreadableList? ']'
 *   ;
 *
 *   spreadableList:
 *   spreadableExpression ( ',' spreadableExpression )* ','?
 *   ;
 *
 *   spreadableExpression:
 *   expression |
 *   spread
 *   ;
 *
 *   spread:
 *   ( '...' | '...?' ) expression
 *   ;
 *
 * Instead of [expressionList], this uses a new [spreadableList] rule since
 * [expressionList] is used elsewhere in the grammar where spreads aren't
 * allowed. Each element in a list is either a normal expression or a spread
 * element. If the spread element starts with [...?], it's a null-aware spread
 * element.
 * @description Checks that [spreadableList] can be constant
 * @author <EMAIL>
 */
// SharedOptions=--enable-experiment=spread-collections

import "../../Utils/expect.dart";

main() {
  const List list1 = ["abc", "int", "hello"];
  const List list2 = [1, 2, 12];
  const List list3 = ["test"];

  List a = const [...list1];
  Expect.listEquals(["abc", "int", "hello"], a);

  a = const ["testme", ...list1];
  Expect.listEquals(["testme", "abc", "int", "hello"], a);

  a = const [...list1, "testme"];
  Expect.listEquals(["abc", "int", "hello", "testme"], a);

  a = const [...list1, ...list2, ...list3];
  Expect.listEquals(["abc", "int", "hello", 1, 2, 12, ""], a);
}<commit_msg>Fixed issue #335<commit_after>/*
 * Copyright (c) 2019, 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.
 */
/**
 * @assertion We extend the list grammar to allow spread elements in addition to
 * regular elements:
 * listLiteral:
 *   const? typeArguments? '[' spreadableList? ']'
 *   ;
 *
 *   spreadableList:
 *   spreadableExpression ( ',' spreadableExpression )* ','?
 *   ;
 *
 *   spreadableExpression:
 *   expression |
 *   spread
 *   ;
 *
 *   spread:
 *   ( '...' | '...?' ) expression
 *   ;
 *
 * Instead of [expressionList], this uses a new [spreadableList] rule since
 * [expressionList] is used elsewhere in the grammar where spreads aren't
 * allowed. Each element in a list is either a normal expression or a spread
 * element. If the spread element starts with [...?], it's a null-aware spread
 * element.
 * @description Checks that [spreadableList] can be constant
 * @author <EMAIL>
 */
// SharedOptions=--enable-experiment=spread-collections

import "../../Utils/expect.dart";

main() {
  const List list1 = ["abc", "int", "hello"];
  const List list2 = [1, 2, 12];
  const List list3 = ["test"];

  List a = const [...list1];
  Expect.listEquals(["abc", "int", "hello"], a);

  a = const ["testme", ...list1];
  Expect.listEquals(["testme", "abc", "int", "hello"], a);

  a = const [...list1, "testme"];
  Expect.listEquals(["abc", "int", "hello", "testme"], a);

  a = const [...list1, ...list2, ...list3];
  Expect.listEquals(["abc", "int", "hello", 1, 2, 12, "test"], a);
}
{'fraction_non_alphanumeric': 0.17077625570776256, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 3.329380764163373, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3310929', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1023, 'n_words': 357}