Skip to content
This repository was archived by the owner on Nov 29, 2024. It is now read-only.

Commit 276032e

Browse files
committed
add test suite
1 parent d10b72b commit 276032e

15 files changed

+152
-0
lines changed

TEST_COVERAGE.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# VisionScript Language Test Coverage
2+
3+
The VisionScript Language is the language used to write VisionScript programs. This document contains a list of all built-in VisionScript functions, and the state of their test coverage.
4+
5+
This document pertains only to the VisionScript Language and runtime, not Notebooks or Cloud.
6+
7+
## Functions
8+
9+
- [ ] `Blur[]`
10+
- [ ] `Break[]`
11+
- [ ] `Breakpoint[]`
12+
- [ ] `Caption[]`
13+
- [X] `Classify[]`
14+
- [ ] `Compare[]`
15+
- [ ] `ComparePose[]`
16+
- [ ] `Count[]`
17+
- [ ] `CountInRegion[]`
18+
- [ ] `Cutout[]`
19+
- [ ] `Describe[]`
20+
- [X] `Detect[]`
21+
- [ ] `DetectPose[]`
22+
- [ ] `Exit[]`
23+
- [ ] `FilterByClass[]`
24+
- [ ] `Find[]`
25+
- [ ] `First[]`
26+
- [ ] `GetDistinctScenes[]`
27+
- [ ] `GetEdges[]`
28+
- [ ] `GetFPS[]`
29+
- [ ] `GetText[]`
30+
- [ ] `Greyscale[]`
31+
- [ ] `If[]`
32+
- [ ] `Import[]`
33+
- [X] `In[]` (folder of images)
34+
- [ ] `In[]` (video file)
35+
- [ ] `Input[]`
36+
- [ ] `Last[]`
37+
- [X] `Load[]`
38+
- [ ] `Make[]`
39+
- [ ] `Not[]`
40+
- [ ] `Paste[]`
41+
- [ ] `PasteRandom[]`
42+
- [ ] `Profile[]`
43+
- [ ] `Random[]`
44+
- [ ] `Read[]`
45+
- [ ] `ReadQR[]`
46+
- [ ] `Replace[]`
47+
- [ ] `Reset[]`
48+
- [ ] `Resize[]`
49+
- [ ] `Rotate[]`
50+
- [ ] `Save[]`
51+
- [X] `Say[]`
52+
- [ ] `Search[]`
53+
- [ ] `Segment[]`
54+
- [ ] `Select[]`
55+
- [ ] `SetBrightness[]`
56+
- [ ] `SetConfidence[]`
57+
- [ ] `Show[]`
58+
- [ ] `ShowText[]`
59+
- [X] `Similarity[]`
60+
- [ ] `Size[]`
61+
- [ ] `Use[]`
62+
- [ ] `UseCamera[]`
63+
- [ ] `Web[]`
Binary file not shown.

tests/images/bus.jpg

476 KB
Loading

tests/images/cans.png

873 KB
Loading

tests/test_visionscript.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import visionscript as lang
2+
import warnings
3+
import os
4+
import pytest
5+
6+
from visionscript import error_handling
7+
8+
TEST_DIR = os.path.join(os.path.dirname(__file__), "vics/")
9+
VALID_OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "valid_output/")
10+
RAISES_EXCEPTIONS_TEST_DIR = os.path.join(os.path.dirname(__file__), "vics/raises_exceptions/")
11+
12+
@pytest.mark.skip
13+
def test_visionscript_program(file):
14+
session = lang.VisionScript()
15+
16+
with open(TEST_DIR + file, "r") as f:
17+
print("Testing " + file)
18+
file_path = os.path.join(TEST_DIR, file)
19+
session.parse_tree(lang.parser.parse(f.read() + "\n"))
20+
return session.state["output"]["text"]
21+
22+
def test_path_not_exists():
23+
file = "raises_exceptions/path_not_exists.vic"
24+
25+
with pytest.raises(error_handling.PathNotExists):
26+
test_visionscript_program(file)
27+
28+
def test_classify():
29+
file = "classify_image.vic"
30+
31+
assert test_visionscript_program(file) == "banana"
32+
33+
def test_find_in_images():
34+
file = "find_in_images.vic"
35+
36+
assert test_visionscript_program(file) == open(os.path.join(VALID_OUTPUT_DIR, "find_in_images.vic.txt"), "r").read()
37+
38+
def test_load_detect_save():
39+
file = "load_detect_save.vic"
40+
41+
assert test_visionscript_program(file) == "Saved to ./bus1.jpg"
42+
43+
def test_similarity():
44+
file = "similarity.vic"
45+
46+
assert test_visionscript_program(file) == [0]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
banana
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Object found: person
2+
Confidence: 86.90%
3+
xyxy Coordinates: 48, 399, 244, 902
4+
5+
Object found: person
6+
Confidence: 85.36%
7+
xyxy Coordinates: 670, 380, 809, 875
8+
9+
Object found: person
10+
Confidence: 81.93%
11+
xyxy Coordinates: 221, 405, 344, 857
12+
13+
Object found: person
14+
Confidence: 30.13%
15+
xyxy Coordinates: 0, 551, 67, 873
16+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Saved to ./bus1.jpg

tests/vics/classify_image.vic

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Load["./tests/images/bus.jpg"]
2+
Classify["apple", "banana"]
3+
# Read[]

tests/vics/find_in_images.vic

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
In["./images"]
2+
Load[]
3+
Detect["person"]
4+
Say[]
5+
EndIn

0 commit comments

Comments
 (0)