<commit_before>package ducttape.syntax
import ducttape.util.AbstractTest
import ducttape.syntax.GrammarParser.Parser
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class RValueTest extends AbstractTest("rvalue",Grammar.rvalue) {
 
  def successCases = Set(

    // Branch point
    """(branchPointName: a=1)""",
    """(branchPointName: a=1 b=5)""",   
    """(greeting: y="welcome home" z="bugger off")""",
    """(sauce: a1="A1 Sauce" ketchup="<NAME>" wasabi="wasabi")""",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=\"kumbaya\" )",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=\"kumbaya\")",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=kumbaya)",      
      
    // Sequential branch point
    """(branchPointName: 1..5)""",   
    """(branchPointName: 1..5.0)""",
    """(branchPointName: 1.0..5.0)""",
    """(branchPointName: 10e1..10e999)""",
    """(branchPointName: 9.9e256..7.7e1024)""",
    """(branchPointName: 1..6..2)""",   
    """(branchPointName: 1..5.0..0.5)""",
    """(branchPointName: 1.0..5.0..2)""",
    """(branchPointName: 10e1..10e999..1)""",
    """(branchPointName: 9.9e256..7.7e1024..5.4e3)""",      
      
    // Branch graft
    "$variableName@taskName[branchPointName:branchName]",
    "$variableName@taskName[branchPointName:*]",
    "$variableName@taskName[a:b,c:d]",
    "$variableName@taskName[a1:b2,c3:*,d4:e5,f6:g7]",
      
    // Task variable reference
    "$A_variable_Name__@foo",
    "$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_@barBar",
    "$abc@def",
    "${A_variable_Name__}@foo",
    "${ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_}@barBar",
    "${abc}@def",
      
    // Variable reference
    "$A_variable_Name__",
    "$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_",
    "$abc",
    "${A_variable_Name__}",
    "${ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_}",
    "${abc}",
    
    // Unquoted literal
    "A_variable_Name__",
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_",
    "/path/to/something/cool",
    "abc",    
    "A-variable_Name__",
    "A_variable_Name__",
    
    // Quoted literal
    """"This is a quoted string"""",
    """'This one uses single quotes '""",
    """' Escape\tsequences\nare\rallowed! '""",
    "\"Unicode sequences should be fine \u21AF too\"",
    "\'Unicode sequences should be fine \u2231 too\'",   
    
    // Triple quoted literal
    "\"\"\"" + "This is a quoted string" + "\"\"\"",
    "\"\"\"" + """This is a quoted string with \r lots of \\u garbage! \b in it!""" + "\"\"\"",    
    
    // Complex nesting
    "(a: a1=(k: 8..12) a4=7)",
    "(a: a1=$g@taskH[i:j])",
    "(a: a1=(b: f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",      
    "(a: a1=(b: c=$d@taskE) a2=5 a3=(k: 8..12) a4=7)",      
    "(a: a1=(b: c=$d@taskE f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",
    "(a: a1=(b: c=(x: x1=$d@taskE x2=farOut x3=\"\"\"Quoted!\"\"\") f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",    

      // Anonymous sequential branch point
      """(1..5)""",   
      """(1..5.0)""",
      """(1.0..5.0)""",
      """(10e1..10e999)""",
      """(9.9e256..7.7e1024)""",
      """(1..6..2)""",   
      """(1..5.0..0.5)""",
      """(1.0..5.0..2)""",
      """(10e1..10e999..1)""",
      """(9.9e256..7.7e1024..5.4e3)""",      
    
    // Anonymous branch point (no branch point name)
    "(foo=bar)",
    "(a=1 b=2)",
    
    // Anonymous branch point with bare rvalues
    "(foo)",
    "(1 2)",
    "((1..10) 7 42 (100..1000..100))"
  ) 
  
  def failureCases = Set(
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_ :",
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_     :"
  ) 
  
  def errorCases = Set(
    "$variableName@taskName[",
    "$A-variable_Name__",
    "$",
    "A_variable_Name__:",      
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_:",
    """"This is a badly quoted string\"""",
    """"This one is, too"it seems"""",
    """'Starting with a single and ending with a double"""",
    """"Starting with a double and ending with a single'""",    
    " ",
    "",
    "\"\"\"This is a badly quoted string",
    "\"\"\"This is a badly quoted string\"",
    "\"\"\"This is a badly quoted string\"\"",
    "\"\"\"This is a badly quoted string'",
    "\"\"\"This is a badly quoted string''",
    "\"\"\"This is a badly quoted string'''"    
  )
  
}<commit_msg>Update test: Doesn't seem like there's any way of coming up with a reasonable name for this anonymous branch<commit_after>package ducttape.syntax
import ducttape.util.AbstractTest
import ducttape.syntax.GrammarParser.Parser
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class RValueTest extends AbstractTest("rvalue",Grammar.rvalue) {
 
  def successCases = Set(

    // Branch point
    """(branchPointName: a=1)""",
    """(branchPointName: a=1 b=5)""",   
    """(greeting: y="welcome home" z="bugger off")""",
    """(sauce: a1="A1 Sauce" ketchup="Tomato Ketchup" wasabi="wasabi")""",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=\"kumbaya\" )",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=\"kumbaya\")",
    "(flags: a=\"\"\"-avze 'ssh -o \"SomeOption=Value\"\"\"\" b=kumbaya)",      
      
    // Sequential branch point
    """(branchPointName: 1..5)""",   
    """(branchPointName: 1..5.0)""",
    """(branchPointName: 1.0..5.0)""",
    """(branchPointName: 10e1..10e999)""",
    """(branchPointName: 9.9e256..7.7e1024)""",
    """(branchPointName: 1..6..2)""",   
    """(branchPointName: 1..5.0..0.5)""",
    """(branchPointName: 1.0..5.0..2)""",
    """(branchPointName: 10e1..10e999..1)""",
    """(branchPointName: 9.9e256..7.7e1024..5.4e3)""",      
      
    // Branch graft
    "$variableName@taskName[branchPointName:branchName]",
    "$variableName@taskName[branchPointName:*]",
    "$variableName@taskName[a:b,c:d]",
    "$variableName@taskName[a1:b2,c3:*,d4:e5,f6:g7]",
      
    // Task variable reference
    "$A_variable_Name__@foo",
    "$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_@barBar",
    "$abc@def",
    "${A_variable_Name__}@foo",
    "${ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_}@barBar",
    "${abc}@def",
      
    // Variable reference
    "$A_variable_Name__",
    "$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_",
    "$abc",
    "${A_variable_Name__}",
    "${ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_}",
    "${abc}",
    
    // Unquoted literal
    "A_variable_Name__",
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_",
    "/path/to/something/cool",
    "abc",    
    "A-variable_Name__",
    "A_variable_Name__",
    
    // Quoted literal
    """"This is a quoted string"""",
    """'This one uses single quotes '""",
    """' Escape\tsequences\nare\rallowed! '""",
    "\"Unicode sequences should be fine \u21AF too\"",
    "\'Unicode sequences should be fine \u2231 too\'",   
    
    // Triple quoted literal
    "\"\"\"" + "This is a quoted string" + "\"\"\"",
    "\"\"\"" + """This is a quoted string with \r lots of \\u garbage! \b in it!""" + "\"\"\"",    
    
    // Complex nesting
    "(a: a1=(k: 8..12) a4=7)",
    "(a: a1=$g@taskH[i:j])",
    "(a: a1=(b: f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",      
    "(a: a1=(b: c=$d@taskE) a2=5 a3=(k: 8..12) a4=7)",      
    "(a: a1=(b: c=$d@taskE f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",
    "(a: a1=(b: c=(x: x1=$d@taskE x2=farOut x3=\"\"\"Quoted!\"\"\") f=$g@taskH[i:j]) a2=5 a3=(k: 8..12) a4=7)",    

      // Anonymous sequential branch point
      """(1..5)""",   
      """(1..5.0)""",
      """(1.0..5.0)""",
      """(10e1..10e999)""",
      """(9.9e256..7.7e1024)""",
      """(1..6..2)""",   
      """(1..5.0..0.5)""",
      """(1.0..5.0..2)""",
      """(10e1..10e999..1)""",
      """(9.9e256..7.7e1024..5.4e3)""",      
    
    // Anonymous branch point (no branch point name)
    "(foo=bar)",
    "(a=1 b=2)",
    
    // Anonymous branch point with bare rvalues
    "(foo)",
    "(1 2)"
  ) 
  
  def failureCases = Set(
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_ :",
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_     :"
  ) 
  
  def errorCases = Set(
    "$variableName@taskName[",
    "$A-variable_Name__",
    "$",
    "A_variable_Name__:",      
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_:",
    """"This is a badly quoted string\"""",
    """"This one is, too"it seems"""",
    """'Starting with a single and ending with a double"""",
    """"Starting with a double and ending with a single'""",    
    " ",
    "",
    "\"\"\"This is a badly quoted string",
    "\"\"\"This is a badly quoted string\"",
    "\"\"\"This is a badly quoted string\"\"",
    "\"\"\"This is a badly quoted string'",
    "\"\"\"This is a badly quoted string''",
    "\"\"\"This is a badly quoted string'''"
  )
  
  override def exceptionCases = Set(
    // there's no good way of determining a name for these internal anonymous branches
    "((1..10) 7 42 (100..1000..100))"    
  )
}
{'fraction_non_alphanumeric': 0.22312633832976445, 'fraction_numerical': 0.06423982869379015, 'mean_word_length': 2.9546994072819643, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1554511', 'n_tokens_mistral': 4103, 'n_tokens_neox': 3787, 'n_words': 658}