Changeset 2149

Show
Ignore:
Timestamp:
07/01/08 07:43:16 (3 months ago)
Author:
jmaessen
Message:

Stream was being closed before read, so this wasn't testing anything
useful! Fixed that and added code to check the output at least in a
rough way.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ProjectFortress/tests/WordCountSmall.fss

    r1825 r2149  
    7878 
    7979opr UNIONUNION(a:Map[\ZZ32,List[\String\]\], b:Map[\ZZ32, List[\String\]\]):Map[\ZZ32,List[\String\]\] = 
    80     a.union(fn(k,x,y) =>x.append(y),b) 
     80    a.union(fn(k,x,y) => x || y, b) 
    8181 
    8282opr BIG UNIONUNION(): BigReduction[\Map[\ZZ32, List[\String\]\],Map[\ZZ32, List[\String\]\]\] = 
     
    8686    println("Processing file " name) 
    8787    var rs:FileReadStream = FileReadStream(name) 
     88    database:Map[\String, ZZ32\] = BIG UNIONSUM [l<-rs.lines()] (getWords(l)) 
    8889    rs.close() 
    89     database:Map[\String, ZZ32\] = BIG UNIONSUM [l<-rs.lines()] (getWords(l)) 
    9090    var invDatabase:Map[\ZZ32,List[\String\]\] = BIG UNIONUNION [(x,y) <-database] (makeInv(x,y)) 
     91    expected = <| (6,1),(4,2),(3,1),(2,13),(1,154) |> 
    9192    try 
    92         for i <- seq(1#100) do 
     93        for (ce,me) <- seq(expected) do 
    9394            (c:ZZ32,m:List[\String\]) = invDatabase.maximum().get() 
    9495            invDatabase := invDatabase.deleteMaximum() 
    9596            println(m ": " c " times") 
     97            assert(c,ce," expected occurrences mismatched") 
     98            assert(|m|,me," expected number of words mismatched") 
    9699        end 
    97100    catch e 
    98             NotFound => println("end") 
     101            NotFound => fail("ended too early!") 
    99102    end 
     103    assert(|invDatabase|, 0, "Still entries in invDatabase ", invDatabase) 
    100104end 
    101105 
     
    105109end 
    106110end 
    107