Tcl Source Code

Artifact [9a7886ada5]
Login

Artifact 9a7886ada5739b2cd44c8bc99c2bc50db55b220d:

Attachment "info.test.diff" to ticket [461635ffff] added by glennjnn 2001-09-15 02:24:13.
*** tests/info.test~	Mon Apr 10 13:19:00 2000
--- tests/info.test	Fri Sep 14 14:50:11 2001
***************
*** 267,273 ****
      list [catch {info exists 1 2} msg] $msg
  } {1 {wrong # args: should be "info exists varName"}}
  
! test info-8.1 {info globals option} {
      set x 1
      set y 2
      set value 23
--- 267,305 ----
      list [catch {info exists 1 2} msg] $msg
  } {1 {wrong # args: should be "info exists varName"}}
  
! test info-8.1 {info fullargs option} {
!     proc t1 {a bbb c} {return foo}
!     info fullargs t1
! } {a bbb c}
! test info-8.2 {info fullargs option} {
!     proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
!     info f t1
! } {{a default1} {bbb default2} {c default3} args}
! test info-8.3 {info fullargs option} {
!     proc t1 "" {return foo}
!     info fullargs t1
! } {}
! test info-8.4 {info fullargs option} {
!     catch {rename t1 {}}
!     list [catch {info fullargs t1} msg] $msg
! } {1 {"t1" isn't a procedure}}
! test info-8.5 {info fullargs option} {
!     list [catch {info fullargs set} msg] $msg
! } {1 {"set" isn't a procedure}}
! test info-8.6 {info fullargs option} {
!     proc t1 {a b} {set c 123; set d $c}
!     t1 1 2
!     info fullargs t1
! } {a b}
! test info-8.7 {info fullargs option} {
!     catch {namespace delete test_ns_info2}
!     namespace eval test_ns_info2 {
!         namespace import ::test_ns_info1::*
!         list [info fullargs p] [info fullargs q]
!     }
! } {x {{y 27} {z {}}}}
! 
! test info-9.1 {info globals option} {
      set x 1
      set y 2
      set value 23
***************
*** 275,293 ****
      list [string match {* x *} $a] [string match {* y *} $a] \
              [string match {* value *} $a] [string match {* _foobar_ *} $a]
  } {1 1 1 0}
! test info-8.2 {info globals option} {
      set _xxx1 1
      set _xxx2 2
      lsort [info g _xxx*]
  } {_xxx1 _xxx2}
! test info-8.3 {info globals option} {
      list [catch {info globals 1 2} msg] $msg
  } {1 {wrong # args: should be "info globals ?pattern?"}}
  
! test info-9.1 {info level option} {
      info level
  } 0
! test info-9.2 {info level option} {
      proc t1 {a b} {
          set x [info le]
          set y [info level 1]
--- 307,325 ----
      list [string match {* x *} $a] [string match {* y *} $a] \
              [string match {* value *} $a] [string match {* _foobar_ *} $a]
  } {1 1 1 0}
! test info-9.2 {info globals option} {
      set _xxx1 1
      set _xxx2 2
      lsort [info g _xxx*]
  } {_xxx1 _xxx2}
! test info-9.3 {info globals option} {
      list [catch {info globals 1 2} msg] $msg
  } {1 {wrong # args: should be "info globals ?pattern?"}}
  
! test info-10.1 {info level option} {
      info level
  } 0
! test info-10.2 {info level option} {
      proc t1 {a b} {
          set x [info le]
          set y [info level 1]
***************
*** 295,301 ****
      }
      t1 146 testString
  } {1 {t1 146 testString}}
! test info-9.3 {info level option} {
      proc t1 {a b} {
          t2 [expr $a*2] $b
      }
--- 327,333 ----
      }
      t1 146 testString
  } {1 {t1 146 testString}}
! test info-10.3 {info level option} {
      proc t1 {a b} {
          t2 [expr $a*2] $b
      }
***************
*** 305,311 ****
      }
      t1 146 {a {b c} {{{c}}}}
  } {2 {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}} {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}}}
! test info-9.4 {info level option} {
      proc t1 {} {
          set x [info level]
          set y [info level 1]
--- 337,343 ----
      }
      t1 146 {a {b c} {{{c}}}}
  } {2 {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}} {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}}}
! test info-10.4 {info level option} {
      proc t1 {} {
          set x [info level]
          set y [info level 1]
***************
*** 313,358 ****
      }
      t1
  } {1 t1}
! test info-9.5 {info level option} {
      list [catch {info level 1 2} msg] $msg
  } {1 {wrong # args: should be "info level ?number?"}}
! test info-9.6 {info level option} {
      list [catch {info level 123a} msg] $msg
  } {1 {expected integer but got "123a"}}
! test info-9.7 {info level option} {
      list [catch {info level 0} msg] $msg
  } {1 {bad level "0"}}
! test info-9.8 {info level option} {
      proc t1 {} {info level -1}
      list [catch {t1} msg] $msg
  } {1 {bad level "-1"}}
! test info-9.9 {info level option} {
      proc t1 {x} {info level $x}
      list [catch {t1 -3} msg] $msg
  } {1 {bad level "-3"}}
  
  set savedLibrary $tcl_library
! test info-10.1 {info library option} {
      list [catch {info library x} msg] $msg
  } {1 {wrong # args: should be "info library"}}
! test info-10.2 {info library option} {
      set tcl_library 12345
      info library
  } {12345}
! test info-10.3 {info library option} {
      unset tcl_library
      list [catch {info library} msg] $msg
  } {1 {no library has been specified for Tcl}}
  set tcl_library $savedLibrary
  
! test info-11.1 {info loaded option} {
      list [catch {info loaded a b} msg] $msg
  } {1 {wrong # args: should be "info loaded ?interp?"}}
! test info-11.2 {info loaded option} {
      list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg
  } {0 1 {could not find interpreter "gorp"}}
  
! test info-12.1 {info locals option} {
      set a 22
      proc t1 {x y} {
          set b 13
--- 345,390 ----
      }
      t1
  } {1 t1}
! test info-10.5 {info level option} {
      list [catch {info level 1 2} msg] $msg
  } {1 {wrong # args: should be "info level ?number?"}}
! test info-10.6 {info level option} {
      list [catch {info level 123a} msg] $msg
  } {1 {expected integer but got "123a"}}
! test info-10.7 {info level option} {
      list [catch {info level 0} msg] $msg
  } {1 {bad level "0"}}
! test info-10.8 {info level option} {
      proc t1 {} {info level -1}
      list [catch {t1} msg] $msg
  } {1 {bad level "-1"}}
! test info-10.9 {info level option} {
      proc t1 {x} {info level $x}
      list [catch {t1 -3} msg] $msg
  } {1 {bad level "-3"}}
  
  set savedLibrary $tcl_library
! test info-11.1 {info library option} {
      list [catch {info library x} msg] $msg
  } {1 {wrong # args: should be "info library"}}
! test info-11.2 {info library option} {
      set tcl_library 12345
      info library
  } {12345}
! test info-11.3 {info library option} {
      unset tcl_library
      list [catch {info library} msg] $msg
  } {1 {no library has been specified for Tcl}}
  set tcl_library $savedLibrary
  
! test info-12.1 {info loaded option} {
      list [catch {info loaded a b} msg] $msg
  } {1 {wrong # args: should be "info loaded ?interp?"}}
! test info-12.2 {info loaded option} {
      list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg
  } {0 1 {could not find interpreter "gorp"}}
  
! test info-13.1 {info locals option} {
      set a 22
      proc t1 {x y} {
          set b 13
***************
*** 362,368 ****
      }
      lsort [t1 23 24]
  } {b c x y}
! test info-12.2 {info locals option} {
      proc t1 {x y} {
          set xx1 2
          set xx2 3
--- 394,400 ----
      }
      lsort [t1 23 24]
  } {b c x y}
! test info-13.2 {info locals option} {
      proc t1 {x y} {
          set xx1 2
          set xx2 3
***************
*** 371,387 ****
      }
      lsort [t1 2 3]
  } {x xx1 xx2}
! test info-12.3 {info locals option} {
      list [catch {info locals 1 2} msg] $msg
  } {1 {wrong # args: should be "info locals ?pattern?"}}
! test info-12.4 {info locals option} {
      info locals
  } {}
! test info-12.5 {info locals option} {
      proc t1 {} {return [info locals]}
      t1
  } {}
! test info-12.6 {info locals vs unset compiled locals} {
      proc t1 {lst} {
          foreach $lst $lst {}
          unset lst
--- 403,419 ----
      }
      lsort [t1 2 3]
  } {x xx1 xx2}
! test info-13.3 {info locals option} {
      list [catch {info locals 1 2} msg] $msg
  } {1 {wrong # args: should be "info locals ?pattern?"}}
! test info-13.4 {info locals option} {
      info locals
  } {}
! test info-13.5 {info locals option} {
      proc t1 {} {return [info locals]}
      t1
  } {}
! test info-13.6 {info locals vs unset compiled locals} {
      proc t1 {lst} {
          foreach $lst $lst {}
          unset lst
***************
*** 389,395 ****
      }
      lsort [t1 {a b c c d e f}]
  } {a b c d e f}
! test info-12.7 {info locals with temporary variables} {
      proc t1 {} {
          foreach a {b c} {}
          info locals
--- 421,427 ----
      }
      lsort [t1 {a b c c d e f}]
  } {a b c d e f}
! test info-13.7 {info locals with temporary variables} {
      proc t1 {} {
          foreach a {b c} {}
          info locals
***************
*** 397,414 ****
      t1
  } {a}
  
! test info-13.1 {info nameofexecutable option} {
      list [catch {info nameofexecutable foo} msg] $msg
  } {1 {wrong # args: should be "info nameofexecutable"}}
  
! test info-14.1 {info patchlevel option} {
      set a [info patchlevel]
      regexp {[0-9]+\.[0-9]+([p[0-9]+)?} $a
  } 1
! test info-14.2 {info patchlevel option} {
      list [catch {info patchlevel a} msg] $msg
  } {1 {wrong # args: should be "info patchlevel"}}
! test info-14.3 {info patchlevel option} {
      set t $tcl_patchLevel
      unset tcl_patchLevel
      set result [list [catch {info patchlevel} msg] $msg]
--- 429,446 ----
      t1
  } {a}
  
! test info-14.1 {info nameofexecutable option} {
      list [catch {info nameofexecutable foo} msg] $msg
  } {1 {wrong # args: should be "info nameofexecutable"}}
  
! test info-15.1 {info patchlevel option} {
      set a [info patchlevel]
      regexp {[0-9]+\.[0-9]+([p[0-9]+)?} $a
  } 1
! test info-15.2 {info patchlevel option} {
      list [catch {info patchlevel a} msg] $msg
  } {1 {wrong # args: should be "info patchlevel"}}
! test info-15.3 {info patchlevel option} {
      set t $tcl_patchLevel
      unset tcl_patchLevel
      set result [list [catch {info patchlevel} msg] $msg]
***************
*** 416,439 ****
      set result
  } {1 {can't read "tcl_patchLevel": no such variable}}
  
! test info-15.1 {info procs option} {
      proc t1 {} {}
      proc t2 {} {}
      set x " [info procs] "
      list [string match {* t1 *} $x] [string match {* t2 *} $x] \
              [string match {* _undefined_ *} $x]
  } {1 1 0}
! test info-15.2 {info procs option} {
      proc _tt1 {} {}
      proc _tt2 {} {}
      lsort [info pr _tt*]
  } {_tt1 _tt2}
  catch {rename _tt1 {}}
  catch {rename _tt2 {}}
! test info-15.3 {info procs option} {
      list [catch {info procs 2 3} msg] $msg
  } {1 {wrong # args: should be "info procs ?pattern?"}}
! test info-15.4 {info procs option} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
          namespace import ::test_ns_info1::*
--- 448,471 ----
      set result
  } {1 {can't read "tcl_patchLevel": no such variable}}
  
! test info-16.1 {info procs option} {
      proc t1 {} {}
      proc t2 {} {}
      set x " [info procs] "
      list [string match {* t1 *} $x] [string match {* t2 *} $x] \
              [string match {* _undefined_ *} $x]
  } {1 1 0}
! test info-16.2 {info procs option} {
      proc _tt1 {} {}
      proc _tt2 {} {}
      lsort [info pr _tt*]
  } {_tt1 _tt2}
  catch {rename _tt1 {}}
  catch {rename _tt2 {}}
! test info-16.3 {info procs option} {
      list [catch {info procs 2 3} msg] $msg
  } {1 {wrong # args: should be "info procs ?pattern?"}}
! test info-16.4 {info procs option} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
          namespace import ::test_ns_info1::*
***************
*** 441,447 ****
          list [info procs] [info procs p*]
      }
  } {{p q r} p}
! test info-15.5 {info procs option with a proc in a namespace} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
  	proc p1 { arg } {
--- 473,479 ----
          list [info procs] [info procs p*]
      }
  } {{p q r} p}
! test info-16.5 {info procs option with a proc in a namespace} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
  	proc p1 { arg } {
***************
*** 453,459 ****
      }
      info procs ::test_ns_info2::p1
  } {::test_ns_info2::p1}
! test info-15.6 {info procs option with a pattern in a namespace} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
  	proc p1 { arg } {
--- 485,491 ----
      }
      info procs ::test_ns_info2::p1
  } {::test_ns_info2::p1}
! test info-16.6 {info procs option with a pattern in a namespace} {
      catch {namespace delete test_ns_info2}
      namespace eval test_ns_info2 {
  	proc p1 { arg } {
***************
*** 465,471 ****
      }
      lsort [info procs ::test_ns_info2::p*]
  } [lsort [list ::test_ns_info2::p1 ::test_ns_info2::p2]]
! test info-15.7 {info procs option with a global shadowing proc} {
      catch {namespace delete test_ns_info2}
      proc string_cmd { arg } {
          puts cmd
--- 497,503 ----
      }
      lsort [info procs ::test_ns_info2::p*]
  } [lsort [list ::test_ns_info2::p1 ::test_ns_info2::p2]]
! test info-16.7 {info procs option with a global shadowing proc} {
      catch {namespace delete test_ns_info2}
      proc string_cmd { arg } {
          puts cmd
***************
*** 481,487 ****
  # that the implementation of "info procs" looks into the global namespace,
  # which it does not (in contrast to "info commands")
  if {0} {
! test info-15.8 {info procs option with a global shadowing proc} {
      catch {namespace delete test_ns_info2}
      proc string_cmd { arg } {
          puts cmd
--- 513,519 ----
  # that the implementation of "info procs" looks into the global namespace,
  # which it does not (in contrast to "info commands")
  if {0} {
! test info-16.8 {info procs option with a global shadowing proc} {
      catch {namespace delete test_ns_info2}
      proc string_cmd { arg } {
          puts cmd
***************
*** 500,538 ****
  } [lsort [list string_cmd string_cmd2]]
  }
  
! test info-16.1 {info script option} {
      list [catch {info script x} msg] $msg
  } {1 {wrong # args: should be "info script"}}
! test info-16.2 {info script option} {
      file tail [info sc]
  } "info.test"
  removeFile gorp.info
  makeFile "info script\n" gorp.info
! test info-16.3 {info script option} {
      list [source gorp.info] [file tail [info script]]
  } [list gorp.info info.test]
! test info-16.4 {resetting "info script" after errors} {
      catch {source ~_nobody_/foo}
      file tail [info script]
  } "info.test"
! test info-16.5 {resetting "info script" after errors} {
      catch {source _nonexistent_}
      file tail [info script]
  } "info.test"
  removeFile gorp.info
  
! test info-17.1 {info sharedlibextension option} {
      list [catch {info sharedlibextension foo} msg] $msg
  } {1 {wrong # args: should be "info sharedlibextension"}}
  
! test info-18.1 {info tclversion option} {
      set x [info tclversion]
      scan $x "%d.%d%c" a b c
  } 2
! test info-18.2 {info tclversion option} {
      list [catch {info t 2} msg] $msg
  } {1 {wrong # args: should be "info tclversion"}}
! test info-18.3 {info tclversion option} {
      set t $tcl_version
      unset tcl_version
      set result [list [catch {info tclversion} msg] $msg]
--- 532,570 ----
  } [lsort [list string_cmd string_cmd2]]
  }
  
! test info-17.1 {info script option} {
      list [catch {info script x} msg] $msg
  } {1 {wrong # args: should be "info script"}}
! test info-17.2 {info script option} {
      file tail [info sc]
  } "info.test"
  removeFile gorp.info
  makeFile "info script\n" gorp.info
! test info-17.3 {info script option} {
      list [source gorp.info] [file tail [info script]]
  } [list gorp.info info.test]
! test info-17.4 {resetting "info script" after errors} {
      catch {source ~_nobody_/foo}
      file tail [info script]
  } "info.test"
! test info-17.5 {resetting "info script" after errors} {
      catch {source _nonexistent_}
      file tail [info script]
  } "info.test"
  removeFile gorp.info
  
! test info-18.1 {info sharedlibextension option} {
      list [catch {info sharedlibextension foo} msg] $msg
  } {1 {wrong # args: should be "info sharedlibextension"}}
  
! test info-19.1 {info tclversion option} {
      set x [info tclversion]
      scan $x "%d.%d%c" a b c
  } 2
! test info-19.2 {info tclversion option} {
      list [catch {info t 2} msg] $msg
  } {1 {wrong # args: should be "info tclversion"}}
! test info-19.3 {info tclversion option} {
      set t $tcl_version
      unset tcl_version
      set result [list [catch {info tclversion} msg] $msg]
***************
*** 540,546 ****
      set result
  } {1 {can't read "tcl_version": no such variable}}
  
! test info-19.1 {info vars option} {
      set a 1
      set b 2
      proc t1 {x y} {
--- 572,578 ----
      set result
  } {1 {can't read "tcl_version": no such variable}}
  
! test info-20.1 {info vars option} {
      set a 1
      set b 2
      proc t1 {x y} {
***************
*** 550,556 ****
      }
      lsort [t1 18 19]
  } {a b c x y}
! test info-19.2 {info vars option} {
      set xxx1 1
      set xxx2 2
      proc t1 {xxa y} {
--- 582,588 ----
      }
      lsort [t1 18 19]
  } {a b c x y}
! test info-20.2 {info vars option} {
      set xxx1 1
      set xxx2 2
      proc t1 {xxa y} {
***************
*** 560,572 ****
      }
      lsort [t1 18 19]
  } {xxa xxx1 xxx2}
! test info-19.3 {info vars option} {
      lsort [info vars]
  } [lsort [info globals]]
! test info-19.4 {info vars option} {
      list [catch {info vars a b} msg] $msg
  } {1 {wrong # args: should be "info vars ?pattern?"}}
! test info-19.5 {info vars with temporary variables} {
      proc t1 {} {
          foreach a {b c} {}
          info vars
--- 592,604 ----
      }
      lsort [t1 18 19]
  } {xxa xxx1 xxx2}
! test info-20.3 {info vars option} {
      lsort [info vars]
  } [lsort [info globals]]
! test info-20.4 {info vars option} {
      list [catch {info vars a b} msg] $msg
  } {1 {wrong # args: should be "info vars ?pattern?"}}
! test info-20.5 {info vars with temporary variables} {
      proc t1 {} {
          foreach a {b c} {}
          info vars
***************
*** 574,594 ****
      t1
  } {a}
  
! test info-20.1 {miscellaneous error conditions} {
      list [catch {info} msg] $msg
  } {1 {wrong # args: should be "info option ?arg arg ...?"}}
! test info-20.2 {miscellaneous error conditions} {
      list [catch {info gorp} msg] $msg
! } {1 {bad option "gorp": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-20.3 {miscellaneous error conditions} {
      list [catch {info c} msg] $msg
! } {1 {ambiguous option "c": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-20.4 {miscellaneous error conditions} {
      list [catch {info l} msg] $msg
! } {1 {ambiguous option "l": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-20.5 {miscellaneous error conditions} {
      list [catch {info s} msg] $msg
! } {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
  
  # cleanup
  catch {namespace delete test_ns_info1 test_ns_info2}
--- 606,626 ----
      t1
  } {a}
  
! test info-21.0 {miscellaneous error conditions} {
      list [catch {info} msg] $msg
  } {1 {wrong # args: should be "info option ?arg arg ...?"}}
! test info-21.2 {miscellaneous error conditions} {
      list [catch {info gorp} msg] $msg
! } {1 {bad option "gorp": must be args, body, cmdcount, commands, complete, default, exists, fullargs, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-21.3 {miscellaneous error conditions} {
      list [catch {info c} msg] $msg
! } {1 {ambiguous option "c": must be args, body, cmdcount, commands, complete, default, exists, fullargs, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-21.4 {miscellaneous error conditions} {
      list [catch {info l} msg] $msg
! } {1 {ambiguous option "l": must be args, body, cmdcount, commands, complete, default, exists, fullargs, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
! test info-21.5 {miscellaneous error conditions} {
      list [catch {info s} msg] $msg
! } {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, fullargs, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
  
  # cleanup
  catch {namespace delete test_ns_info1 test_ns_info2}