Beispiel #1
0
def test_tokenize():
    result = tokenize(tokenizer, "public void main()")
    estimated_result = ['public', 'void', 'main', '(', ')']
    assert check_torknized_str(result, estimated_result)
    estimated_result = ['String', 'str', '=', r'"\""']
    result = tokenize(tokenizer, r'String str="\""')
    assert check_torknized_str(result, estimated_result)
Beispiel #2
0
def test_tokenize():
    result = tokenize(tokenizer, "public void main()")
    estimated_result = ['public', 'void', 'main', '(', ')']
    assert check_torknized_str(result, estimated_result)
    estimated_result = ['String', 'str', '=', r'"\""']
    result = tokenize(tokenizer, r'String str="\""')
    assert check_torknized_str(result, estimated_result)
Beispiel #3
0
def test_create_two_shingles():
    seq = tokenize(tokenizer, "public void main()")[1:]
    result = get_shingles_str(create_two_shingles(seq))
    estimated_result = {('public', 'void'), ('void', 'main'), ('main', '('), ('(', ')')}
    assert result == estimated_result
    seq = tokenize(tokenizer, "public int main()")[1:]
    result = get_shingles_str(create_two_shingles(seq))
    estimated_result = {('public', 'int'), ('int', 'main'), ('main', '('), ('(', ')')}
    assert result == estimated_result
Beispiel #4
0
def test_create_two_shingles():
    seq = tokenize(tokenizer, "public void main()")[1:]
    result = get_shingles_str(create_two_shingles(seq))
    estimated_result = {('public', 'void'), ('void', 'main'), ('main', '('),
                        ('(', ')')}
    assert result == estimated_result
    seq = tokenize(tokenizer, "public int main()")[1:]
    result = get_shingles_str(create_two_shingles(seq))
    estimated_result = {('public', 'int'), ('int', 'main'), ('main', '('),
                        ('(', ')')}
    assert result == estimated_result
Beispiel #5
0
def test_tokenize():
    result = tokenize(tokenizer, "public void main()")
    result = tokenize(tokenizer, r'String str="\""')
    assert False == result
Beispiel #6
0
def test_create_two_shingles():
    seq = tokenize(tokenizer, "public void main()")[1:]
    result = create_two_shingles(seq)
    seq = tokenize(tokenizer, "public int main()")[1:]
    result = create_two_shingles(seq)
    assert False == result