memoizing-procs.tcl

automated-testing for memoizing procs

Location:
packages/acs-tcl/tcl/test/memoizing-procs.tcl
Created:
2006-07-28
Author:
Adrian Catalan <ykro@galileo.edu>

Procedures in this file

Detailed information

_acs-tcl__util_memoize_cache (private)

 _acs-tcl__util_memoize_cache

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) memoizing_procs_test::return_string memoizing_procs_test::return_string (private) util_memoize util_memoize (public) _acs-tcl__util_memoize_cache _acs-tcl__util_memoize_cache _acs-tcl__util_memoize_cache->aa_equals _acs-tcl__util_memoize_cache->aa_log _acs-tcl__util_memoize_cache->aa_log_result _acs-tcl__util_memoize_cache->memoizing_procs_test::return_string _acs-tcl__util_memoize_cache->util_memoize

Testcases:
No testcase defined.

_acs-tcl__util_memoize_cache_flush (private)

 _acs-tcl__util_memoize_cache_flush

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) memoizing_procs_test::return_string memoizing_procs_test::return_string (private) memoizing_procs_test::return_upper_case_text memoizing_procs_test::return_upper_case_text (private) _acs-tcl__util_memoize_cache_flush _acs-tcl__util_memoize_cache_flush _acs-tcl__util_memoize_cache_flush->aa_equals _acs-tcl__util_memoize_cache_flush->aa_log _acs-tcl__util_memoize_cache_flush->aa_log_result _acs-tcl__util_memoize_cache_flush->memoizing_procs_test::return_string _acs-tcl__util_memoize_cache_flush->memoizing_procs_test::return_upper_case_text

Testcases:
No testcase defined.

_acs-tcl__util_memoize_cache_script (private)

 _acs-tcl__util_memoize_cache_script

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) util_memoize util_memoize (public) util_memoize_cached_p util_memoize_cached_p (public) _acs-tcl__util_memoize_cache_script _acs-tcl__util_memoize_cache_script _acs-tcl__util_memoize_cache_script->aa_equals _acs-tcl__util_memoize_cache_script->aa_log _acs-tcl__util_memoize_cache_script->aa_log_result _acs-tcl__util_memoize_cache_script->util_memoize _acs-tcl__util_memoize_cache_script->util_memoize_cached_p

Testcases:
No testcase defined.

memoizing_procs_test::return_string (private)

 memoizing_procs_test::return_string -name name

Test proc that returns a string

Switches:
-name (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

memoizing_procs_test::return_upper_case_text (private)

 memoizing_procs_test::return_upper_case_text -txt txt

Test proc that returns a string in uppercase

Switches:
-txt (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    automated-testing for memoizing procs

    @author Adrian Catalan (ykro@galileo.edu)
    @creation-date 2006-07-28
}

namespace eval memoizing_procs_test {}

d_proc -private memoizing_procs_test::return_string {
    {-name:required}
} {
    Test proc that returns a string
} {
    set response "This is a test for "
    append response $name
    return $response
}

d_proc -private memoizing_procs_test::return_upper_case_text {
    {-txt:required}
} {
    Test proc that returns a string in uppercase
} {
    set response $txt
    append response " in uppercase is "
    append response [string toupper $txt]
    return $response
}

aa_register_case \
    -cats {api smoke} \
    -procs {util_memoize util_memoize_cached_p} \
    util_memoize_cache {
    Test caching of a cmd call
} {
    aa_log "caching a cmd call"
    util_memoize {memoizing_procs_test::return_string -name "foobar"}
    aa_log "checking if the proc is cached"
    set success_p [util_memoize_cached_p {memoizing_procs_test::return_string -name "foobar"}]

    aa_equals "cmd call was cached successful" $success_p 1
}

aa_register_case \
    -cats {api smoke} \
    -bugs {3448} \
    -procs {util_memoize util_memoize_cached_p} \
    util_memoize_cache_script {
        Test passing a script to util_memoize.
    } {
        aa_log "caching a script"
        set script {
            set x 1
            set y 2
            expr {$x + $y}
        }
        set r [util_memoize $script]
        aa_equals "the script was executed successfully via util_memoize" $r 3

        set success_p [util_memoize_cached_p $script]
        aa_equals "the script is recognized as being cached" $success_p 1
    }


aa_register_case \
    -cats {api smoke} \
    -procs {util_memoize util_memoize_cached_p util_memoize_flush_regexp} \
    util_memoize_cache_flush {
    Test flush of a proc cached
} {
    aa_log "caching"
    util_memoize {memoizing_procs_test::return_string -name "foobar"}
    aa_log "checking if the proc is cached"
    aa_log "flushing"
    util_memoize_flush_regexp {return_upper_case_text}
    set success_p [util_memoize_cached_p {memoizing_procs_test::return_upper_case_text -txt "foobar"}]
    aa_equals "proc was flushed successful" $success_p 0
}


# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: