summary refs log tree commit diff stats
path: root/test/tc_ui.py
blob: affec9079df22e90062c7efd9f3981386e84e155 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__': from __init__ import init; init()

import unittest
import curses

from ranger.gui import ui

from test import Fake, OK, raise_ok

ui.curses = Fake()

class Test(unittest.TestCase):
	def setUp(self):

		self.fm = Fake()
		self.ui = ui.UI(env=Fake(), fm=self.fm, commandlist=Fake())

		def fakesetup():
			self.ui.widget = Fake()
			self.ui.add_child(self.ui.widget)
		self.ui.setup = fakesetup

		self.ui.initialize()

	def tearDown(self):
		self.ui.destroy()
	
	def test_passing(self):
		# Test whether certain method calls are passed to widgets
		widget = self.ui.widget

		widget.draw = raise_ok
		self.assertRaises(OK, self.ui.draw)
		widget.__clear__()

		widget.finalize = raise_ok
		self.assertRaises(OK, self.ui.finalize)
		widget.__clear__()

		widget.press = raise_ok
		random_key = 123
		self.assertRaises(OK, self.ui.handle_key, random_key)
		widget.__clear__()

		widget.destroy = raise_ok
		self.assertRaises(OK, self.ui.destroy)
		widget.__clear__()

if __name__ == '__main__':
	unittest.main()
a> 446 447 448 449
<HTML>
<HEAD>
<TITLE>Simply Scheme contents</TITLE>
<link rel="shortcut icon" href="http://www.cs.berkeley.edu/~bh/simply.png" type="image/png">
</HEAD>
<BODY>
<H1><CITE>Simply Scheme:<BR>Introducing Computer Science</H1>

<TABLE><TR><TD>
<P><IMG SRC="simply.jpg" ALT="cover photo">
<TD valign="center">
<CITE><A HREF="http://www.cs.berkeley.edu/~bh/">Brian
Harvey</A><BR><A HREF="http://www.cnmat.berkeley.edu/~matt">Matthew
Wright</A><BR>University of California, Berkeley</CITE>
<BR><BR><A HREF="http://www-mitpress.mit.edu/book-home.tcl?isbn=0262082810">MIT
Press web page for <CITE>Simply Scheme</CITE></A>
</TABLE>

<P><TABLE><TR><TD><A HREF="ss/foreword.html"><H3>Foreword</H3></A>
<TD>by Hal Abelson</TABLE>

<H3><A HREF="https://people.eecs.berkeley.edu/~bh/ss/preface">Preface</A></H3>
<UL>
<LI>One Big Idea: Symbolic Programming
<LI>Lisp and Radical Computer Science
<LI>Who Should Read This Book
<LI>How to Read This Book
</UL>

<H3><A HREF="ss/instructor.html">To the Instructor</A></H3>
<UL>
<LI>Lists and Sentences
<LI>Sentences and Words
<LI>Overloading in the Text Abstraction
<LI>Higher-Order Procedures, Lambda, and Recursion
<LI>Mutators and Environments
</UL>

<H3><A HREF="ss/ack.html">Acknowledgments</A></H3>

<P><EM>(Note: The links on the Part headings below point to the
introductions to the major parts of the book, each introducing one
"big idea."  Each introduction is about a page of text.)</EM>

<A HREF="part1.html"><H2>Part I. Introduction: Functions</H2></A>

<H3>1. Showing Off Scheme</H3>
<UL>
<LI>Talking to Scheme
<LI>Recovering from Typing Errors
<LI>Exiting Scheme
<LI>More Examples
<LI>Example: Acronyms
<LI>Example: Pig Latin
<LI>Example: Ice Cream Choices
<LI>Example: Combinations from a Set
<LI>Example: Factorial
<LI>Play with the Procedures
</UL>

<H3>2. Functions</H3>
<UL>
<LI>Arithmetic
<LI>Words
<LI>Domain and Range
<LI>More Types: Sentences and Booleans
<LI>Our Favorite Type: Functions
<LI>Play with It
<LI>Thinking about What You've Done
</UL>

<A HREF="part2.html"><H2>Part II. Composition of Functions</H2></A>

<H3>3. Expressions</H3>
<UL>
<LI>Little People
<LI>Result Replacement
<LI>Plumbing Diagrams
<LI>Pitfalls
</UL>

<H3>4. Defining Your Own Procedures</H3>
<UL>
<LI>How to Define a Procedure
<LI>Special Forms
<LI>Functions and Procedures
<LI>Argument Names versus Argument Values
<LI>Procedure as Generalization
<LI>Composability
<LI>The Substitution Model
<LI>Pitfalls
</UL>

<H3>5. Words and Sentences</H3>
<UL>
<LI>Selectors
<LI>Constructors
<LI>First-Class Words and Sentences
<LI>Pitfalls
</UL>

<H3>6. True and False</H3>
<UL>
<LI>Predicates
<LI>Using Predicates
<LI><CODE>If</CODE> Is a Special Form
<LI>So Are <CODE>And</CODE> and <CODE>Or</CODE>
<LI>Everything That Isn't False Is True
<LI>Decisions, Decisions, Decisions
<LI><CODE>If</CODE> Is Composable
<LI>Pitfalls
</UL>

<H3>7. Variables</H3>
<UL>
<LI>How Little People Do Variables
<LI>Global and Local Variables
<LI>The Truth about Substitution
<LI><CODE>Let</CODE>
<LI>Pitfalls
</UL>

<A HREF="part3.html"><H2>Part III. Functions as Data</H2></A>

<H3>8. Higher-Order Functions</H3>
<UL>
<LI><CODE>Every</CODE>
<LI>A Pause for Reflection
<LI><CODE>Keep</CODE>
<LI><CODE>Accumulate</CODE>
<LI>Combining Higher-Order Functions
<LI>Choosing the Right Tool
<LI>First-Class Functions and First-Class Sentences
<LI><CODE>Repeated</CODE>
<LI>Pitfalls
</UL>

<H3>9. Lambda</H3>
<UL>
<LI>Procedures That Return Procedures
<LI>The Truth about <CODE>Define</CODE>
<LI>The Truth about <CODE>Let</CODE>
<LI>Name Conflicts
<LI>Named and Unnamed Functions
<LI>Pitfalls
</UL>

<H3>Project: Scoring Bridge Hands</H3>

<H3>10. Example: Tic-Tac-Toe</H3>
<UL>
<LI>A Warning
<LI>Technical Terms in Tic-Tac-Toe
<LI>Thinking about the Program Structure
<LI>The First Step: Triples
<LI>Finding the Triples
<LI>Using <CODE>Every</CODE> with Two-Argument Procedures
<LI>Can the Computer Win on This Move?
<LI>If So, in Which Square?
<LI>Second Verse, Same as the First
<LI>Now the Strategy Gets Complicated
<LI>Finding the Pivots
<LI>Taking the Offensive
<LI>Leftovers
<LI>Complete Program Listing
</UL>

<A HREF="https://people.eecs.berkeley.edu/~bh/part4.html"><H2>Part IV. Recursion</H2></A>

<H3>11. Introduction to Recursion</H3>
<UL>
<LI>A Separate Procedure for Each Length
<LI>Use What You Have to Get What You Need
<LI>Notice That They're All the Same
<LI>Notice That They're Almost All the Same
<LI>Base Cases and Recursive Calls
<LI>Pig Latin
<LI>Problems for You to Try
<LI>Our Solutions
<LI>Pitfalls
</UL>

<H3>12. The Leap of Faith</H3>
<UL>
<LI>From the Combining Method to the Leap of Faith
<LI>Example: <CODE>Reverse</CODE>
<LI>The Leap of Faith
<LI>The Base Case
<LI>Example: <CODE>Factorial</CODE>
<LI>Likely Guesses for Smaller Subproblems
<LI>Example: <CODE>Downup</CODE>
<LI>Example: <CODE>Evens</CODE>
<LI>Simplifying Base Cases
<LI>Pitfalls
</UL>

<H3>13. How Recursion Works</H3>
<UL>
<LI>Little People and Recursion
<LI>Tracing
<LI>Pitfalls
</UL>

<H3>14. Common Patterns in Recursive Procedures</H3>
<UL>
<LI>The <CODE>Every</CODE> Pattern
<LI>The <CODE>Keep</CODE> Pattern
<LI>The <CODE>Accumulate</CODE> Pattern
<LI>Combining Patterns
<LI>Helper Procedures
<LI>How to Use Recursive Patterns
<LI>Problems That Don't Follow Patterns
<LI>Pitfalls
</UL>

<H3>Project: Spelling Names of Huge Numbers</H3>

<H3>15. Advanced Recursion</H3>
<UL>
<LI>Example: <CODE>Sort</CODE>
<LI>Example: <CODE>From-Binary</CODE>
<LI>Example: <CODE>Mergesort</CODE>
<LI>Example: <CODE>Subsets</CODE>
<LI>Pitfalls
</UL>

<H3>Project: Scoring Poker Hands</H3>
<UL>
<LI>Extra Work for Hotshots
</UL>

<H3>16. Example: Pattern Matcher</H3>
<UL>
<LI>Problem Description
<LI>Implementation: When Are Two Sentences Equal?
<LI>When Are Two Sentences Nearly Equal?
<LI>Matching with Alternatives
<LI>Backtracking
<LI>Matching Several Words
<LI>Combining the Placeholders
<LI>Naming the Matched Text
<LI>The Final Version
<LI>Abstract Data Types
<LI>Backtracking and <CODE>Known-Values</CODE>
<LI>How We Wrote It
<LI>Complete Program Listing
</UL>

<A HREF="part5.html"><H2>Part V. Abstraction</H2></A>

<H3>17. Lists</H3>
<UL>
<LI>Selectors and Constructors
<LI>Programming with Lists
<LI>The Truth about Sentences
<LI>Higher-Order Functions
<LI>Other Primitives for Lists
<LI>Association Lists
<LI>Functions That Take Variable Numbers of Arguments
<LI>Recursion on Arbitrary Structured Lists
<LI>Pitfalls
</UL>

<H3>18. Trees</H3>
<UL>
<LI>Example: The World
<LI>How Big Is My Tree?
<LI>Mutual Recursion
<LI>Searching for a Datum in the Tree
<LI>Locating a Datum in the Tree
<LI>Representing Trees as Lists
<LI>Abstract Data Types
<LI>An Advanced Example: Parsing Arithmetic Expressions
<LI>Pitfalls
</UL>

<H3>19. Implementing Higher-Order Functions</H3>
<UL>
<LI>Generalizing Patterns
<LI>The <CODE>Every</CODE> Pattern Revisited
<LI>The Difference between <CODE>Map</CODE> and <CODE>Every</CODE>
<LI><CODE>Filter</CODE>
<LI><CODE>Accumulate</CODE> and <CODE>Reduce</CODE>
<LI>Robustness
<LI>Higher-Order Functions for Structured Lists
<LI>The Zero-Trip Do Loop
<LI>Pitfalls
</UL>

<A HREF="part6.html"><H2>Part VI. Sequential Programming</H2></A>

<H3>20. Input and Output</H3>
<UL>
<LI>Printing
<LI>Side Effects and Sequencing
<LI>The <CODE>Begin</CODE> Special Form
<LI>This Isn't Functional Programming
<LI>Not Moving to the Next Line
<LI>Strings
<LI>A Higher-Order Procedure for Sequencing
<LI>Tic-Tac-Toe Revisited
<LI>Accepting User Input
<LI>Aesthetic Board Display
<LI>Reading and Writing Normal Text
<LI>Formatted Text
<LI>Sequential Programming and Order of Evaluation
<LI>Pitfalls
</UL>

<H3>21. Example: The <CODE>Functions</CODE> Program</H3>
<UL>
<LI>The Main Loop
<LI>The Difference between a Procedure and Its Name
<LI>The Association List of Functions
<LI>Domain Checking
<LI>Intentionally Confusing a Function with Its Name
<LI>More on Higher-Order Functions
<LI>More Robustness
<LI>Complete Program Listing
</UL>

<H3>22. Files</H3>
<UL>
<LI>Ports
<LI>Writing Files for People to Read
<LI>Using a File as a Database
<LI>Transforming the Lines of a File
<LI>Justifying Text
<LI>Preserving Spacing of Text from Files
<LI>Merging Two Files
<LI>Writing Files for Scheme to Read
<LI>Pitfalls
</UL>

<H3>23. Vectors</H3>
<UL>
<LI>The Indy 500
<LI>Vectors
<LI>Using Vectors in Programs
<LI>Non-Functional Procedures and State
<LI>Shuffling a Deck
<LI>More Vector Tools
<LI>The Vector Pattern of Recursion
<LI>Vectors versus Lists
<LI>State, Sequence, and Effects
<LI>Pitfalls
</UL>

<H3>24. Example: A Spreadsheet Program</H3>
<UL>
<LI>Limitations of Our Spreadsheet
<LI>Spreadsheet Commands
<LI>Moving the Selection
<LI>Putting Values in Cells
<LI>Formulas
<LI>Displaying Formula Values
<LI>Loading Spreadsheet Commands from a File
<LI>Application Programs and Abstraction
</UL>

<H3>25. Implementing the Spreadsheet Program</H3>
<UL>
<LI>Cells, Cell Names, and Cell IDs
<LI>The Command Processor
<LI>Cell Selection Commands
<LI>The <CODE>Load</CODE> Command
<LI>The <CODE>Put</CODE> Command
<LI>The Formula Translator
<LI>The Dependency Manager
<LI>The Expression Evaluator
<LI>The Screen Printer
<LI>The Cell Manager
<LI>Complete Program Listing
</UL>

<H3>Project: A Database Program</H3>
<UL>
<LI>A Sample Session with Our Database
<LI>How Databases Are Stored Internally
<LI>The Current Database
<LI>Implementing the Database Program Commands
<LI>Additions to the Program
<LI>Extra Work for Hotshots
</UL>

<A HREF="part7.html"><H2>Part VII. Conclusion: Computer Science</H2></A>

<H3>26. What's Next?</H3>
<UL>
<LI>The Best Computer Science Book
<LI>Beyond <CITE>SICP</CITE>
<LI>Standard Scheme
<LI>Last Words
</UL>

<H2>Appendices</H2>

<H3>A. Running Scheme</H3>
<UL>
<LI>The Program Development Cycle
<LI>Integrated Editing
<LI>Getting Our Programs
<LI>Tuning Our Programs for Your System
<LI>Loading Our Programs
<LI>Versions of Scheme
<LI>Scheme Standards
</UL>

<H3>B. Common Lisp</H3>
<UL>
<LI>Why Common Lisp Exists
<LI>Defining Procedures and Variables
<LI>The Naming Convention for Predicates
<LI>No Words or Sentences
<LI>True and False
<LI>Files
<LI>Arrays
<LI>Equivalents to Scheme Primitives
<LI>A Separate Name Space for Procedures
<LI><CODE>Lambda</CODE>
<LI>More about <CODE>Function</CODE>
<LI>Writing Higher-Order Procedures
</UL>

<H3>C. Scheme Initialization File</H3>

<H3>D. GNU General Public License</H3>
<H3>Credits</H3>
<H3>Alphabetical Table of Scheme Primitives</H3>
<H3>Glossary</H3>
<H3>Index of Defined Procedures</H3>
<H3>General Index</H3>

<P>
<A HREF="http://mitpress.mit.edu/0262082810">MIT
Press web page for <CITE>Simply Scheme</CITE></A>

<P>
<ADDRESS>
<A HREF="index.html">Brian Harvey</A>, 
<CODE>bh@cs.berkeley.edu</CODE>
</ADDRESS>
<BR>
<ADDRESS>
<A HREF="http://www.cnmat.berkeley.edu/~matt">Matthew Wright</A>,
<CODE>matt@cnmat.berkeley.edu</CODE>
</ADDRESS>
</BODY>
</HTML>