Skip to content

Commit

Permalink
switch some vocabs to 4 spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jul 24, 2013
1 parent 1f5e8f3 commit c75fc48
Show file tree
Hide file tree
Showing 16 changed files with 1,089 additions and 1,088 deletions.
10 changes: 5 additions & 5 deletions basis/csv/csv-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ IN: csv.tests

! I like to name my unit tests
: named-unit-test ( name output input -- )
unit-test drop ; inline
unit-test drop ; inline

"Fields are separated by commas"
[ { { "1997" "Ford" "E350" } } ]
Expand All @@ -22,17 +22,17 @@ IN: csv.tests
"double quotes mean escaped in quotes"
[ { { "1997" "Ford" "E350" "Super \"luxurious\" truck" } } ]
[ "1997,Ford,E350,\"Super \"\"luxurious\"\" truck\""
string>csv ] named-unit-test
string>csv ] named-unit-test

"Fields with embedded line breaks must be delimited by double-quote characters."
[ { { "1997" "Ford" "E350" "Go get one now\nthey are going fast" } } ]
[ "1997,Ford,E350,\"Go get one now\nthey are going fast\""
string>csv ] named-unit-test
string>csv ] named-unit-test

"Fields with leading or trailing spaces must be delimited by double-quote characters. (See comment about leading and trailing spaces above)"
[ { { "1997" "Ford" "E350" " Super luxurious truck " } } ]
[ "1997,Ford,E350,\" Super luxurious truck \""
string>csv ] named-unit-test
string>csv ] named-unit-test

"Fields may always be delimited by double-quote characters, whether necessary or not."
[ { { "1997" "Ford" "E350" } } ]
Expand All @@ -43,7 +43,7 @@ IN: csv.tests
{ "1997" "Ford" "E350" }
{ "2000" "Mercury" "Cougar" } } ]
[ "Year,Make,Model\n1997,Ford,E350\n2000,Mercury,Cougar"
string>csv ] named-unit-test
string>csv ] named-unit-test


! !!!!!!!! other tests
Expand Down
88 changes: 43 additions & 45 deletions basis/match/match-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,78 @@ MATCH-VARS: ?a ?b ;
[ f ] [ { ?a ?a } { 1 2 } match ] unit-test

[ H{ { ?a 1 } { ?b 2 } } ] [
{ ?a ?b } { 1 2 } match
{ ?a ?b } { 1 2 } match
] unit-test

[ { 1 2 } ] [
{ 1 2 }
{
{ { ?a ?b } [ ?a ?b 2array ] }
} match-cond
[ { 1 2 } ] [
{ 1 2 }
{
{ { ?a ?b } [ ?a ?b 2array ] }
} match-cond
] unit-test

[ t ] [
{ 1 2 }
{
{ { 1 2 } [ t ] }
{ f [ f ] }
} match-cond
[ t ] [
{ 1 2 }
{
{ { 1 2 } [ t ] }
{ f [ f ] }
} match-cond
] unit-test

[ t ] [
{ 1 3 }
{
{ { 1 2 } [ t ] }
{ { 1 3 } [ t ] }
} match-cond
[ t ] [
{ 1 3 }
{
{ { 1 2 } [ t ] }
{ { 1 3 } [ t ] }
} match-cond
] unit-test

[ f ] [
{ 1 5 }
{
{ { 1 2 } [ t ] }
{ { 1 3 } [ t ] }
{ _ [ f ] }
} match-cond
[ f ] [
{ 1 5 }
{
{ { 1 2 } [ t ] }
{ { 1 3 } [ t ] }
{ _ [ f ] }
} match-cond
] unit-test

TUPLE: foo a b ;

C: <foo> foo

{ 1 2 } [
1 2 <foo> T{ foo f ?a ?b } match [
?a ?b
] with-variables
1 2 <foo> T{ foo f ?a ?b } match [
?a ?b
] with-variables
] unit-test

{ 1 2 } [
1 2 <foo> \ ?a \ ?b <foo> match [
?a ?b
] with-variables
1 2 <foo> \ ?a \ ?b <foo> match [
?a ?b
] with-variables
] unit-test

{ H{ { ?a ?a } } } [
\ ?a \ ?a match
{ H{ { ?a ?a } } }
\ ?a \ ?a match
] unit-test

[ "match" ] [
"abcd" {
{ ?a [ "match" ] }
} match-cond
[ "match" ] [
"abcd" {
{ ?a [ "match" ] }
} match-cond
] unit-test

[
{ 2 1 }
] [
{ "a" 1 2 "b" } { _ ?a ?b _ } { ?b ?a } match-replace
{ { 2 1 } } [
{ "a" 1 2 "b" } { _ ?a ?b _ } { ?b ?a } match-replace
] unit-test

TUPLE: match-replace-test a b ;

[
T{ match-replace-test f 2 1 }
] [
T{ match-replace-test f 1 2 }
T{ match-replace-test f ?a ?b }
T{ match-replace-test f ?b ?a }
match-replace
T{ match-replace-test f 1 2 }
T{ match-replace-test f ?a ?b }
T{ match-replace-test f ?b ?a }
match-replace
] unit-test
20 changes: 15 additions & 5 deletions basis/math/functions/functions.factor
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,22 @@ M: real absq sq ; inline
: >=1? ( x -- ? )
dup complex? [ drop f ] [ 1 >= ] if ; inline

<PRIVATE

: fp-normalize ( x -- y exp )
dup abs 0x1.0p-1022 < [ 52 2^ * -52 ] [ 0 ] if ; inline

PRIVATE>

GENERIC: frexp ( x -- y exp )

M: float frexp
dup fp-special? [ dup zero? ] unless* [ 0 ] [
double>bits
[ 0x800f,ffff,ffff,ffff bitand 0.5 double>bits bitor bits>double ]
[ -52 shift 0x7ff bitand 1022 - ] bi
fp-normalize [
double>bits
[ 0x800f,ffff,ffff,ffff bitand 0.5 double>bits bitor bits>double ]
[ -52 shift 0x7ff bitand 1022 - ] bi
] dip +
] if ; inline

M: integer frexp
Expand All @@ -210,8 +219,9 @@ GENERIC# ldexp 1 ( x exp -- y )

M: float ldexp
over fp-special? [ over zero? ] unless* [ drop ] [
[ double>bits dup -52 shift 0x7ff bitand 1023 - ] dip +
{
[ fp-normalize ] dip
[ double>bits dup -52 shift 0x7ff bitand 1023 - ]
[ + ] [ + ] tri* {
{ [ dup -1074 < ] [ drop 0 copysign ] }
{ [ dup 1023 > ] [ drop 0 < -1/0. 1/0. ? ] }
[
Expand Down
Loading

0 comments on commit c75fc48

Please sign in to comment.