summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2003-07-29 09:46:55 +0000
committerburaq <buraq@epfl.ch>2003-07-29 09:46:55 +0000
commit9b9660252eb0a4a992dd4f3c461405ec43822d24 (patch)
tree839a2d735c683c4e31ae13e2a59b894e77e477f7 /test
parent30e3b26eee42660fae2f732443b79ad8a182e308 (diff)
downloadscala-9b9660252eb0a4a992dd4f3c461405ec43822d24.tar.gz
scala-9b9660252eb0a4a992dd4f3c461405ec43822d24.tar.bz2
scala-9b9660252eb0a4a992dd4f3c461405ec43822d24.zip
shortest-match policy instead of longest match ...
shortest-match policy instead of longest match policy
Diffstat (limited to 'test')
-rw-r--r--test/files/run/regularpatmat.scala16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/files/run/regularpatmat.scala b/test/files/run/regularpatmat.scala
index cbcc162952..829b32c838 100644
--- a/test/files/run/regularpatmat.scala
+++ b/test/files/run/regularpatmat.scala
@@ -118,9 +118,9 @@ object testBM {
test[List[Char],List[Char]]( doit1, s6, Nil);
val t7:List[Char] = 'a'::'a'::'a'::'b'::'b'::'b'::Nil;
- val t7ex:List[Char] = 'a'::'a'::'b'::Nil;
+ //val t7ex:List[Char] = 'a'::'a'::'b'::Nil; // with longest match policy
- test[List[Char],List[Char]]( doit1, t7, t7ex );
+ test[List[Char],List[Char]]( doit1, t7, List('a') );
()
};
@@ -206,7 +206,7 @@ object testBO {
/** first longest match policy -> the star is greedy/hungry/...
*/
- def searchLastJohn( db:List[ Person ] ):String = {
+ def searchFirstJohn( db:List[ Person ] ):String = {
db.match {
@@ -227,9 +227,9 @@ object testBO {
db.match {
- case List( before @ (_ *), Person( "John", lastname ), _ * )
+ case List( _ *, Person( "John", lastname ), rest@(_ *) )
=> { //System.out.print("before is : "+before );
- lastname::searchJohns( before )
+ lastname::searchJohns( rest )
}
case _
@@ -261,13 +261,13 @@ object testBO {
( onlyJohn, db2, "Le Carre"::Nil );
test[ List[Person], String ]
- ( searchLastJohn, db, "Smith" );
+ ( searchFirstJohn, db, "Le Carre" );
test[ List[Person], String ]
- ( searchLastJohn, db2, "Le Carre" );
+ ( searchFirstJohn, db2, "Le Carre" );
test[ List[Person], List[ String ]]
- ( searchJohns, db, "Smith"::"Le Carre"::Nil );
+ ( searchJohns, db, "Le Carre"::"Smith"::Nil );
test[ List[Person], List[ String ]]
( searchJohns, db2, "Le Carre"::Nil );