Skip to content

Commit 6ea992c

Browse files
committed
Add tests for theme toggling and UI elements
- Implemented tests for dark/light theme toggle functionality in `test_theme.py`. - Added assertions to verify the correct application of themes. - Created tests for UI elements in `test_ui.py`, ensuring proper creation and existence of components. - Included mock functions to simulate button interactions and validate behavior.
1 parent b29b9f2 commit 6ea992c

15 files changed

+87
-48
lines changed
189 Bytes
Binary file not shown.
9.66 KB
Binary file not shown.
1.12 KB
Binary file not shown.
3.81 KB
Binary file not shown.

src/__pycache__/ui.cpython-313.pyc

6.82 KB
Binary file not shown.

src/optimizations.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ def apply_optimizations(options, text):
1212
if options["remove_extra_spaces"].get():
1313
text = re.sub(r'[ \t]+', ' ', text)
1414
if options["single_line_mode"].get():
15-
text = text.replace("\n", "⏎")
15+
text = text.replace("\n", "⏎") # بدون \n آخر
1616
if options["shorten_keywords"].get():
17-
rep = {"def ": "d ", "return ": "r ", "import ": "i ", "from ": "f ", "as ": "a ", "if ": "if", "class ": "c ", "lambda ": "λ "}
17+
rep = {
18+
"def ": "d ", "return ": "r ", "import ": "i ", "from ": "f ", "as ": "a ",
19+
"if ": "if", "class ": "c ", "lambda ": "λ "
20+
}
1821
for k, v in rep.items():
1922
text = text.replace(k, v)
2023
if options["replace_booleans"].get():
2124
text = text.replace("True", "1").replace("False", "0").replace("None", "~")
2225
if options["use_short_operators"].get():
23-
text = text.replace("==", "≡").replace("!=", "≠").replace(" and ", "∧").replace(" or ", "∨")
26+
text = text.replace("==", "≡").replace("!=", "≠")
27+
text = text.replace(" and ", "∧").replace(" or ", "∨")
28+
text = re.sub(r'\band\b', '∧', text)
29+
text = re.sub(r'\bor\b', '∨', text)
2430
if options["remove_type_hints"].get():
2531
text = re.sub(r':\s*[^=\n\->]+', '', text)
2632
text = re.sub(r'->\s*[^:\n]+', '', text)
@@ -29,6 +35,8 @@ def apply_optimizations(options, text):
2935
text = re.sub(r':\s+', ':', text)
3036
if options["unicode_shortcuts"].get():
3137
text = text.replace(" in ", "∈").replace(" not in ", "∉")
38+
text = re.sub(r'\bin\b', '∈', text)
39+
text = re.sub(r'\bnot\s+in\b', '∉', text)
3240
if options["shorten_print"].get():
3341
text = re.sub(r'print\s*\(', 'p(', text)
34-
return text.strip() + "\n"
42+
return text.rstrip() + "\n" if text.strip() else text # فقط یه \n آخر

src/ui.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def create_ui(app):
7474
app.checkbuttons.append(cb)
7575

7676
# Crush button
77-
ttk.Button(main, text="CRUSH TOKENS →", command=app.optimize).pack(pady=20)
77+
crush_btn = ttk.Button(main, text="CRUSH TOKENS →", command=app.optimize)
78+
crush_btn.pack(pady=20)
79+
app.ui_elements["crush_btn"] = crush_btn
7880

7981
# Output panel
8082
output_frame = tk.LabelFrame(main, text=" Crushed Output (AI-Safe) ", fg=theme["text_bright"], bg=theme["frame_bg"], font=("Segoe UI", 10, "bold"))
191 Bytes
Binary file not shown.
3.99 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)