Skip to content

Commit

Permalink
Changed 'self.analyzer' calls to 'self.analyze'.
Browse files Browse the repository at this point in the history
  • Loading branch information
rturrado committed Nov 28, 2023
1 parent 9ac5449 commit df6d421
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/v1x/python/test_analysis_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def analyze(self, s: str):
return self.analyzer.analyze_string(s)

def test_to_json_with_analyzer_errors(self):
result = self.analyzer("version 1.0; qubits 2; wait 1")
result = self.analyze("version 1.0; qubits 2; wait 1")
json_result = result.to_json()
expected_json_result = '''{"errors":["Error at res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:1..7: failed to resolve overload for wait with argument pack (int)"]}'''
self.assertEqual(json_result, expected_json_result)

def test_to_json_with_analyzer_ast(self):
result = self.analyzer("version 1.0; qubits 2; wait 1")
result = self.analyze("version 1.0; qubits 2; wait 1")
json_result = result.to_json()
expected_json_result = '''{"Program":{"api_version":"1.0","version":{"Version":{"items":"1.0","source_location":"res/v1x/parsing/grammar/map/input.cq:1:9..12"}},"num_qubits":"10","error_model":"-","subcircuits":"[]","mappings":[{"Mapping":{"name":"three","value":{"ConstInt":{"value":"3","source_location":"res/v1x/parsing/grammar/map/input.cq:4:5..6"}},"annotations":[{"AnnotationData":{"interface":"first","operation":"annot","operands":"[]","source_location":"res/v1x/parsing/grammar/map/input.cq:4:15..26"}}],"source_location":"res/v1x/parsing/grammar/map/input.cq:4:1..26"}},{"Mapping":{"name":"also_three","value":{"ConstInt":{"value":"3","source_location":"res/v1x/parsing/grammar/map/input.cq:5:18..23"}},"annotations":[{"AnnotationData":{"interface":"second","operation":"annot","operands":"[]","source_location":"res/v1x/parsing/grammar/map/input.cq:5:25..37"}},{"AnnotationData":{"interface":"third","operation":"annot","operands":"[]","source_location":"res/v1x/parsing/grammar/map/input.cq:5:39..50"}}],"source_location":"res/v1x/parsing/grammar/map/input.cq:5:1..50"}}],"variables":"[]","source_location":"res/v1x/parsing/grammar/map/input.cq:1:1..6:1"}}'''
self.assertEqual(json_result, expected_json_result)
Expand Down
4 changes: 2 additions & 2 deletions test/v1x/python/test_parse_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def analyze(self, s: str):
return self.analyzer.analyze_string(s)

def test_to_json_with_parser_errors(self):
result = self.analyzer("version 1.0; qubits 10; display @test.test([, 1, 2, 3+, 4, 5) @test.test([, 1, 2, 3+, 4, 5)")
result = self.analyze("version 1.0; qubits 10; display @test.test([, 1, 2, 3+, 4, 5) @test.test([, 1, 2, 3+, 4, 5)")
json_result = result.to_json()
expected_json_result = '''{"errors":["res/v1x/parsing/grammar/expression_recovery/input.cq:4:21: syntax error, unexpected ','","res/v1x/parsing/grammar/expression_recovery/input.cq:4:31: syntax error, unexpected ','","res/v1x/parsing/grammar/expression_recovery/input.cq:4:37: syntax error, unexpected ')', expecting ']'","res/v1x/parsing/grammar/expression_recovery/input.cq:4:61: syntax error, unexpected ','""res/v1x/parsing/grammar/expression_recovery/input.cq:4:67: syntax error, unexpected ')', expecting ',' or ']'","Failed to parse res/v1x/parsing/grammar/expression_recovery/input.cq"]}'''
self.assertEqual(json_result, expected_json_result)

def test_to_json_with_parser_ast(self):
result = self.analyzer("version 1.0; qubits 2; wait 1")
result = self.analyze("version 1.0; qubits 2; wait 1")
json_result = result.to_json()
expected_json_result = '''{"Program":{"version":{"Version":{"items":"1.0","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:1:9..12"}},"num_qubits":{"IntegerLiteral":{"value":"2","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:2:8..9"}},"statements":{"StatementList":{"items":[{"Bundle":{"items":[{"Instruction":{"name":{"Identifier":{"name":"wait","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:1..5"}},"condition":"-","operands":{"ExpressionList":{"items":[{"IntegerLiteral":{"value":"1","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:6..7"}}],"source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:6..7"}},"annotations":"[]","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:1..7"}}],"annotations":"[]","source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:4:1..7"}}],"source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:2:1..5:7"}},"source_location":"res/v1x/parsing/misc/wait_not_ok_1/input.cq:1:1..5:1"}}'''
self.assertEqual(json_result, expected_json_result)
Expand Down
4 changes: 2 additions & 2 deletions test/v3x/python/test_analysis_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def analyze(self, s: str):
return self.analyzer.analyze_string(s)

def test_to_json_with_analyzer_errors(self):
result = self.analyzer("version 3; bit[0] b")
result = self.analyze("version 3; bit[0] b")
json_result = result.to_json()
expected_json_result = '''{"errors":["Error at <unknown>:3:8..9: declaring bit array of size <= 0"]}'''
self.assertEqual(json_result, expected_json_result)

def test_to_json_with_analyzer_ast(self):
result = self.analyzer("version 3; bit[17] b")
result = self.analyze("version 3; bit[17] b")
json_result = result.to_json()
expected_json_result = '''{"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"statements":"[]","variables":[{"Variable":{"name":"b","typ":{"BitArray":{"size":"17"}},"annotations":"[]"}}]}}'''
self.assertEqual(json_result, expected_json_result)
Expand Down
4 changes: 2 additions & 2 deletions test/v3x/python/test_parse_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def analyze(self, s: str):
return self.analyzer.analyze_string(s)

def test_to_json_with_parser_errors(self):
result = self.analyzer("version 3; bit[3.14]")
result = self.analyze("version 3; bit[3.14]")
json_result = result.to_json()
expected_json_result = '''{"errors":["<unknown>:3:5: mismatched input '3.14' expecting INTEGER_LITERAL"]}'''
self.assertEqual(json_result, expected_json_result)

def test_to_json_with_parser_ast(self):
result = self.analyzer("version 1.0; bit[0] b")
result = self.analyze("version 1.0; bit[0] b")
json_result = result.to_json()
expected_json_result = '''{"Program":{"version":{"Version":{"items":"3","source_location":"<unknown>:1:9..10"}},"statements":{"StatementList":{"items":[{"Variables":{"names":[{"Identifier":{"name":"b"}}],"typ":{"Identifier":{"name":"bit"}},"size":{"IntegerLiteral":{"value":"0"}},"annotations":"[]","source_location":"<unknown>:3:8..9"}}]}}}}'''
self.assertEqual(json_result, expected_json_result)
Expand Down

0 comments on commit df6d421

Please sign in to comment.