R Under development (unstable) (2026-01-20 r89309 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(hash) hash-2.2.6.4 provided by Decision Patterns > library(testthat) > > h0 <- hash() > h <- hash( letters, 1:26 ) > > # OBJECT CREATION / TYPE > for( h in list( h0, h) ) expect_is( h, "hash" ) > > > # EMPTY HASH > expect_that( length(h0), equals(0) ) > expect_that( length(h0), equals(0) ) > > # POPULATED HASH > expect_that( length(h), equals(26) ) > expect_that( keys(h), is_identical_to(letters) ) > > > # ALL HASHES > for( h in list( h0, h) ) { + expect_that( + h[['missing']], is_identical_to(NULL) + , label="Attempt to retrieve missing key" + ) + } > > > # TEST [[ > for( h in list( h0, h ) ) { + expect_error( h[[NULL]] ) + expect_error( h[[NA] ]) + expect_error( h[[]] ) + expect_error( h[[letters]] ) + } > > for( n in 1:26 ) expect_that( h[[ letters[n] ]], equals(n) ) > > > > # TEST $ > expect_that( h$a, equals(1) ) > expect_that( h$z, equals(26) ) > > > # TEST [ > for( h in list( h0, h ) ) { + expect_error( h[[NULL]] ) + expect_error( h[[NA] ]) + expect_error( h[[]] ) + expect_error( h[[letters]] ) + } > expect_that( h[ letters ], equals(h) ) > > > # TEST [[ <- > h[['a']] <- -1 > expect_that( h[['a']], equals(-1) ) > > # TEST $<- > h$b <- -2 > expect_that( h$b, equals(-2) ) > > # TEST [ <- > > proc.time() user system elapsed 4.73 0.65 5.40