Ejemplo n.º 1
0
def MatchesSemanticTrigger_RegexTrigger_test():
    ok_(
        cu._MatchesSemanticTrigger('foo.bar', 4,
                                   [cu._PrepareTrigger(r're!\w+\.')]))

    ok_(not cu._MatchesSemanticTrigger('foo . bar', 5,
                                       [cu._PrepareTrigger(r're!\w+\.')]))
Ejemplo n.º 2
0
def MatchesSemanticTrigger_RegexTrigger_test():
  ok_( cu._MatchesSemanticTrigger( 'foo.bar',
                                   4,
                                   [ cu._PrepareTrigger( r're!\w+\.' ) ] ) )

  ok_( not cu._MatchesSemanticTrigger( 'foo . bar',
                                       5,
                                       [ cu._PrepareTrigger( r're!\w+\.' ) ] ) )
Ejemplo n.º 3
0
def MatchesSemanticTrigger_OneTriggerMatches_test():
    ok_(
        cu._MatchesSemanticTrigger('foo::bar', 5, [
            cu._PrepareTrigger('.'),
            cu._PrepareTrigger(';'),
            cu._PrepareTrigger('::')
        ]))
Ejemplo n.º 4
0
def MatchesSemanticTrigger_OneTriggerMatches_test():
    triggers = [
        cu._PrepareTrigger('.'),
        cu._PrepareTrigger(';'),
        cu._PrepareTrigger('::')
    ]

    assert_that(cu._MatchesSemanticTrigger('foo::bar', 5, 8, triggers))
Ejemplo n.º 5
0
def MatchesSemanticTrigger_Basic_test():
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 7, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 6, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 5, ['.'] ) )

  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 4, ['.'] ) )

  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 3, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 2, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 1, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 0, ['.'] ) )
Ejemplo n.º 6
0
def MatchesSemanticTrigger_BadInput_test():
    triggers = [cu._PrepareTrigger('.')]

    ok_(not cu._MatchesSemanticTrigger('foo.bar', 10, 7, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', -1, 7, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 4, -1, triggers))
    ok_(not cu._MatchesSemanticTrigger('', -1, 0, triggers))
    ok_(not cu._MatchesSemanticTrigger('', 0, 0, triggers))
    ok_(not cu._MatchesSemanticTrigger('', 1, 0, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 4, 7, []))
Ejemplo n.º 7
0
def MatchesSemanticTrigger_BadInput_test():
  triggers = [ cu._PrepareTrigger( '.' ) ]

  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 10, 7, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', -1, 7, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, -1, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( '', -1, 0, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( '', 0, 0, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( '', 1, 0, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, 7, [] ) )
Ejemplo n.º 8
0
def MatchesSemanticTrigger_BadInput_test():
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 10, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', -1, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( '', -1, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( '', 0, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( '', 1, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, [] ) )
Ejemplo n.º 9
0
def MatchesSemanticTrigger_LongerTrigger_test():
    triggers = [cu._PrepareTrigger('::')]

    ok_(not cu._MatchesSemanticTrigger('foo::bar', 6, 8, triggers))
    ok_(cu._MatchesSemanticTrigger('foo::bar', 5, 8, triggers))
    ok_(cu._MatchesSemanticTrigger('foo::bar', 4, 8, triggers))
    ok_(cu._MatchesSemanticTrigger('foo::bar', 3, 8, triggers))

    ok_(not cu._MatchesSemanticTrigger('foo::bar', 4, 4, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo::bar', 3, 4, triggers))
Ejemplo n.º 10
0
def MatchesSemanticTrigger_LongerTrigger_test():
  triggers = [ cu._PrepareTrigger( '::' ) ]

  ok_( not cu._MatchesSemanticTrigger( 'foo::bar', 6, 8, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 5, 8, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 4, 8, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 3, 8, triggers ) )

  ok_( not cu._MatchesSemanticTrigger( 'foo::bar', 4, 4, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo::bar', 3, 4, triggers ) )
Ejemplo n.º 11
0
def MatchesSemanticTrigger_LongerTrigger_test():
  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 5, ['::'] ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo::bar', 4, ['::'] ) )
Ejemplo n.º 12
0
def MatchesSemanticTrigger_TriggerIsWrong_test():
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, [':'] ) )
Ejemplo n.º 13
0
def MatchesSemanticTrigger_TriggerIsWrong_test():
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 4, [cu._PrepareTrigger(':')])
        )
Ejemplo n.º 14
0
def MatchesSemanticTrigger_TriggerBetweenWords_test():
  ok_( cu._MatchesSemanticTrigger( 'foo . bar', 5, ['.'] ) )
Ejemplo n.º 15
0
def MatchesSemanticTrigger_TriggerBetweenWords_test():
  triggers = [ cu._PrepareTrigger( '.' ) ]

  ok_( not cu._MatchesSemanticTrigger( 'foo . bar', 6, 9, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo . bar', 5, 9, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo . bar', 4, 9, triggers ) )
Ejemplo n.º 16
0
def MatchesSemanticTrigger_TriggerIsWrong_test():
    triggers = [cu._PrepareTrigger(':')]

    ok_(not cu._MatchesSemanticTrigger('foo.bar', 4, 7, triggers))
Ejemplo n.º 17
0
def MatchesSemanticTrigger_TriggerBetweenWords_test():
    triggers = [cu._PrepareTrigger('.')]

    ok_(not cu._MatchesSemanticTrigger('foo . bar', 6, 9, triggers))
    ok_(cu._MatchesSemanticTrigger('foo . bar', 5, 9, triggers))
    ok_(cu._MatchesSemanticTrigger('foo . bar', 4, 9, triggers))
Ejemplo n.º 18
0
def MatchesSemanticTrigger_TriggerIsWrong_test():
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, [cu._PrepareTrigger( ':' )] ) )
Ejemplo n.º 19
0
def MatchesSemanticTrigger_JustTrigger_test():
    ok_(cu._MatchesSemanticTrigger('.', 1, [cu._PrepareTrigger('.')]))
    ok_(not cu._MatchesSemanticTrigger('.', 0, [cu._PrepareTrigger('.')]))
Ejemplo n.º 20
0
def MatchesSemanticTrigger_RegexTrigger_test():
    triggers = [cu._PrepareTrigger(r're!\w+\.')]

    ok_(cu._MatchesSemanticTrigger('foo.bar', 4, 8, triggers))

    ok_(not cu._MatchesSemanticTrigger('foo . bar', 5, 8, triggers))
Ejemplo n.º 21
0
def MatchesSemanticTrigger_OneTriggerMatches_test():
  triggers = [ cu._PrepareTrigger( '.' ),
               cu._PrepareTrigger( ';' ),
               cu._PrepareTrigger( '::' ) ]

  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 5, 8, triggers ) )
Ejemplo n.º 22
0
def MatchesSemanticTrigger_TriggerIsWrong_test():
  triggers = [ cu._PrepareTrigger( ':' ) ]

  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 4, 7, triggers ) )
Ejemplo n.º 23
0
def MatchesSemanticTrigger_JustTrigger_test():
  triggers = [ cu._PrepareTrigger( '.' ) ]

  assert_that( not cu._MatchesSemanticTrigger( '.', 2, 2, triggers ) )
  assert_that( cu._MatchesSemanticTrigger( '.', 1, 1, triggers ) )
  assert_that( not cu._MatchesSemanticTrigger( '.', 0, 0, triggers ) )
Ejemplo n.º 24
0
def MatchesSemanticTrigger_OneTriggerMatches_test():
  ok_( cu._MatchesSemanticTrigger( 'foo::bar', 5, ['.', ';', '::'] ) )
Ejemplo n.º 25
0
def MatchesSemanticTrigger_TriggerBetweenWords_test():
  ok_( cu._MatchesSemanticTrigger( 'foo . bar', 5, [cu._PrepareTrigger( '.' )] ) )
Ejemplo n.º 26
0
def MatchesSemanticTrigger_JustTrigger_test():
    triggers = [cu._PrepareTrigger('.')]

    ok_(not cu._MatchesSemanticTrigger('.', 2, 2, triggers))
    ok_(cu._MatchesSemanticTrigger('.', 1, 1, triggers))
    ok_(not cu._MatchesSemanticTrigger('.', 0, 0, triggers))
Ejemplo n.º 27
0
def MatchesSemanticTrigger_JustTrigger_test():
  ok_( cu._MatchesSemanticTrigger( '.', 1, [cu._PrepareTrigger( '.' )] ) )
  ok_( not cu._MatchesSemanticTrigger( '.', 0, [cu._PrepareTrigger( '.' )] ) )
Ejemplo n.º 28
0
def MatchesSemanticTrigger_TriggerBetweenWords_test():
    ok_(cu._MatchesSemanticTrigger('foo . bar', 5, [cu._PrepareTrigger('.')]))
Ejemplo n.º 29
0
def MatchesSemanticTrigger_JustTrigger_test():
  ok_( cu._MatchesSemanticTrigger( '.', 1, ['.'] ) )
  ok_( not cu._MatchesSemanticTrigger( '.', 0, ['.'] ) )
Ejemplo n.º 30
0
def MatchesSemanticTrigger_RegexTrigger_test():
  triggers = [ cu._PrepareTrigger( r're!\w+\.' ) ]

  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 4, 8, triggers ) )

  ok_( not cu._MatchesSemanticTrigger( 'foo . bar', 5, 8, triggers ) )
Ejemplo n.º 31
0
def MatchesSemanticTrigger_JustTrigger_test():
  triggers = [ cu._PrepareTrigger( '.' ) ]

  ok_( not cu._MatchesSemanticTrigger( '.', 2, 2, triggers ) )
  ok_( cu._MatchesSemanticTrigger( '.', 1, 1, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( '.', 0, 0, triggers ) )
Ejemplo n.º 32
0
def MatchesSemanticTrigger_Basic_test():
    triggers = [cu._PrepareTrigger('.')]

    ok_(not cu._MatchesSemanticTrigger('foo.bar', 7, 7, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 6, 7, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 5, 7, triggers))
    ok_(cu._MatchesSemanticTrigger('foo.bar', 4, 7, triggers))
    ok_(cu._MatchesSemanticTrigger('foo.bar', 3, 7, triggers))
    ok_(cu._MatchesSemanticTrigger('foo.bar', 2, 7, triggers))
    ok_(cu._MatchesSemanticTrigger('foo.bar', 1, 7, triggers))
    ok_(cu._MatchesSemanticTrigger('foo.bar', 0, 7, triggers))

    ok_(not cu._MatchesSemanticTrigger('foo.bar', 3, 3, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 2, 3, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 1, 3, triggers))
    ok_(not cu._MatchesSemanticTrigger('foo.bar', 0, 3, triggers))
Ejemplo n.º 33
0
def MatchesSemanticTrigger_Basic_test():
  triggers = [ cu._PrepareTrigger( '.' ) ]

  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 7, 7, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 6, 7, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 5, 7, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 4, 7, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 3, 7, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 2, 7, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 1, 7, triggers ) )
  ok_( cu._MatchesSemanticTrigger( 'foo.bar', 0, 7, triggers ) )

  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 3, 3, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 2, 3, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 1, 3, triggers ) )
  ok_( not cu._MatchesSemanticTrigger( 'foo.bar', 0, 3, triggers ) )