<commit_before>require 'spec_helper'

describe Oga::XML::Lexer do
  context 'lexing inline Javascript' do
    before do
      @javascript = <<-EOF.strip
(function()
{
  if ( some_number < 10 )
  {
    console.log('Hello');
  }
})();
      EOF
    end

    example 'lex inline Javascript' do
      lex("<script>\n#{@javascript}\n</script>").should == [
        [:T_ELEM_START, nil, 1],
        [:T_ELEM_NAME, 'script', 1],
        [:T_TEXT, "\n#{@javascript}\n", 1],
        [:T_ELEM_END, nil, 9]
      ]
    end
  end
end
<commit_msg>Added spec for inline JS + comments.<commit_after>require 'spec_helper'

describe Oga::XML::Lexer do
  context 'lexing inline Javascript' do
    before do
      @javascript = 'if ( number < 10 ) { }'
    end

    example 'lex inline Javascript' do
      lex("<script>#{@javascript}</script>").should == [
        [:T_ELEM_START, nil, 1],
        [:T_ELEM_NAME, 'script', 1],
        [:T_TEXT, @javascript, 1],
        [:T_ELEM_END, nil, 1]
      ]
    end

    example 'lex inline Javascript containing an XML comment' do
      lex("<script>#{@javascript}<!--foo--></script>").should == [
        [:T_ELEM_START, nil, 1],
        [:T_ELEM_NAME, 'script', 1],
        [:T_TEXT, @javascript, 1],
        [:T_ELEM_END, nil, 1],
        [:T_COMMENT, 'foo', 1]
      ]
    end
  end
end

{'fraction_non_alphanumeric': 0.16793313069908813, 'fraction_numerical': 0.012917933130699088, 'mean_word_length': 2.512, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 10, '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': '3510898', 'n_tokens_mistral': 511, 'n_tokens_neox': 454, 'n_words': 111}