<commit_before>#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../test_helper'
require 'sass/engine'

class ScssRxTest < Test::Unit::TestCase
  include Sass::SCSS::RX

  def test_identifiers
    assert_match IDENT, "foo"
    assert_match IDENT, "\377oo" # Initial char can be nonascii
    assert_match IDENT, "\\123abcoo" # Initial char can be unicode escape
    assert_match IDENT, "\\f oo" # Unicode escapes can be followed by whitespace
    assert_match IDENT, "\\fa\too"
    assert_match IDENT, "\\ff2\roo"
    assert_match IDENT, "\\f13a\foo"
    assert_match IDENT, "\\f13abcoo"
    assert_match IDENT, "\\ oo" # Initial char can be a plain escape as well
    assert_match IDENT, "\\~oo"
    assert_match IDENT, "\\\\oo"
    assert_match IDENT, "\\{oo"
    assert_match IDENT, "\\\377oo"
    assert_match IDENT, "-foo" # Can put a - before anything
    assert_match IDENT, "-\377oo"
    assert_match IDENT, "-\\f oo"
    assert_match IDENT, "_foo" # Can put a _ before anything
    assert_match IDENT, "_\377oo"
    assert_match IDENT, "_\\f oo"

    assert_match IDENT, "foo-bar"
    assert_match IDENT, "f012-23"
    assert_match IDENT, "foo_-_bar"
    assert_match IDENT, "f012_23"

    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-003.xht
    assert_match IDENT, "c\\lass"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-004.xht
    assert_match IDENT, "c\\00006Cas\\000073"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-001.xht
    assert_match IDENT, "IdE6n-3t0_6"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-006.xht
    assert_match IDENT, "\\6000ident"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-007.xht
    assert_match IDENT, "iden\\6000t\\6000"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-013.xht
    assert_match IDENT, "\\-ident"
  end

  def test_underscores_in_identifiers
    assert_match IDENT, "foo_bar"
    assert_match IDENT, "_\377foo"
  end

  def test_invalid_identifiers
    assert_no_match IDENT, ""
    assert_no_match IDENT, "1foo"
    assert_no_match IDENT, "-1foo"
    assert_no_match IDENT, "--foo"
    assert_no_match IDENT, "_1foo"
    assert_no_match IDENT, "__foo"
    assert_no_match IDENT, "-_foo"
    assert_no_match IDENT, "_-foo"
    assert_no_match IDENT, "foo bar"
    assert_no_match IDENT, "foo~bar"

    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-008.xht
    assert_no_match IDENT, "c\\06C  ass"
    assert_no_match IDENT, "back\\67\n round"
  end

  def test_double_quote_strings
    assert_match STRING, '"foo bar"'
    assert_match STRING, '"foo\\\nbar"'
    assert_match STRING, "\"\\\"\""
    assert_match STRING, '"\t !#$%&(-~()*+,-./0123456789~"'
  end

  def test_single_quote_strings<commit_msg>[Sass] [SCSS] Make all the test identifiers UTF-8 compatible.<commit_after>#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../../test_helper'
require 'sass/engine'

class ScssRxTest < Test::Unit::TestCase
  include Sass::SCSS::RX

  def test_identifiers
    assert_match IDENT, "foo"
    assert_match IDENT, "\xC3\xBFoo" # Initial char can be nonascii
    assert_match IDENT, "\\123abcoo" # Initial char can be unicode escape
    assert_match IDENT, "\\f oo" # Unicode escapes can be followed by whitespace
    assert_match IDENT, "\\fa\too"
    assert_match IDENT, "\\ff2\roo"
    assert_match IDENT, "\\f13a\foo"
    assert_match IDENT, "\\f13abcoo"
    assert_match IDENT, "\\ oo" # Initial char can be a plain escape as well
    assert_match IDENT, "\\~oo"
    assert_match IDENT, "\\\\oo"
    assert_match IDENT, "\\{oo"
    assert_match IDENT, "\\\xC3\xBFoo"
    assert_match IDENT, "-foo" # Can put a - before anything
    assert_match IDENT, "-\xC3\xBFoo"
    assert_match IDENT, "-\\f oo"
    assert_match IDENT, "_foo" # Can put a _ before anything
    assert_match IDENT, "_\xC3\xBFoo"
    assert_match IDENT, "_\\f oo"

    assert_match IDENT, "foo-bar"
    assert_match IDENT, "f012-23"
    assert_match IDENT, "foo_-_bar"
    assert_match IDENT, "f012_23"

    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-003.xht
    assert_match IDENT, "c\\lass"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-004.xht
    assert_match IDENT, "c\\00006Cas\\000073"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-001.xht
    assert_match IDENT, "IdE6n-3t0_6"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-006.xht
    assert_match IDENT, "\\6000ident"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-007.xht
    assert_match IDENT, "iden\\6000t\\6000"
    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-013.xht
    assert_match IDENT, "\\-ident"
  end

  def test_underscores_in_identifiers
    assert_match IDENT, "foo_bar"
    assert_match IDENT, "_\xC3\xBFfoo"
  end

  def test_invalid_identifiers
    assert_no_match IDENT, ""
    assert_no_match IDENT, "1foo"
    assert_no_match IDENT, "-1foo"
    assert_no_match IDENT, "--foo"
    assert_no_match IDENT, "_1foo"
    assert_no_match IDENT, "__foo"
    assert_no_match IDENT, "-_foo"
    assert_no_match IDENT, "_-foo"
    assert_no_match IDENT, "foo bar"
    assert_no_match IDENT, "foo~bar"

    # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-008.xht
    assert_no_match IDENT, "c\\06C  ass"
    assert_no_match IDENT, "back\\67\n round"
  end

  def test_double_quote_strings
    assert_match STRING, '"foo bar"'
    assert_match STRING, '"foo\\\nbar"'
    assert_match STRING, "\"\\\"\""
    assert_match STRING, '"\t !#$%&(-~()*+,-./0123456789~"'
  end

  def test_single_quote_strings
{'fraction_non_alphanumeric': 0.1428072625698324, 'fraction_numerical': 0.04259776536312849, 'mean_word_length': 3.1695778748180494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, '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': '4089606', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2182, 'n_words': 443}