| … | … | @@ -14,7 +14,7 @@ |
| 14 | 14 | ; but, for convenience, we just use Postgres for now. |
| 15 | 15 | (define sto (PostgresStorageNode |
| 16 | 16 | "postgres:///opencog_test?user=opencog_tester&password=cheese")) |
| 17 | (cog-open sto) | |
| 17 | (cog-set-value! sto (*-open-*)) | |
| 18 | 18 | (cog-erase! sto) |
| 19 | 19 | |
| 20 | 20 | (define fvof (FetchValueOf (Concept "a") (Predicate "foo") sto)) |
| … | … | @@ -36,7 +36,7 @@ |
| 36 | 36 | (test-assert "Reset" (equal? fv (cog-execute! fvof))) |
| 37 | 37 | |
| 38 | 38 | (cog-erase! sto) |
| 39 | (cog-close sto) | |
| 39 | (cog-set-value! sto (*-close-*)) | |
| 40 | 40 | (test-end tname) |
| 41 | 41 | |
| 42 | 42 | (opencog-test-end) |
| … | … | @@ -41,12 +41,12 @@ |
| 41 | 41 | (define wnull (WriteThruProxy "wnull")) |
| 42 | 42 | (cog-set-value! wnull parts (NullProxy "bar")) |
| 43 | 43 | |
| 44 | (cog-open wnull) | |
| 45 | (store-atom (Concept "boffo")) | |
| 46 | (cog-close wnull) | |
| 44 | (cog-set-value! wnull (*-open-*)) | |
| 45 | (cog-set-value! wnull (*-store-atom-*) (Concept "boffo")) | |
| 46 | (cog-set-value! wnull (*-close-*)) | |
| 47 | 47 | |
| 48 | 48 | (set! caught #f) |
| 49 | (catch 'C++-EXCEPTION (lambda () (store-atom (Concept "boffo"))) | |
| 49 | (catch 'C++-EXCEPTION (lambda () (cog-set-value! wnull (*-store-atom-*) (Concept "boffo"))) | |
| 50 | 50 | (lambda (key funcname msg) |
| 51 | 51 | (format #t "Yes, we got the exception as expected\n") |
| 52 | 52 | (set! caught #t))) |
| … | … | @@ -63,12 +63,12 @@ |
| 63 | 63 | (NullProxy "bar") |
| 64 | 64 | (NullProxy "baz"))) |
| 65 | 65 | |
| 66 | (cog-open wmulti) | |
| 67 | (store-atom (Concept "boffo")) | |
| 68 | (cog-close wmulti) | |
| 66 | (cog-set-value! wmulti (*-open-*)) | |
| 67 | (cog-set-value! wmulti (*-store-atom-*) (Concept "boffo")) | |
| 68 | (cog-set-value! wmulti (*-close-*)) | |
| 69 | 69 | |
| 70 | 70 | (set! caught #f) |
| 71 | (catch 'C++-EXCEPTION (lambda () (store-atom (Concept "boffo"))) | |
| 71 | (catch 'C++-EXCEPTION (lambda () (cog-set-value! wmulti (*-store-atom-*) (Concept "boffo"))) | |
| 72 | 72 | (lambda (key funcname msg) |
| 73 | 73 | (format #t "Yes, we got the exception as expected\n") |
| 74 | 74 | (set! caught #t))) |
| … | … | @@ -82,15 +82,15 @@ |
| 82 | 82 | (define rnull (ReadThruProxy "wnull")) |
| 83 | 83 | (cog-set-value! rnull parts (NullProxy "bar")) |
| 84 | 84 | |
| 85 | (cog-open rnull) | |
| 86 | (fetch-atom (Concept "b1")) | |
| 87 | (fetch-atom (Concept "b2")) | |
| 88 | (fetch-atom (Concept "b3")) | |
| 89 | (fetch-atom (Concept "b4")) | |
| 90 | (cog-close rnull) | |
| 85 | (cog-set-value! rnull (*-open-*)) | |
| 86 | (cog-set-value! rnull (*-fetch-atom-*) (Concept "b1")) | |
| 87 | (cog-set-value! rnull (*-fetch-atom-*) (Concept "b2")) | |
| 88 | (cog-set-value! rnull (*-fetch-atom-*) (Concept "b3")) | |
| 89 | (cog-set-value! rnull (*-fetch-atom-*) (Concept "b4")) | |
| 90 | (cog-set-value! rnull (*-close-*)) | |
| 91 | 91 | |
| 92 | 92 | (set! caught #f) |
| 93 | (catch 'C++-EXCEPTION (lambda () (fetch-atom (Concept "boffo"))) | |
| 93 | (catch 'C++-EXCEPTION (lambda () (cog-set-value! rnull (*-fetch-atom-*) (Concept "boffo"))) | |
| 94 | 94 | (lambda (key funcname msg) |
| 95 | 95 | (format #t "Yes, we got the exception as expected\n") |
| 96 | 96 | (set! caught #t))) |
| … | … | @@ -107,17 +107,17 @@ |
| 107 | 107 | (NullProxy "bar") |
| 108 | 108 | (NullProxy "baz"))) |
| 109 | 109 | |
| 110 | (cog-open rmulti) | |
| 111 | (fetch-atom (Concept "b1")) | |
| 112 | (fetch-atom (Concept "b2")) | |
| 113 | (fetch-atom (Concept "b3")) | |
| 114 | (fetch-atom (Concept "b4")) | |
| 115 | (fetch-atom (Concept "b5")) | |
| 116 | (fetch-atom (Concept "b6")) | |
| 117 | (cog-close rmulti) | |
| 110 | (cog-set-value! rmulti (*-open-*)) | |
| 111 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b1")) | |
| 112 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b2")) | |
| 113 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b3")) | |
| 114 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b4")) | |
| 115 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b5")) | |
| 116 | (cog-set-value! rmulti (*-fetch-atom-*) (Concept "b6")) | |
| 117 | (cog-set-value! rmulti (*-close-*)) | |
| 118 | 118 | |
| 119 | 119 | (set! caught #f) |
| 120 | (catch 'C++-EXCEPTION (lambda () (fetch-atom (Concept "boffo"))) | |
| 120 | (catch 'C++-EXCEPTION (lambda () (cog-set-value! rmulti (*-fetch-atom-*) (Concept "boffo"))) | |
| 121 | 121 | (lambda (key funcname msg) |
| 122 | 122 | (format #t "Yes, we got the exception as expected\n") |
| 123 | 123 | (set! caught #t))) |
| … | … | @@ -20,20 +20,20 @@ |
| 20 | 20 | (define wsto (WriteThruProxy "writer")) |
| 21 | 21 | (cog-set-value! wsto (Predicate "*-proxy-parts-*") sto) |
| 22 | 22 | |
| 23 | (cog-open wsto) | |
| 23 | (cog-set-value! wsto (*-open-*)) | |
| 24 | 24 | (define b1 (Concept "b1")) |
| 25 | 25 | (cog-set-value! b1 (Predicate "*-TruthValueKey-*") (FloatValue 0.1 0.1)) |
| 26 | (store-atom b1) | |
| 26 | (cog-set-value! wsto (*-store-atom-*) b1) | |
| 27 | 27 | (define b2 (Concept "b2")) |
| 28 | 28 | (cog-set-value! b2 (Predicate "*-TruthValueKey-*") (FloatValue 0.2 0.2)) |
| 29 | (store-atom b2) | |
| 29 | (cog-set-value! wsto (*-store-atom-*) b2) | |
| 30 | 30 | (define b3 (Concept "b3")) |
| 31 | 31 | (cog-set-value! b3 (Predicate "*-TruthValueKey-*") (FloatValue 0.3 0.3)) |
| 32 | (store-atom b3) | |
| 32 | (cog-set-value! wsto (*-store-atom-*) b3) | |
| 33 | 33 | (define b4 (Concept "b4")) |
| 34 | 34 | (cog-set-value! b4 (Predicate "*-TruthValueKey-*") (FloatValue 0.4 0.4)) |
| 35 | (store-atom b4) | |
| 36 | (cog-close wsto) | |
| 35 | (cog-set-value! wsto (*-store-atom-*) b4) | |
| 36 | (cog-set-value! wsto (*-close-*)) | |
| 37 | 37 | |
| 38 | 38 | ; ---------------------------- |
| 39 | 39 | ; Now, read it back. |
| … | … | @@ -46,12 +46,12 @@ |
| 46 | 46 | (define rsto (ReadThruProxy "reader")) |
| 47 | 47 | (cog-set-value! rsto (Predicate "*-proxy-parts-*") sto) |
| 48 | 48 | |
| 49 | (cog-open rsto) | |
| 50 | (fetch-atom (Concept "b1")) | |
| 51 | (fetch-atom (Concept "b2")) | |
| 52 | (fetch-atom (Concept "b3")) | |
| 53 | (fetch-atom (Concept "b4")) | |
| 54 | (cog-close rsto) | |
| 49 | (cog-set-value! rsto (*-open-*)) | |
| 50 | (cog-set-value! rsto (*-fetch-atom-*) (Concept "b1")) | |
| 51 | (cog-set-value! rsto (*-fetch-atom-*) (Concept "b2")) | |
| 52 | (cog-set-value! rsto (*-fetch-atom-*) (Concept "b3")) | |
| 53 | (cog-set-value! rsto (*-fetch-atom-*) (Concept "b4")) | |
| 54 | (cog-set-value! rsto (*-close-*)) | |
| 55 | 55 | |
| 56 | 56 | (test-approximate "b1" 0.1 (cog-mean (Concept "b1")) 1.0e-8) |
| 57 | 57 | (test-approximate "b2" 0.2 (cog-mean (Concept "b2")) 1.0e-8) |
| … | … | @@ -32,27 +32,27 @@ |
| 32 | 32 | |
| 33 | 33 | ; Store some individual Atoms, and then store everything. |
| 34 | 34 | (define wfsn (FileStorageNode fname)) |
| 35 | (cog-open wfsn) | |
| 35 | (cog-set-value! wfsn (*-open-*)) | |
| 36 | 36 | |
| 37 | 37 | ; Store just one Atom. |
| 38 | (store-atom wa wfsn) | |
| 38 | (cog-set-value! wfsn (*-store-atom-*) wa) | |
| 39 | 39 | |
| 40 | 40 | ; Store just one value on an Atom. Store it three times; |
| 41 | 41 | ; it will show up in the file three times. |
| 42 | 42 | (cog-set-value! wa (Predicate "num") (FloatValue 11 22 33)) |
| 43 | (store-value wa (Predicate "num") wfsn) | |
| 44 | (store-value wa (Predicate "num") wfsn) | |
| 45 | (store-value wa (Predicate "num") wfsn) | |
| 43 | (cog-set-value! wfsn (*-store-value-*) wa (Predicate "num")) | |
| 44 | (cog-set-value! wfsn (*-store-value-*) wa (Predicate "num")) | |
| 45 | (cog-set-value! wfsn (*-store-value-*) wa (Predicate "num")) | |
| 46 | 46 | |
| 47 | 47 | ; The file write might not occur until after the `barrier` call. |
| 48 | 48 | ; File writes are buffered by the operating system. |
| 49 | (barrier wfsn) | |
| 49 | (cog-set-value! wfsn (*-barrier-*) (cog-atomspace)) | |
| 50 | 50 | |
| 51 | 51 | ; Now store everything. This will appear after the writes above, |
| 52 | 52 | ; and will duplicate some of the earlier data. During file read, |
| 53 | 53 | ; later data in the file will take precedence over earlier data. |
| 54 | (store-atomspace wfsn) | |
| 55 | (cog-close wfsn) | |
| 54 | (cog-set-value! wfsn (*-store-atomspace-*) (cog-atomspace)) | |
| 55 | (cog-set-value! wfsn (*-close-*)) | |
| 56 | 56 | |
| 57 | 57 | (cog-atomspace-clear) |
| 58 | 58 | |
| … | … | @@ -60,9 +60,9 @@ |
| 60 | 60 | |
| 61 | 61 | ; Load everything from the file. |
| 62 | 62 | (define rfsn (FileStorageNode fname)) |
| 63 | (cog-open rfsn) | |
| 64 | (load-atomspace rfsn) | |
| 65 | (cog-close rfsn) | |
| 63 | (cog-set-value! rfsn (*-open-*)) | |
| 64 | (cog-set-value! rfsn (*-load-atomspace-*) (cog-atomspace)) | |
| 65 | (cog-set-value! rfsn (*-close-*)) | |
| 66 | 66 | |
| 67 | 67 | ; Verify the load |
| 68 | 68 | (cog-prt-atomspace) |