Skip to content

Commit ef0cf5c

Browse files
committed
Indentation bug in executable comments fixed. Yet to be made more efficient. Docs not yet done.
1 parent ef99db7 commit ef0cf5c

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

transcrypt/development/automated_tests/transcrypt/autotest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import div_pulls
2424
import docstrings
2525
import exceptions
26+
import executable_comments
2627
import extended_slices
2728
import fstrings
2829
import general_functions
@@ -79,6 +80,7 @@
7980
autoTester.run (div_pulls, 'div_pulls')
8081
autoTester.run (docstrings, 'docstrings')
8182
autoTester.run (exceptions, 'exceptions')
83+
autoTester.run (executable_comments, 'executable_comments')
8284
autoTester.run (extended_slices, 'extended_slices')
8385
autoTester.run (fstrings, 'fstrings')
8486
autoTester.run (general_functions, 'general_functions')
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from org.transcrypt.stubs.browser import __pragma__
2+
3+
def run (autoTester):
4+
5+
# __pragma__ ('ecom') # ===================================================================
6+
7+
# --- Executed only by Transcrypt ---
8+
'''?
9+
for i in range (10):
10+
autoTester.check (i)
11+
?'''
12+
13+
# --- Executed only by CPython ---
14+
# __pragma__ ('skip')
15+
for i in range (10):
16+
autoTester.check (i)
17+
# __pragma__ ('noskip')
18+
19+
# --- Executed only by Transcrypt ---
20+
#?autoTester.check (100)
21+
22+
# --- Executed only by CPython ---
23+
autoTester.check (100) #__: skip
24+
25+
#__pragma__ ('noecom') # ===================================================================
26+
27+
28+
# --- Executed by none ---
29+
'''?
30+
for i in range (10, 20):
31+
autoTester.check (i)
32+
?'''
33+
34+
# --- Executed by none ---
35+
#?autoTester.check (200)
36+
37+
__pragma__ ('ecom') # ===================================================================
38+
39+
40+
# --- Executed only by Transcrypt ---
41+
'''?
42+
for i in range (20, 30):
43+
autoTester.check (i)
44+
?'''
45+
46+
# --- Executed only by CPython ---
47+
# __pragma__ ('skip')
48+
for i in range (20, 30):
49+
autoTester.check (i)
50+
# __pragma__ ('noskip')
51+
52+
# --- Executed only by Transcrypt ---
53+
#?autoTester.check (300)
54+
55+
# --- Executed only by CPython ---
56+
autoTester.check (300) #__: skip
57+
58+
__pragma__ ('noecom') # ===================================================================
59+
60+
# --- Executed by none ---
61+
'''?
62+
for i in range (30, 40):
63+
autoTester.check (i)
64+
?'''
65+
66+
# --- Executed by none ---
67+
#?autoTester.check (400)

transcrypt/development/automated_tests/transcrypt/weak_comments/__init__.py

Whitespace-only changes.

transcrypt/modules/org/transcrypt/compiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,9 @@ def pragmasFromComments (sourceCode):
454454
elif sourceLine == noecom:
455455
allowExecutableComments = False
456456
elif allowExecutableComments:
457-
if not sourceLine [:4] in {"'''?", "?'''", '"""?', '?"""'}:
458-
uncommentedSourceLines.append (sourceLine [2:] if sourceLine.startswith ('#?') else sourceLine)
457+
lStrippedSourceLine = sourceLine.lstrip ()
458+
if not lStrippedSourceLine [:4] in {"'''?", "?'''", '"""?', '?"""'}:
459+
uncommentedSourceLines.append (sourceLine.replace ('#?', '', 1) if lStrippedSourceLine.startswith ('#?') else sourceLine)
459460
else:
460461
uncommentedSourceLines.append (sourceLine)
461462

0 commit comments

Comments
 (0)