<commit_before># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import itertools
import sys
import unittest

import mopy.gn as gn

from mopy.config import Config


class GTestListTestsTest(unittest.TestCase):
  """Tests mopy.gn."""

  def testConfigToGNToConfig(self):
    """Tests that config to gn to config is the identity"""
    configs_to_test = {
      "target_os": [None, "android", "linux", "ios"],
      "target_cpu": [None, "x86", "x64", "arm"],
      "is_simulator": [False, True],
      "is_debug": [False, True],
      "is_official_build": [False, True],
      "is_clang": [False, True],
      "sanitizer": [None, Config.SANITIZER_ASAN],
      "use_goma": [False],
      "use_nacl": [False, True],
      "mojo_use_go": [False],
      "dcheck_always_on": [False, True],
    }

    for args in _iterate_over_config(configs_to_test):
      if args.get("target_os") != "ios" and args["is_simulator"]:
        continue
      config = Config(**args)
      gn_args = gn.GNArgsForConfig(config)
      new_config = gn.ConfigForGNArgs(gn_args)
      self.assertDictEqual(config.values, new_config.values)

  def testGNToConfigToGN(self):
    """Tests that gn to config to gn is the identity"""
    # TODO(vtl): Test OSes other than None (== host?) and "android".
    configs_to_test = {
      "target_os": [None, "android"],<commit_msg>gn_unittest: don't test target_os 'linux' on mac host<commit_after># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import itertools
import sys
import unittest

import mopy.gn as gn

from mopy.config import Config


class GTestListTestsTest(unittest.TestCase):
  """Tests mopy.gn."""

  def testConfigToGNToConfig(self):
    """Tests that config to gn to config is the identity"""
    configs_to_test = {
      "target_os": [None, "android", "linux", "ios"],
      "target_cpu": [None, "x86", "x64", "arm"],
      "is_simulator": [False, True],
      "is_debug": [False, True],
      "is_official_build": [False, True],
      "is_clang": [False, True],
      "sanitizer": [None, Config.SANITIZER_ASAN],
      "use_goma": [False],
      "use_nacl": [False, True],
      "mojo_use_go": [False],
      "dcheck_always_on": [False, True],
    }
    if sys.platform == "darwin":
      configs_to_test["target_os"].remove("linux")

    for args in _iterate_over_config(configs_to_test):
      if args.get("target_os") != "ios" and args["is_simulator"]:
        continue
      config = Config(**args)
      gn_args = gn.GNArgsForConfig(config)
      new_config = gn.ConfigForGNArgs(gn_args)
      self.assertDictEqual(config.values, new_config.values)

  def testGNToConfigToGN(self):
    """Tests that gn to config to gn is the identity"""
    # TODO(vtl): Test OSes other than None (== host?) and "android".
    configs_to_test = {
      "target_os": [None, "android"],
{'fraction_non_alphanumeric': 0.13564356435643565, 'fraction_numerical': 0.005280528052805281, 'mean_word_length': 3.5854765506807866, 'pattern_counts': {'":': 25, '<': 3, '<?xml version=': 0, '>': 3, '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': '3603394', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1010, 'n_words': 284}