From 570278be6ea5e3981d20f9ffcfeec27d43cf9770 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 5 Aug 1997 16:52:50 +0000 Subject: Add test for function comparisons --- Lib/test/output/test_opcodes | 1 + Lib/test/test_opcodes.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Lib/test/output/test_opcodes b/Lib/test/output/test_opcodes index 8b78885..4685571 100644 --- a/Lib/test/output/test_opcodes +++ b/Lib/test/output/test_opcodes @@ -3,3 +3,4 @@ test_opcodes XXX Not yet fully implemented 2.1 try inside for loop 2.2 raise class exceptions +2.3 comparing function objects diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py index b1e944b..656e00a 100644 --- a/Lib/test/test_opcodes.py +++ b/Lib/test/test_opcodes.py @@ -57,3 +57,38 @@ except AClass, v: try: raise BClass, a except TypeError: pass + + +print '2.3 comparing function objects' + +f = eval('lambda: None') +g = eval('lambda: None') +if f != g: raise TestFailed + +f = eval('lambda a: a') +g = eval('lambda a: a') +if f != g: raise TestFailed + +f = eval('lambda a=1: a') +g = eval('lambda a=1: a') +if f != g: raise TestFailed + +f = eval('lambda: 0') +g = eval('lambda: 1') +if f == g: raise TestFailed + +f = eval('lambda: None') +g = eval('lambda a: None') +if f == g: raise TestFailed + +f = eval('lambda a: None') +g = eval('lambda b: None') +if f == g: raise TestFailed + +f = eval('lambda a: None') +g = eval('lambda a=None: None') +if f == g: raise TestFailed + +f = eval('lambda a=0: None') +g = eval('lambda a=1: None') +if f == g: raise TestFailed -- cgit v0.12