summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_grammar.py16
-rw-r--r--Lib/test/test_select.py25
-rw-r--r--Lib/test/testall.out1
3 files changed, 42 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 4c9e7b0086..742477f9b4 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -62,6 +62,22 @@ x = 3.e14
x = .3e14
x = 3.1e4
+print '1.1.3 String literals'
+
+def assert(s):
+ if not s: raise TestFailed, 'see traceback'
+
+x = ''; y = ""; assert(len(x) == 0 and x == y)
+x = '\''; y = "'"; assert(len(x) == 1 and x == y and ord(x) == 39)
+x = '"'; y = "\""; assert(len(x) == 1 and x == y and ord(x) == 34)
+x = "doesn't \"shrink\" does it"
+y = 'doesn\'t "shrink" does it'
+assert(len(x) == 24 and x == y)
+x = "doesn \"shrink\" doesn't it"
+y = 'doesn "shrink" doesn\'t it'
+assert(len(x) == 25 and x == y)
+
+
print '1.2 Grammar'
print 'single_input' # NEWLINE | simple_stmt | compound_stmt NEWLINE
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
new file mode 100644
index 0000000000..89088ef628
--- /dev/null
+++ b/Lib/test/test_select.py
@@ -0,0 +1,25 @@
+# Testing select module
+
+from test_support import *
+
+def test():
+ import select
+ import os
+ cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do date; sleep 3; done'
+ p = os.popen(cmd, 'r')
+ for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
+ print 'timeout =', tout
+ rfd, wfd, xfd = select.select([p], [], [], tout)
+ print rfd, wfd, xfd
+ if (rfd, wfd, xfd) == ([], [], []):
+ continue
+ if (rfd, wfd, xfd) == ([p], [], []):
+ line = p.readline()
+ print `line`
+ if not line:
+ print 'EOF'
+ break
+ continue
+ print 'Heh?'
+
+test()
diff --git a/Lib/test/testall.out b/Lib/test/testall.out
index 1dbb42a1ec..90c1202de4 100644
--- a/Lib/test/testall.out
+++ b/Lib/test/testall.out
@@ -6,6 +6,7 @@ test_grammar
1.1.2.1 Plain integers
1.1.2.2 Long integers
1.1.2.3 Floating point
+1.1.3 String literals
1.2 Grammar
single_input
file_input