<commit_before>REBOL [
  Title:   "Generates Red/System float! tests"
	Author:  "<NAME>"
	File: 	 %make-float-auto-test.r
	Version: 0.1.0
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
]

;; initialisations 
tests: copy ""                          ;; string to hold generated tests
test-number: 0                          ;; number of the generated test
make-dir %auto-tests/
file-out: %auto-tests/float-auto-test.reds

;; create a block of values to be used in the binary ops tests
test-values: [
            0.0                   
  -2147483648.0                   
   2147483647.0
           -1.0
            3.0
           -7.0
            5.0
       123456.7890
            1.222090944E+33
            9.99999E-45
            7.7E18
]

tol: 1e-4   

;; create blocks of operators to be applied
test-binary-ops: [
  +
  -
  *
  /
  //
 "%"
]

test-comparison-ops: [
  =
  <>
  <
  >
  >=
  <=
]

test-comparison-values: [
  -1E-13
  0.0
  +1E-13
]

;; create test file with header
append tests "Red/System [^(0A)"
append tests {  Title:   "Red/System auto-generated float! tests"^(0A)}
append tests {	Author:  "<NAME>"^(0A)}
append tests {  File: 	 %float-auto-test.reds^(0A)}
append tests {  License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"^(0A)}
append tests "]^(0A)^(0A)"
append tests "^(0A)^(0A)comment {"
append tests "  This file is generated by make-float-auto-test.r^(0A)"
append tests "  Do not edit this file directly.^(0A)"
append tests "}^(0A)^(0A)"
append tests join ";make-length:" 
                  [length? read %make-float-auto-test.r "^(0A)^(0A)"]
append tests "#include %../../../../../quick-test/quick-test.reds^(0A)^(0A)"
append tests {~~~start-file~~~ "Auto-generated tests for integers"^(0A)^(0A)}
append tests {===start-group=== "Auto-generated tests for integers"^(0A)^(0A)}

write file-out tests
tests: copy ""

;; binary operator tests - in global context
foreach op test-binary-ops [
  foreach operand1 test-values [
    foreach operand2 test-values [
      ;; only write a test if REBOL produces a result
      if attempt [
        either op = "%" [
          expected: do reduce [round remainder operand1 operand2]
        ][
          expected: to decimal! do reduce [operand1 op operand2]
        ]
      ][
        ;; test with literal values
        test-number: test-number + 1
        append tests join {  --test-- "float-auto-} [test-number {"^(0A)}]
        either op <> "%" [
          append tests "  --assertf~= "
          append tests reform [expected " (" operand1 op operand2 ") " tol "^(0A)"]
        ][
          append tests "  --assert "
          append tests reform [expected "= (" operand1 op operand2 ") ^(0A)"]
        ]
        
        
        ;; test with variables
        test-number: test-number + 1
        append tests join {  --test-- "float-auto-} [test-number {"^(0A)}]
        append tests join "      i: " [operand1 "^(0A)"]
        append tests join "      j: " [operand2 "^(0A)"]
        append tests rejoin ["      k:  i " op " j^(0A)"]
        either op <> "%" [
          append tests "  --assertf~= "
          append tests reform [expected " k " tol "^(0A)"]
        ][
          append tests "  --assert "
          append tests reform [expected "= k ^(0A)"]
        ]
        
           
        ;; write tests to file
        write/append file-out tests
        tests: copy ""
      ]
      recycle<commit_msg>TESTS: changed float-auto tests to meet revised spec<commit_after>REBOL [
  Title:   "Generates Red/System float! tests"
	Author:  "<NAME>"
	File: 	 %make-float-auto-test.r
	Version: 0.1.0
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
]

;; initialisations 
tests: copy ""                          ;; string to hold generated tests
test-number: 0                          ;; number of the generated test
make-dir %auto-tests/
file-out: %auto-tests/float-auto-test.reds

;; create a block of values to be used in the binary ops tests
test-values: [
            0.0                   
  -2147483648.0                   
   2147483647.0
           -1.0
            3.0
           -7.0
            5.0
       123456.7890
            1.222090944E+33
            9.99999E-45
            7.7E18
]

tol: 1e-4   

;; create blocks of operators to be applied
test-binary-ops: [
  +
  -
  *
  /
  //
 "%"
]

test-comparison-ops: [
  =
  <>
  <
  >
  >=
  <=
]

test-comparison-values: [
  -1E-13
  0.0
  +1E-13
]

;; create test file with header
append tests "Red/System [^(0A)"
append tests {  Title:   "Red/System auto-generated float! tests"^(0A)}
append tests {	Author:  "<NAME>"^(0A)}
append tests {  File: 	 %float-auto-test.reds^(0A)}
append tests {  License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"^(0A)}
append tests "]^(0A)^(0A)"
append tests "^(0A)^(0A)comment {"
append tests "  This file is generated by make-float-auto-test.r^(0A)"
append tests "  Do not edit this file directly.^(0A)"
append tests "}^(0A)^(0A)"
append tests join ";make-length:" 
                  [length? read %make-float-auto-test.r "^(0A)^(0A)"]
append tests "#include %../../../../../quick-test/quick-test.reds^(0A)^(0A)"
append tests {~~~start-file~~~ "Auto-generated tests for integers"^(0A)^(0A)}
append tests {===start-group=== "Auto-generated tests for integers"^(0A)^(0A)}

write file-out tests
tests: copy ""

;; binary operator tests - in global context
foreach op test-binary-ops [
  foreach operand1 test-values [
    foreach operand2 test-values [
      ;; only write a test if REBOL produces a result
      if attempt [
        either op = "%" [
          expected: to decimal! do reduce [remainder operand1 operand2]
        ][
          expected: to decimal! do reduce [operand1 op operand2]
        ]
      ][
        ;; test with literal values
        test-number: test-number + 1
        append tests join {  --test-- "float-auto-} [test-number {"^(0A)}]
        append tests "  --assertf~= "
        append tests reform [expected " (" operand1 op operand2 ") " tol "^(0A)"]
        
        ;; test with variables
        test-number: test-number + 1
        append tests join {  --test-- "float-auto-} [test-number {"^(0A)}]
        append tests join "      i: " [operand1 "^(0A)"]
        append tests join "      j: " [operand2 "^(0A)"]
        append tests rejoin ["      k:  i " op " j^(0A)"]
        append tests "  --assertf~= "
        append tests reform [expected " k " tol "^(0A)"]
           
        ;; write tests to file
        write/append file-out tests
        tests: copy ""
      ]
      recycle
{'fraction_non_alphanumeric': 0.14946777054997043, 'fraction_numerical': 0.0384387936132466, 'mean_word_length': 2.0120213713268034, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 4, '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': '2270000', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2235, 'n_words': 607}