<commit_before>require_relative '../../test_helper'
require 'app/helpers/syntax'

class SyntaxHelperTest < Minitest::Test
  def helper
    return @helper if @helper
    @helper = Object.new
    @helper.extend(ExercismWeb::Helpers::Syntax)
    @helper
  end

  def test_inline_markdown
  code = <<CODE
"""
```Leap year
Most years are not leap years.
Is a leap year if every year that is evenly divisible by 4.
  Is not a leaper if it is evenly divisible by 100.
    Is a leap year if evenly divisible by 400.
Test driven development forced us to care about most of of the cases right away.
The examples in the test made the read me much clearer.
Python error about module meant to suggest a particular file name.
Pythons logical and operator simpler than Javascript's ampersands.(&)
Exercism readme's structured as nonrepeating text was unclear.
Acceptance criteria for even the most basic cases can be unclear.
Exercism's domain specific language takes some getting used to each time.
```
"""

def is_leap_year(year):
    if year % 4 != 0:
        return False
    elif year % 4 == 0  and year % 400 == 0:
        return True
    elif year % 4 == 0  and year % 100 == 0:
        return False
    return True
CODE

    output = helper.syntax(code, "python")
    refute_match('<p>', output)
  end
end
<commit_msg>Simplify and extend #syntax helper specs<commit_after>require_relative '../../test_helper'
require 'app/helpers/syntax'

class SyntaxHelperTest < Minitest::Test
  def helper
    return @helper if @helper
    @helper = Object.new
    @helper.extend(ExercismWeb::Helpers::Syntax)
    @helper
  end

  def test_inline_markdown
    code = <<CODE
"""
Method usage:
```
foo.bar()
```
"""

def bar():
    return True
CODE

    output = helper.syntax(code, "python")
    refute_match('<p>', output)
    assert_match('<div class="highlight python">', output)
  end

  def test_language_option
    code = <<CODE
def bar():
    return True
CODE

    output = helper.syntax(code, "python")
    assert_match('<div class="highlight python">', output)
  end
end

{'fraction_non_alphanumeric': 0.09766763848396501, 'fraction_numerical': 0.01020408163265306, 'mean_word_length': 3.495633187772926, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': '4800677', 'n_tokens_mistral': 653, 'n_tokens_neox': 604, 'n_words': 239}