@@ -450,6 +450,57 @@ Rebol [
450
450
451
451
===end-group===
452
452
453
+ ===start-group=== "AS coercion"
454
+
455
+ --test-- "AS datatype! any-string!"
456
+ s: "hell"
457
+ --assert file? f: as file! s
458
+ --assert email? e: as email! s
459
+ --assert url? u: as url! s
460
+ --assert tag? t: as tag! s
461
+ append s #"o"
462
+ --assert f = %hello
463
+ --assert e = to-email %hello
464
+ --assert u = #[url! "hello" ]
465
+ --assert t = <hello >
466
+
467
+ --test-- "AS datatype! any-block!"
468
+ b: [a b]
469
+ --assert paren? pa: as paren! b
470
+ --assert path? p: as path! b
471
+ --assert set-path? sp: as set-path! b
472
+ --assert get-path? gp: as get-path! b
473
+ --assert lit-path? lp: as lit-path! b
474
+ append b 'c
475
+ --assert pa = quote (a b c)
476
+ --assert p = quote a/b/c
477
+ --assert sp = quote a/b/c:
478
+ --assert gp = quote : a/b/c
479
+ --assert lp = quote 'a/b/c
480
+
481
+ --test-- "AS example any-string!"
482
+ s: "hell"
483
+ --assert file? f: as %file s
484
+ --assert email? e: as e@mail s
485
+ --assert url? u: as #[url! "" ] s
486
+ --assert tag? t: as <tag > s
487
+
488
+ --test-- "AS with protect"
489
+ b: protect [a b]
490
+ --assert path? try [p: as path! b]
491
+ --assert error? e: try [append b 'c]
492
+ --assert e/id = 'protected
493
+ --assert error? e: try [append p 'c]
494
+ --assert e/id = 'protected
495
+
496
+ --test-- "AS coercion error"
497
+ --assert error? e: try [as string! []]
498
+ --assert e/id = 'not-same-class
499
+ --assert error? e: try [as block! "" ]
500
+ --assert e/id = 'not-same-class
501
+
502
+ ===end-group===
503
+
453
504
;-- VECTOR related tests moved to %vector-test.r3
454
505
455
506
~~~end-file~~~
0 commit comments