<commit_before>Red/System [
	Title:   "Red/System simple testing framework"
	Author:  "<NAME>"
	File: 	 %quick-test.reds
	Version: 0.4.1
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt"
]

;; allocate string memory
qt-run-name:    "123456789012345678901234567890"
qt-file-name:   "123456789012345678901234567890"
qt-group-name:  "123456789012345678901234567890"
qt-test-name:   "123456789012345678901234567890"

;; counters
qt-run: declare struct! [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
]
qt-file: declare struct! [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
]
;; group switches
qt-group-name-not-printed: true
qt-group?: false

_qt-init-group: does [
  
  qt-group-name-not-printed: true
  qt-group?: false
  qt-group-name: ""
]

qt-init-run: func [] [
  qt-run/tests:     0
  qt-run/asserts:   0
  qt-run/passes:    0
  qt-run/failures:  0
  _qt-init-group
]

qt-init-file: func [] [
  qt-file/tests:     0
  qt-file/asserts:   0
  qt-file/passes:    0
  qt-file/failures:  0
  _qt-init-group
]

***start-run***: func[
    title [c-string!]
][
  qt-init-run
  qt-run-name: title
  prin "***Starting*** "
  print title
  print ""
]

~~~start-file~~~: func [
  title [c-string!]
][
  qt-init-file
  prin "~~~started test~~~ "
  print title
  qt-file-name: title
  qt-group?: false
]

===start-group===: func [
  title [c-string!]
][
  qt-group-name: title
  qt-group?: true
]

--test--: func [
  title [c-string!]
][
  qt-test-name: title
  qt-file/tests: qt-file/tests + 1
]

--assert: func [
  assertion [logic!]
][
  qt-file/asserts: qt-file/asserts + 1
  
  either assertion [
     qt-file/passes: qt-file/passes + 1
  ][
    qt-file/failures: qt-file/failures + 1
    if qt-group? [  
      if qt-group-name-not-printed [
        print ""
        prin "===group=== "
        print qt-group-name
        qt-group-name-not-printed: false
      ]
    ]
    prin "--test-- "
    prin qt-test-name
    print " FAILED**************"
  ]
]

===end-group===: func [] [
  _qt-init-group
]

~~~end-file~~~: func [] [
  print ""
  prin "~~~finished test~~~ "
  print qt-file-name
  qt-print-totals qt-file/tests
                  qt-file/asserts
                  qt-file/passes 
                  qt-file/failures
  print ""
  
  ;; update run totals
  qt-run/passes: qt-run/passes + qt-file/passes
  qt-run/asserts: qt-run/asserts + qt-file/asserts
  qt-run/failures: qt-run/failures + qt-file/failures
  qt-run/tests: qt-run/tests + qt-file/tests
]

***end-run***: func [][
  prin "***Finished*** "
  print qt-run-name
  qt-print-totals qt-run/tests
                  qt-run/asserts
                  qt-run/passes
                  qt-run/failures
]

qt-print-totals: func [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
][
  prin "  Number of Tests Performed:      "
  prin-int tests
  print ""
  prin "  Number of Assertions Performed: "
  prin-int asserts
  print ""
  prin "  Number of Assertions Passed:    "
  prin-int passes
  print ""
  prin "  Number of Assertions Failed:    "
  prin-int failures
  print ""
  if failures <> 0 [
    print "****************TEST FAILURES****************"
  ]
]

<commit_msg>Update quick-test.reds to Red/System v0.2.1<commit_after>Red/System [
	Title:   "Red/System simple testing framework"
	Author:  "<NAME>"
	File: 	 %quick-test.reds
	Version: 0.4.2
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt"
]

;; allocate string memory
qt-run-name:    "123456789012345678901234567890"
qt-file-name:   "123456789012345678901234567890"
qt-group-name:  "123456789012345678901234567890"
qt-test-name:   "123456789012345678901234567890"

;; counters
qt-run: declare struct! [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
]
qt-file: declare struct! [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
]
;; group switches
qt-group-name-not-printed: true
qt-group?: false

_qt-init-group: does [
  
  qt-group-name-not-printed: true
  qt-group?: false
  qt-group-name: ""
]

qt-init-run: func [] [
  qt-run/tests:     0
  qt-run/asserts:   0
  qt-run/passes:    0
  qt-run/failures:  0
  _qt-init-group
]

qt-init-file: func [] [
  qt-file/tests:     0
  qt-file/asserts:   0
  qt-file/passes:    0
  qt-file/failures:  0
  _qt-init-group
]

***start-run***: func[
    title [c-string!]
][
  qt-init-run
  qt-run-name: title
  print ["***Starting*** " title lf lf]
]

~~~start-file~~~: func [
  title [c-string!]
][
  qt-init-file
  print ["~~~started test~~~ " title lf]
  qt-file-name: title
  qt-group?: false
]

===start-group===: func [
  title [c-string!]
][
  qt-group-name: title
  qt-group?: true
]

--test--: func [
  title [c-string!]
][
  qt-test-name: title
  qt-file/tests: qt-file/tests + 1
]

--assert: func [
  assertion [logic!]
][
  qt-file/asserts: qt-file/asserts + 1
  
  either assertion [
     qt-file/passes: qt-file/passes + 1
  ][
    qt-file/failures: qt-file/failures + 1
    if qt-group? [  
      if qt-group-name-not-printed [
        print [lf "===group=== " qt-group-name]
        qt-group-name-not-printed: false
      ]
    ]
    print ["--test-- " qt-test-name " FAILED**************" lf]
  ]
]

===end-group===: func [] [
  _qt-init-group
]

~~~end-file~~~: func [] [
  print [lf "~~~finished test~~~ " qt-file-name lf]
  qt-print-totals qt-file/tests
                  qt-file/asserts
                  qt-file/passes 
                  qt-file/failures
  print lf
  
  ;; update run totals
  qt-run/passes: qt-run/passes + qt-file/passes
  qt-run/asserts: qt-run/asserts + qt-file/asserts
  qt-run/failures: qt-run/failures + qt-file/failures
  qt-run/tests: qt-run/tests + qt-file/tests
]

***end-run***: func [][
  print ["***Finished*** " qt-run-name lf]
  qt-print-totals qt-run/tests
                  qt-run/asserts
                  qt-run/passes
                  qt-run/failures
]

qt-print-totals: func [
  tests     [integer!]
  asserts   [integer!]
  passes    [integer!]
  failures  [integer!]
][
  print ["  Number of Tests Performed:      " tests lf]
  print ["  Number of Assertions Performed: " asserts lf]
  print ["  Number of Assertions Passed:    " passes lf]
  print ["  Number of Assertions Failed:    " failures lf]
  if failures <> 0 [
    print ["****************TEST FAILURES****************" lf]
  ]
]


{'fraction_non_alphanumeric': 0.1710188679245283, 'fraction_numerical': 0.04332075471698113, 'mean_word_length': 2.4727463312368974, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7547653', 'n_tokens_mistral': 2881, 'n_tokens_neox': 2578, 'n_words': 516}