Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Rebol Programming/assert

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

USAGE: ASSERT conditions /type DESCRIPTION: Assert that condition is true, else throw an assertion error. ASSERT is a function value. ARGUMENTS conditions -- (Type: block) REFINEMENTS /type -- Safely check datatypes of variables (words) (SPECIAL ATTRIBUTES) catch throw SOURCE CODE assert: func [ {Assert that condition is true, else throw an assertion error.} [catch throw] conditions [block!] /type "Safely check datatypes of variables (words)" /local w t ][throw-on-error [ either type [ parse conditions [any [ [set w word! | set w skip ( cause-error 'script 'invalid-arg type? get/any 'w )] [set t [block! | word!] ( unless find to-typeset t type? get/any w [ make error! join "datatype assertion failed for: " w ] ) | set t skip ( cause-error 'script 'invalid-arg type? get/any 't )] ]] ] [ any [ all conditions make error! join "assertion failed for: " mold conditions ] ] ]]