REBOL [
  Title:   "Generates Red not equal? tests"
	Author:  "Peter W A Wood"
	File: 	 %make-non-equal-auto-test.r
	Version: 0.1.0
	Tabs:	 4
	Rights:  "Copyright (C) 2011-2015 Peter W A Wood. All rights reserved."
	License: "BSD-3 - https://github.com/red/red/blob/origin/BSD-3-License.txt"
]

;; initialisations 

make-dir %auto-tests/
infix-file: %auto-tests/infix-not-equal-auto-test.red
prefix-file: %auto-tests/not-equal-auto-test.red

test-src: {
Red [
	Title:   "Red infix or prefix not equal test script"
	Author:  "Nenad Rakocevic & Peter W A Wood"
	File: 	 ***FILE***
	Tabs:	 4
	Rights:  "Copyright (C) 2011-2015, Nenad Rakocevic & Peter W A Wood. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
]

comment {  This file is generated by make-not-equal-auto-test.r
  Do not edit this file directly.
}

;make-length:***MAKELENGTH***           

#include  %../../../../quick-test/quick-test.red

}

;;functions

group-title: ""                         ;; title of current group
group-test-no: 0                        ;; number of current test in group

add-not-equal-test: func [
  expected [string!]
  actual   [string!]
][
  add-test
  append infix-src join {--assert } [expected " <> " actual newline]
  append prefix-src join {--assert not-equal? } [expected " " actual newline]
]

add-not-not-equal-test: func [
  expected [string!]
  actual   [string!]
][
  add-test
  append infix-src join {--assert not } [expected " <> " actual newline]
  append prefix-src join {--assert not not-equal? } [expected " " actual newline]
]

add-test: func [] [
  group-test-no: group-test-no + 1
  append infix-src join {--test-- "infix-not-equal-} 
    [group-title "-" group-test-no {"} newline]
  append prefix-src join {--test-- "prefix-not-equal-} 
    [group-title "-" group-test-no {"} newline]
]

add-test-with-code: func [
  code        [string!]
  assertion   [string!]
][
  add-test
  append infix-src join code newline
  append prefix-src join code newline
  append infix-src join {--assert } [assertion newline]
  append prefix-src join {--assert } [assertion newline]
]
  
add-test-text: func [
  text  [string!]
][
  append infix-src join replace copy text "***FIX***" "infix" newline
  append prefix-src join replace copy text "***FIX***" "prefix" newline
]


start-group: func [
  title [string!]
][
  group-title: title
  group-test-no: 0
  add-test-text join {===start-group=== "} [title {"}]
]
  

;; processing 
replace test-src {***MAKELENGTH***} length? read %make-not-equal-auto-test.r
infix-src: copy test-src
replace infix-src {***FILE***} :infix-file
prefix-src: copy test-src
replace prefix-src {***FILE***} :prefix-file

add-test-text {~~~start-file~~~ "***FIX***-not-equal"}

start-group "same-datatype"
add-not-equal-test "0" "1"
add-not-equal-test "1" "0"
add-not-equal-test "FFFFFFFEh" "-1"
add-not-equal-test "[]" "[[]]"
add-not-equal-test "[a]" "[b]"
add-not-equal-test "[A]" "[b]"
add-not-equal-test "['a]" "['b]"
add-not-equal-test "[a:]" "[b:]"
add-not-equal-test "[:a]" "[b:]"
add-not-equal-test "[abcde]" "[abcdef]"
add-not-equal-test "[a b c d]" "[a c d]"
add-not-equal-test "[b c d]" "next [a b c d e]"
add-not-equal-test "[b c d]" "(next [a b c d e])"
add-not-equal-test {"a"} {"b"}
add-not-equal-test {"a"} {"B"}
add-not-equal-test {"abcdeè"} {"abcdeèf"}
add-not-equal-test {(next "abcdeè")} {next "abcdeèf"}
add-not-equal-test {(first "abcdeè")} {first "bcdeè"}
add-not-equal-test {(last "abcdeè")} {last "abcdeèf"}
add-not-equal-test {"abcde^^(2710)é^^(010000)"} {"abcde^^(2711)é^^(010000)"} 
;; need to escape the ^ as file is processed by REBOL
add-not-equal-test {[d]} {back tail [a b c d e]}
add-not-equal-test {"2345"} {next "123456"}
add-not-equal-test {#"z"} {#"Z"}
add-not-not-equal-test {#"z"} {#"z"}
add-not-not-equal-test {#"e"} {#"e"}
add-not-equal-test {#"^^(010000)"} {#"^^(010001)"}
add-not-equal-test {true} {false}
add-not-equal-test {false} {true}
add-not-not-equal-test {false} {false}
add-not-not-equal-test {true} {true}
add-not-equal-test {none} {"a"}
add-not-equal-test {'a} {'b}
add-not-equal-test {'a} {'B}
add-not-equal-test {(first [a])} {first [b]}
add-not-equal-test {'a} {first [B]}
add-not-equal-test {'a} {first ['b]}
add-not-equal-test {'a} {first [:b]}
add-not-equal-test {'a} {first [b:]}
add-not-equal-test {(first [a:])} {first [z:]}
add-not-equal-test {(first [:a])} {first [:z]}
add-not-equal-test {[a b c d e]} {first [[b c d e]]}
add-test-with-code {ea-result: 1 <> 1} {ea-result = false}
add-test-with-code {ea-result: 1 <> 0} {ea-result = true}
add-test-with-code {ea-result: not-equal? 1 1} {ea-result = false}
add-test-with-code {ea-result: not-equal? 1 0} {ea-result = true}
add-test-text {===end-group===}

start-group {implcit-cast}
add-not-equal-test {#"0"} {49}
add-not-equal-test {48} {#"1"}
add-not-equal-test {#"^^(2711)"} {10000}
add-not-equal-test {#"^^(010001)"} {65536}
add-test-with-code {ea-result: #"1" <> 49} {ea-result = false}
add-test-with-code {ea-result: not-equal? #"^^(01000)" 10000} {ea-result = true}
add-test-text {===end-group===}

add-test-text {~~~end-file~~~}

write infix-file infix-src
write prefix-file prefix-src

print "Not equal auto test files generated"

