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

User picture

Commiter: Charles Childers

Author: Charles Childers

Revision: e42c7ed451


File Size: 955 Bytes

(March 07, 2010 03:59 UTC) About 2 years ago

add associate arrays and hashing libraries from Marc

 
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
    ;
  }}
))

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

clear aa.tests

' associative-tests shut
' associative shut
bye