f35805c2c5/test/library/hash_and_aa/aa-test.retro

User picture

Commiter: Charles Childers

Author: Charles Childers

Revision: f35805c2c5


File Size: 1.43 KB

(March 09, 2010 00:08 UTC) About 2 years ago

keys stuff from Marc to data/aa.retro

 
Show/hide line numbers
include library/data/aa.retro

' associative open

vocab associative-tests
((
  {{
    new-hash constant %h1

    %h1 %{ hello = 100 }%
    %h1 %{ goodbye = 200 }%
    %h1 %{ some text goes here = 300 }%
    %h1 %{ you would never guess = here }%

    ( State test: )
    : add-test1 %h1 %{ yep = 500 }% ;
    add-test1
    ---reveal---
    : .? ( xf- ) if . else drop ." (not present)" then ;

    : aa.tests
      cr ." Testing 'hello': "
      %h1 @" hello" .?

      cr ." Testing 'goodbye': "
      %h1 @" goodbye" .?

      cr ." Testing 'some text goes here': "
      %h1 @" some text goes here" .?

      cr ." Testing 'you would never guess': "
      %h1 @" you would never guess" .?

      cr ." Testing 'yep' "
      %h1 @" yep" .?

      cr ." Testing 'not there!' "
      %h1 @" not there!" .? cr
    ;
  }}

    : new-hash: new-hash constant ;
    new-hash: h1
    new-hash: h2

    h1 %{ x = 10 }%
    h1 %{ y = 20 }%
    h1 %{ z = 30 }%
    h1 %{ more = " hello" keepString }%

    ( Be careful with visual alignment; leading spaces are   )
    ( part of the key string...                              )
    h2   %{ one = 1 }%
    h2   %{ two = 2 }%
    h2 %{ three = 3 }%

    ( NOTE: these operations are expensive: )
    : t1 h1 .keys ;
    : t2 h1 .table ;
    : t3 h2 .keys ;
    : t4 h2 .table ;
))

( ~~[ Testing ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )

clear aa.tests t1 t2 t3 t4

' associative-tests shut
' associative shut
bye