diff options
Diffstat (limited to '')
-rw-r--r-- | cpp/sca/test/store-script/store-script.scm | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/cpp/sca/test/store-script/store-script.scm b/cpp/sca/test/store-script/store-script.scm new file mode 100644 index 0000000000..8af88b45f0 --- /dev/null +++ b/cpp/sca/test/store-script/store-script.scm @@ -0,0 +1,99 @@ + +(display "Currency implementation") + +(define (currency_convert from to amount) + (if (equal? to "EUR") (* amount 0.70) amount) +) + +(define (currency_symbol currency) + (if (equal? currency "EUR") "E" "$") +) + +(define (currency_impl op args) + (cond + ((equal? op "convert") (apply currency_convert args)) + ((equal? op "symbol") (apply currency_symbol args)) + ) +) + +(display "Currency composite") + +(define (currency_service op . args) (currency_impl op args)) + +(display "Catalog implementation") + +(define (catalog_get converter) + (define (convert price) (converter "convert" "USD" "USD" price)) + + (define code "USD") + (define symbol (converter "symbol" code)) + + (list (list "apple" code symbol (convert 2.99)) + (list "orange" code symbol (convert 3.55)) + (list "pear" code symbol (convert 1.55)) + ) +) + +(define (catalog_impl converter op args) + (cond + ((equal? op "get") (apply catalog_get (cons converter args))) + ) +) + +(display "Catalog composite") + +(define (catalog_service op . args) (catalog_impl currency_service op args)) + +(display "Cart implementation") + +(define (cart_post content item) + (cons item content) +) + +(define (cart_getall content) + content +) + +(define (cart_impl op args) + (cond + ((equal? op "post") (apply cart_post args)) + ((equal? op "getall") (apply cart_getall args)) + ) +) + +(display "Store UI implementation") + +(define (storeui_post cart content item) + (cart "post" content item) +) + +(define (storeui_getcart cart content) + (cart "getall" content) +) + +(define (storeui_getcatalog catalog) + (catalog "get") +) + +(define (storeui_impl cart catalog op args) + (cond + ((equal? op "post") (apply storeui_post (cons cart args))) + ((equal? op "getall") (apply storeui_getcart (cons cart args))) + ((equal? op "getcatalog") (apply storeui_getcatalog (cons catalog args))) + ) +) + +(display "Store UI composite") + +(define (cart_service op . args) (cart_impl op args)) + +(define (storeui_service op . args) (storeui_impl cart_service catalog_service op args)) + +(display "Store UI test case") + +(define catalog (storeui_service "getcatalog")) +(define empty (list)) +(define apple (car catalog)) +(define full (storeui_service "post" empty apple)) +(display (storeui_service "getall" full)) + |