Last active
April 25, 2025 01:30
-
-
Save GiuseppeChillemi/abe4696bfd3a494a2f594fd95f7c627d to your computer and use it in GitHub Desktop.
Test for ARG types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Red [] | |
Rebol [ | |
Title: "Args Test" | |
Notes: { | |
https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#literal-arguments-and-get-arguments | |
https://github.com/red/red/issues/1850 | |
https://github.com/red/red/issues/2622 | |
https://github.com/red/red/issues/3840 | |
} | |
Version: 1.3 | |
Log: { | |
Commented every test, uncomment what you want | |
Removed some output parts because they could confuse. Now test output is short and coincise | |
Some test line had QUOTE removed because LIT-ARG would treat it as argument | |
Added an arg to print the arg line before and after modifications | |
Fixed some problemis the sequence of DO/COMPOSE | |
} | |
] | |
;--- Stub for test --- | |
z: %testfile.txt | |
test: func [a aa 'a-lit 'aa-lit :a-get :aa-get arg* g* line* line1*] [ | |
Print "--Direct args--" | |
Print "" | |
Print ["Specs: [a aa 'a-lit 'aa-lit :a-get :aa-get arg* g* line* line1* ]"] | |
Print [" ARG1 ARG2 ARG3 ARG4 ARG5 ARG6"] | |
Print "" | |
Print [" G:" :g* ] | |
print ["Arg Creator: DO" mold :arg*] | |
print [" Line1:" mold :line1*] | |
print [" Line:" mold :line*] | |
;Prin ["Spec: "] probe mold spec-of context? 'a | |
Print "" | |
Prin rejoin ["ARG1-SPECS: a >> " tab type? :a " " tab] probe :a | |
Prin rejoin ["ARG2-SPECS: aa >> " tab type? :aa " " tab] probe :aa | |
Print [lf lf] | |
Print "--Lit args--" | |
Print "" | |
Prin rejoin ["ARG3-SPECS: 'a-lit >> " tab type? :a-lit " " tab] probe :a-lit | |
Prin rejoin ["ARG4-SPECS: 'aa-lit >> " tab type? :aa-lit " " tab] probe :aa-lit | |
Print [lf lf] | |
Print "--Get args--" | |
;--- Comment the following 2 in REBOL2 | |
Prin rejoin ["ARG5-SPECS: :a-get >> " tab type? :a-get " " tab] probe :a-get | |
Prin rejoin ["ARG6-SPECS: :aa-get >> " tab type? :aa-get " " tab] probe :aa-get | |
Print [lf lf] | |
] | |
;--- Stub for table making | |
;in-line | args-specs | probe | type? :a (rebol2) | type? a (rebol2) (probe) | output (rebol2) | type? :a (rebol3) | type? a (rebol3) (probe) | output (rebol3) | |
;Print "********** Function **********" | |
;do arg: [g: func [][1 + 1]] | |
;do line: line1: [test g :g g :g g :g :arg mold :g line line1] | |
;print rejoin [lf " ::Direct by parens ARGS::" lf] | |
;do line: compose/only line1: [test (g) (:g) (g) (:g) (g) (:g) :arg mold :g line line1] | |
;print rejoin [lf " ::Direct by Quoted parens ARGS::" lf] | |
;do line: compose/only line1: [test quote (g) quote (:g) (g) (:g) (g) (:g) :arg mold :g line line1] | |
;Print "" | |
; | |
;Print "********** Quoted paren **********" | |
;do arg: [g: quote (3 + 3)] | |
;do line: line1: [test g :g g :g g :g :arg mold :g line line1] | |
;print rejoin [lf " ::Composed in paren (g) (:g) RESULT + FUNCTION ARGS::" lf] | |
;do line: compose/only line1: [test (g) (:g) (g) (:g) (g) (:g) :arg mold :g line line1] | |
;print rejoin [lf " ::Quoted in paren quote (g) quote (:g) RESULT + FUNCTION::" lf] | |
;do line: compose/only line1: [test quote (g) quote (:g) (g) (:g) (g) (:g) :arg mold :g line line1] | |
;Print "" | |
; | |
; | |
;Print "********** Composed function **********" | |
;do arg: [f: func [][1 + 1] g: compose [(:f)]] | |
;do line: line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: (g/1) (:g/1) pointing to function (result + function when composed)" lf] | |
;do line: compose/only line1: [test (g/1) (:g/1) (g/1) (:g/1) (g/1) (:g/1) :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: g/1 :g/1 - pointing to function" lf] | |
;do line: compose/only line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;Print "" | |
; | |
;Print "********** Reduced function **********" | |
;do arg: [f: func [][1 + 1] g: reduce [:f]] | |
;do line: line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: (g/1) (:g/1) pointing to function (result + function when composed)" lf] | |
;do line: compose/only line1: [test (g/1) (:g/1) (g/1) (:g/1) (g/1) (:g/1) :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: g/1 :g/1 - pointing to function" lf] | |
;do line: compose/only line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;Print "" | |
;; | |
; | |
;Print "********** Paren in block **********" | |
;do arg: [f: quote (3 + 3) g: reduce [:f]] | |
;do line: line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: (g/1) (:g/1) pointing to paren (result + paren)" lf] | |
;do line: compose/only line1: [test (g/1) (:g/1) (g/1) (:g/1) (g/1) (:g/1) :arg mold :g line line1] | |
;print rejoin [lf " ::ARGS: g/1 :g/1 - pointing to paren" lf] | |
;do line: line1: [test g/1 :g/1 g/1 :g/1 g/1 :g/1 :arg mold :g line line1] | |
;Print "" | |
halt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment