unit tests for identities, recrossref speedup

cvs
Slava Pestov 2005-08-14 06:08:11 +00:00
parent 1fa0bfc130
commit 10ea9df312
4 changed files with 69 additions and 7 deletions

View File

@ -189,8 +189,8 @@ This guide uses the standard mathematical notation to denote intervals.
Notation&Meaning\\
\hline
$(a,b)$&All numbers from $a$ to $b$, excluding $a$ and $b$\\
$[a,b)$&All numbers from $a$ to $b$, including $a$ and excluding and $b$\\
$(a,b]$&All numbers from $a$ to $b$, excluding $a$ and including and $b$\\
$[a,b)$&All numbers from $a$ to $b$, including $a$ and excluding $b$\\
$(a,b]$&All numbers from $a$ to $b$, excluding $a$ and including $b$\\
$[a,b]$&All numbers from $a$ to $b$, including $a$ and $b$
\end{tabular}
@ -233,7 +233,7 @@ parsing words. Tokens are appended to the parse tree, the top level of which is
returned by the original parser invocation. Nested levels of the parse tree are created
by parsing words.
Here is the parser algorithm in more detail -- some of the concepts therein will be defined shortly:
The parser iterates through the input text, checking each character in turn. Here is the parser algorithm in more detail -- some of the concepts therein will be defined shortly:
\begin{itemize}
\item If the current character is a double-quote (\texttt{"}), the \texttt{"} parsing word is executed, causing a string to be read.
@ -522,7 +522,7 @@ Escape code&Character\\
\texttt{\bs{}s}&Space\\
\texttt{\bs{}t}&Tab\\
\texttt{\bs{}n}&Newline\\
\texttt{\bs{}t}&Carriage return\\
\texttt{\bs{}r}&Carriage return\\
\texttt{\bs{}0}&Null byte (ASCII 0)\\
\texttt{\bs{}e}&Escape (ASCII 27)\\
\texttt{\bs{}"}&Double quote (\texttt{"})\\
@ -1043,8 +1043,8 @@ There is one final conditional form that is used to implement the ``default valu
}
If the condition is \texttt{f}, the \texttt{false} quotation is called with the \texttt{default} value on the stack. Otherwise, the \texttt{true} quotation is called with the condition on the stack. The following two lines are equivalent:
\begin{verbatim}
X [ Y ] [ Z ] ?ifte
X dup [ nip Y ] [ drop Z ] ifte
D X [ Y ] [ Z ] ?ifte
D X dup [ nip Y ] [ drop Z ] ifte
\end{verbatim}
\subsection{Boolean logic}

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: sequences
USING: generic kernel lists ;
USING: generic kernel lists strings ;
G: tree-each ( obj quot -- | quot: elt -- )
[ over ] [ type ] ; inline
@ -13,5 +13,7 @@ M: object tree-each call ;
M: sequence tree-each swap [ swap tree-each ] each-with ;
M: string tree-each call ;
M: cons tree-each ( cons quot -- )
>r uncons r> tuck >r >r tree-each r> r> tree-each ;

View File

@ -0,0 +1,59 @@
IN: temporary
USING: compiler kernel math test ;
[ 5 ] [ 5 [ 0 + ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 swap + ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 - ] compile-1 ] unit-test
[ -5 ] [ 5 [ 0 swap - ] compile-1 ] unit-test
[ 0 ] [ 5 [ dup - ] compile-1 ] unit-test
[ 5 ] [ 5 [ 1 * ] compile-1 ] unit-test
[ 5 ] [ 5 [ 1 swap * ] compile-1 ] unit-test
[ 0 ] [ 5 [ 0 * ] compile-1 ] unit-test
[ 0 ] [ 5 [ 0 swap * ] compile-1 ] unit-test
[ -5 ] [ 5 [ -1 * ] compile-1 ] unit-test
[ -5 ] [ 5 [ -1 swap * ] compile-1 ] unit-test
[ 5 ] [ 5 [ 1 / ] compile-1 ] unit-test
[ 1/5 ] [ 5 [ 1 swap / ] compile-1 ] unit-test
[ -5 ] [ 5 [ -1 / ] compile-1 ] unit-test
[ 0 ] [ 5 [ 1 mod ] compile-1 ] unit-test
[ 0 ] [ 5 [ 1 rem ] compile-1 ] unit-test
[ 5 ] [ 5 [ 1 ^ ] compile-1 ] unit-test
[ 25 ] [ 5 [ 2 ^ ] compile-1 ] unit-test
[ 1/5 ] [ 5 [ -1 ^ ] compile-1 ] unit-test
[ 1/25 ] [ 5 [ -2 ^ ] compile-1 ] unit-test
[ 1 ] [ 5 [ 1 swap ^ ] compile-1 ] unit-test
[ 5 ] [ 5 [ -1 bitand ] compile-1 ] unit-test
[ 0 ] [ 5 [ 0 bitand ] compile-1 ] unit-test
[ 5 ] [ 5 [ -1 swap bitand ] compile-1 ] unit-test
[ 0 ] [ 5 [ 0 swap bitand ] compile-1 ] unit-test
[ 5 ] [ 5 [ dup bitand ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 bitor ] compile-1 ] unit-test
[ -1 ] [ 5 [ -1 bitor ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 swap bitor ] compile-1 ] unit-test
[ -1 ] [ 5 [ -1 swap bitor ] compile-1 ] unit-test
[ 5 ] [ 5 [ dup bitor ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 bitxor ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 swap bitxor ] compile-1 ] unit-test
[ -6 ] [ 5 [ -1 bitxor ] compile-1 ] unit-test
[ -6 ] [ 5 [ -1 swap bitxor ] compile-1 ] unit-test
[ 0 ] [ 5 [ dup bitxor ] compile-1 ] unit-test
[ 0 ] [ 5 [ 0 swap shift ] compile-1 ] unit-test
[ 5 ] [ 5 [ 0 shift ] compile-1 ] unit-test
[ f ] [ 5 [ dup < ] compile-1 ] unit-test
[ t ] [ 5 [ dup <= ] compile-1 ] unit-test
[ f ] [ 5 [ dup > ] compile-1 ] unit-test
[ t ] [ 5 [ dup >= ] compile-1 ] unit-test
[ t ] [ 5 [ dup eq? ] compile-1 ] unit-test
[ t ] [ 5 [ dup = ] compile-1 ] unit-test
[ t ] [ 5 [ dup number= ] compile-1 ] unit-test

View File

@ -110,6 +110,7 @@ SYMBOL: failures
"compiler/stack" "compiler/ifte"
"compiler/generic" "compiler/bail-out"
"compiler/linearizer" "compiler/intrinsics"
"compiler/identities"
] run-tests ;
: all-tests tests compiler-tests benchmarks ;