Kaynağa Gözat

Change test file to support different parsers

tags/v1.0^2
Benjamin Attal 10 yıl önce
ebeveyn
işleme
c859416d2d
1 değiştirilmiş dosya ile 35 ekleme ve 13 silme
  1. +35
    -13
      test/parser_test.py

+ 35
- 13
test/parser_test.py Dosyayı Görüntüle

@@ -1,18 +1,40 @@
import socket
import socket, sys

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5002))
file_name = 'resources/<name>.c'
server_socket_number = 5001

with open("resources/Matrix.java", "r") as java_file:
source = java_file.read() + "\nEOS_BITSHIFT"
client_socket.send("%d\n%s" % (len(source), source));
if __name__ == '__main__':
if len(sys.argv) == 1:
print "Please input a parser to test."

data = ''
while True:
data = client_socket.recv(10000)
elif len(sys.argv) > 2:
print "Too many arguments."

if data != '':
client_socket.close()
break;
else:
if sys.argv[1] == 'c':
pass

print data;
elif sys.argv[1] == 'java':
file_name = "resources/Matrix.java"
server_socket_number = 5002

elif sys.argv[1] == 'ruby':
file_name = "resources/<name>.rb"
server_socket_number = 5003

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", server_socket_number))

with open(file_name, "r") as source_file:
source = source_file.read()
client_socket.send("%d\n%s" % (len(source), source));

data = ''
while True:
data = client_socket.recv(10000)

if data != '':
client_socket.close()
break;

print data;

Yükleniyor…
İptal
Kaydet