# Path: redhawk/test/sample_last.py



import redhawk.common.selector as S
import redhawk.common.xpath as X
from .sample_last import module_tree

def TestPositionSelector():
  l0 = list(Query('**/DefineFunction/[0]'))
  l1 = list(Query('**/DefineFunction/[1]'))
  l2 = list(Query('**/DefineFunction/[2]'))

  assert(len(l0) == len(l1) == 1)
  assert(l0[0].GetName() == 'FunctionArguments')
  assert(l1[0].GetName() == 'IfElse')
  assert(l2 == [])

  l0 = list(Query('**/DefineFunction/FunctionArguments/[0, 0]'))
  assert(len(l0) == 1)
  assert(l0[0].GetName() == 'DefineVariable')

  # We should be getting a return which is a child of the else clause
  r = list(Query('**/IfElse/Return[2]'))
  q = list(Query('**/IfElse/Return[2, 0]'))
  assert(len(r) == 1)
  assert(r == q)
  assert(r[0].GetChildren()[0].GetName() == 'Expression')
  return

def TestDot():
  """ Test Dot """
  assert(list(Query("./././././."))[0] == module_tree)
  return

def TestDotDot():
  """ Test Dot Dot """

# Path: redhawk/test/sample_last.py



# Path: redhawk/test/test_common_xpath_functionality.py
import redhawk.common.selector as S
import redhawk.common.xpath as X
from .sample_last import module_tree


def TestPositionSelector():
  l0 = list(Query('**/DefineFunction/[0]'))
  l1 = list(Query('**/DefineFunction/[1]'))
  l2 = list(Query('**/DefineFunction/[2]'))

  assert(len(l0) == len(l1) == 1)
  assert(l0[0].GetName() == 'FunctionArguments')
  assert(l1[0].GetName() == 'IfElse')
  assert(l2 == [])

  l0 = list(Query('**/DefineFunction/FunctionArguments/[0, 0]'))
  assert(len(l0) == 1)
  assert(l0[0].GetName() == 'DefineVariable')

  # We should be getting a return which is a child of the else clause
  r = list(Query('**/IfElse/Return[2]'))
  q = list(Query('**/IfElse/Return[2, 0]'))
  assert(len(r) == 1)
  assert(r == q)
  assert(r[0].GetChildren()[0].GetName() == 'Expression')
  return

def TestDot():
  """ Test Dot """
  assert(list(Query("./././././."))[0] == module_tree)
  return

def TestDotDot():
  """ Test Dot Dot """

  assert(list(Query("*/.."))[0] == module_tree)