]> gitweb.factorcode.org Git - factor.git/commitdiff
Tests of around-advice
authorJames Cash <james.nvc@gmail.com>
Thu, 6 Nov 2008 05:44:25 +0000 (00:44 -0500)
committerJames Cash <james.nvc@gmail.com>
Thu, 6 Nov 2008 05:44:25 +0000 (00:44 -0500)
extra/advice/advice-tests.factor

index 868f81cbe8c41ac349d7cca3899608c7e0591ab7..17b60c8fb1e85ff7ee2cf245a99249fa0ba9ecf8 100644 (file)
@@ -1,22 +1,40 @@
 ! Copyright (C) 2008 James Cash
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences tools.test advice parser ;
+USING: kernel sequences math tools.test advice parser namespaces ;
 IN: advice.tests
 
 [
 : foo "foo" ; 
 \ foo make-advised
  
- { "bar" "foo" } [
 { "bar" "foo" } [
      [ "bar" ] "barify" \ foo advise-before
      foo ] unit-test
  
- { "bar" "foo" "baz" } [
 { "bar" "foo" "baz" } [
       [ "baz" ] "bazify" \ foo advise-after
       foo ] unit-test
  
- { "foo" "baz" } [
 { "foo" "baz" } [
      "barify" \ foo before remove-advice
      foo ] unit-test
  
- ] with-interactive-vocabs
\ No newline at end of file
+: bar ( a -- b ) 1+ ;
+\ bar make-advised
+
+  { 11 } [
+     [ 2 * ] "double" \ bar advise-before
+     5 bar
+  ] unit-test 
+
+  { 11/3 } [
+      [ 3 / ] "third" \ bar advise-after
+      5 bar
+  ] unit-test
+
+  { -2 } [
+      [ -1 * ad-do-it 3 + ] "frobnobicate" \ bar advise-around
+      5 bar
+  ] unit-test
+ ] with-scope
\ No newline at end of file