<commit_before>package org.fusesource.scalate.ssp

import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import collection.mutable.HashMap
import org.scalatest.FunSuite

/**
 * @version $Revision : 1.1 $
 */
@RunWith(classOf[JUnitRunner])
class ParserTest extends FunSuite {
  val logging = false

  test("parse attribute declaration") {
    val lines = assertValid("""<%@ val name: String %>
<html>
  <%-- comment --%>
  <body>
    <h1>Hello ${user > 5}</h1>
    <p>Hey <%= blah.somthing("$blah") % 5 %></p>
  </body>
</html>
""")

    assertAttribute(lines, AttributeFragment("val", "name", "String", None, false))
  }

  test("parse valid SSP file with attribute with default value") {<commit_msg>Failing test for a bug in SspParser.<commit_after>package org.fusesource.scalate.ssp

import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import collection.mutable.HashMap
import org.scalatest.FunSuite

/**
 * @version $Revision : 1.1 $
 */
@RunWith(classOf[JUnitRunner])
class ParserTest extends FunSuite {
  val logging = false

  test("parse attribute declaration") {
    val lines = assertValid("""<%@ val name: String %>
<html>
  <%-- comment --%>
  <body>
    <h1>Hello ${user > 5}</h1>
    <p>Hey <%= blah.somthing("$blah") % 5 %></p>
  </body>
</html>
""")

    assertAttribute(lines, AttributeFragment("val", "name", "String", None, false))
  }

// Failing test!
// In the current SspParser implementation we cannot have whitespace in the default value
//  test("parse attribute declaration with the default value being a constructor invocation") {
//    val lines = assertValid("""<%@ val name: String = new String("spiros")%>
//<html>
//  <%-- comment --%>
//  <body>
//    <h1>Hello ${name}</h1>
//  </body>
//</html>
//""")
//    assertAttribute(lines, AttributeFragment("val", "name", "String", Some("new String(\"spiros\")"), false))
//  }
  

  test("parse valid SSP file with attribute with default value") {
{'fraction_non_alphanumeric': 0.17491075981642018, 'fraction_numerical': 0.0071392146863844975, 'mean_word_length': 3.92964824120603, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '3957956', 'n_tokens_mistral': 666, 'n_tokens_neox': 640, 'n_words': 169}