Index: library/nx/nx.tcl =================================================================== diff -u -r74b7a4066526ff5f5a8080ed907f71c9ed5c7700 -r8776580a91fa04fd52378dd37143f6c27769c8ab --- library/nx/nx.tcl (.../nx.tcl) (revision 74b7a4066526ff5f5a8080ed907f71c9ed5c7700) +++ library/nx/nx.tcl (.../nx.tcl) (revision 8776580a91fa04fd52378dd37143f6c27769c8ab) @@ -229,19 +229,16 @@ ###################################################################### ::nsf::method::create Class method { - name arguments:parameter,0..* -checkalways:switch -returns body -precondition -postcondition + name arguments:parameter,0..* -checkalways:switch -returns body } { - set conditions [list] - if {[info exists precondition]} {lappend conditions -precondition $precondition} - if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} set p [:__resolve_method_path $name] set p [dict filter $p script {k v} {expr {$k in {object regObject methodName}}}] dict with p { #puts "class method $object.$methodName [list $arguments] {...}" set r [::nsf::method::create $object \ -checkalways=$checkalways \ {*}[expr {$regObject ne "" ? "-reg-object [list $regObject]" : ""}] \ - $methodName $arguments $body {*}$conditions] + $methodName $arguments $body] if {$r ne ""} { # the method was not deleted ::nsf::method::property $object $r call-protected \ @@ -501,18 +498,15 @@ # - "forward" :public method "object method" { - name arguments:parameter,0..* -checkalways:switch -returns body -precondition -postcondition + name arguments:parameter,0..* -checkalways:switch -returns body } { - set conditions [list] - if {[info exists precondition]} {lappend conditions -precondition $precondition} - if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} array set "" [:__resolve_method_path -per-object $name] # puts "object method $(object).$(methodName) [list $arguments] {...}" set r [::nsf::method::create $(object) \ -checkalways=$checkalways \ {*}[expr {$(regObject) ne "" ? "-reg-object [list $(regObject)]" : ""}] \ -per-object \ - $(methodName) $arguments $body {*}$conditions] + $(methodName) $arguments $body] if {$r ne ""} { # the method was not deleted ::nsf::method::property $(object) $r call-protected \ @@ -878,8 +872,6 @@ return [string trimright "/cls/ [namespace tail $name] [: ::nsf::methods::class::info::method syntax $name]" { }] } :method "info method type" {name} {: ::nsf::methods::class::info::method type $name} - :method "info method precondition" {name} {: ::nsf::methods::class::info::method precondition $name} - :method "info method postcondition" {name} {: ::nsf::methods::class::info::method postcondition $name} :method "info method submethods" {name} {: ::nsf::methods::class::info::method submethods $name} :method "info method returns" {name} {: ::nsf::methods::class::info::method returns $name} } @@ -903,8 +895,6 @@ return [string trimright "/obj/ [namespace tail $name] [: ::nsf::methods::object::info::method syntax $name]" { }] } :method "info object method type" {name} {: ::nsf::methods::object::info::method type $name} - :method "info object method precondition" {name} {: ::nsf::methods::object::info::method precondition $name} - :method "info object method postcondition" {name} {: ::nsf::methods::object::info::method postcondition $name} :method "info object method submethods" {name} {: ::nsf::methods::object::info::method submethods $name} :method "info object method returns" {name} {: ::nsf::methods::object::info::method returns $name} } Index: tests/info-method.test =================================================================== diff -u -r74b7a4066526ff5f5a8080ed907f71c9ed5c7700 -r8776580a91fa04fd52378dd37143f6c27769c8ab --- tests/info-method.test (.../info-method.test) (revision 74b7a4066526ff5f5a8080ed907f71c9ed5c7700) +++ tests/info-method.test (.../info-method.test) (revision 8776580a91fa04fd52378dd37143f6c27769c8ab) @@ -67,7 +67,7 @@ nx::Class create C { :method m {x} {return proc-[self proc]} :object method mpo {} {return instproc-[self proc]} - :method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2 + # :method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2 :forward addOne expr 1 + :object forward add1 expr 1 + @@ -81,7 +81,7 @@ } C create c1 - ? {lsort [C info methods -callprotection all]} "a addOne m m-with-assertions s" + ? {lsort [C info methods -callprotection all]} "a addOne m s" #? {lsort [C info methods]} "a addOne s" foreach m [lsort [C info methods -callprotection all]] { ? [subst -nocommands {lsort [c1 info lookup methods $m]}] $m @@ -100,16 +100,16 @@ ? {C info method definition m} {::C public method m x {return proc-[self proc]}} ? {C info object method definition mpo} {::C public object method mpo {} {return instproc-[self proc]}} - if {$::nsf::config(assertions)} { - ? {C info method definition m-with-assertions} \ - {::C public method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2} - } else { - ? {C info method definition m-with-assertions} \ - {::C public method m-with-assertions {} {return proc-[self proc]}} - } + # if {$::nsf::config(assertions)} { + # ? {C info method definition m-with-assertions} \ + # {::C public method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2} + # } else { + # ? {C info method definition m-with-assertions} \ + # {::C public method m-with-assertions {} {return proc-[self proc]}} + # } ? {C info method parameters m} {x} ? {nx::Class info method parameters method} \ - {name arguments:parameter,0..* -checkalways:switch -returns body -precondition -postcondition} + {name arguments:parameter,0..* -checkalways:switch -returns body} ? {nx::Class info method parameters alias} \ {methodName -returns {-frame default} cmd} # raises currently an error @@ -138,7 +138,7 @@ ? {lsort [::nx::Object info lookup methods]} $class_methods ? {lsort [::nx::Class info lookup methods]} $class_methods ? {lsort [C info lookup methods -source application]} "add1 apo fpo mpo spo" - ? {lsort [c1 info lookup methods -source application]} "a addOne foo m m-with-assertions s" + ? {lsort [c1 info lookup methods -source application]} "a addOne foo m s" ? {lsort [C info lookup methods -source system]} $class_methods ? {lsort [c1 info lookup methods -source system]} $object_methods @@ -801,7 +801,7 @@ nx::test case parametersyntax { # a true method ? {::nx::Class info method syntax method} \ - "/cls/ method /name/ /arguments/ ?-checkalways? ?-returns /value/? /body/ ?-precondition /value/? ?-postcondition /value/?" + "/cls/ method /name/ /arguments/ ?-checkalways? ?-returns /value/? /body/" # a forwarder to ::nsf::relation; definition comes via array ::nsf::parametersyntax ? {::nx::Class info method syntax mixin} "/cls/ mixin ?/class .../?|?add /class/?|?delete /class/?" Index: tests/methods.test =================================================================== diff -u -r17b2bed824041ef05d7739b2151882d5f9ec1f88 -r8776580a91fa04fd52378dd37143f6c27769c8ab --- tests/methods.test (.../methods.test) (revision 17b2bed824041ef05d7739b2151882d5f9ec1f88) +++ tests/methods.test (.../methods.test) (revision 8776580a91fa04fd52378dd37143f6c27769c8ab) @@ -1084,37 +1084,39 @@ ? {e1 bar} bar } -nx::test case assertion-swallows-result { +nx::test case xotcl-assertion-swallows-result { - nx::Class create Edge { - :public method foo {} { - :configure -xxx 1 - } - :public method bar {} { - :configure -xxx 1 - } -postcondition {{1 == 0}} - :create e1 + package req XOTcl + + xotcl::Class create Edge + Edge instproc foo {} { + my set xxx } + Edge instproc bar {} { + my set xxx + } {} {{1 == 0}} + + Edge create e1 + # base case ? {catch {e1 foo} errMsg} 1 - ? {string match "invalid non-positional*" $errMsg} 1 + ? {string match {can't read "xxx":*} $errMsg} 1 ? {catch {e1 bar} errMsg} 1 - ? {string match "invalid non-positional*" $errMsg} 1 + ? {string match {can't read "xxx":*} $errMsg} 1 # turn on assertion checking nsf::method::assertion e1 check all # still report error when invariant would not return error ? {catch {e1 foo} errMsg} 1 - ? {string match "invalid non-positional*" $errMsg} 1 + ? {string match {can't read "xxx":*} $errMsg} 1 - # still report error when postcondition would not return error + # still report error when postcondition would return an error ? {catch {e1 bar} errMsg} 1 - ? {string match "invalid non-positional*" $errMsg} 1 - + ? {string match {can't read "xxx":*} $errMsg} 1 } Index: tests/parameters.test =================================================================== diff -u -r74b7a4066526ff5f5a8080ed907f71c9ed5c7700 -r8776580a91fa04fd52378dd37143f6c27769c8ab --- tests/parameters.test (.../parameters.test) (revision 74b7a4066526ff5f5a8080ed907f71c9ed5c7700) +++ tests/parameters.test (.../parameters.test) (revision 8776580a91fa04fd52378dd37143f6c27769c8ab) @@ -616,7 +616,7 @@ "query instparams with default, no paramdefs needed" ? {nx::Class info method parameters method} \ - "name arguments:parameter,0..* -checkalways:switch -returns body -precondition -postcondition" \ + "name arguments:parameter,0..* -checkalways:switch -returns body" \ "query instparams for scripted method 'method'" ? {nx::Object info method parameters ::nsf::method::forward} \