<commit_before>Red/System [
	Title:   "Red/System math mixed tests script"
	Author:  "<NAME>"
	File: 	 %math-mixed-test.reds
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
]

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

~~~start-file~~~ "math-mixed"


===start-group=== "Simple nested expressions"

	a: 1
	b: 2
	c: 3

	--test-- "math-nested-1"
	--assert 1 + (3 - 2) = 2

	--test-- "math-nested-2"
	--assert a + (3 - 2) = 2

	--test-- "math-nested-3"
	--assert a + (3 - b) = 2

	--test-- "math-nested-4"
	--assert a + (c - 2) = 2

	--test-- "math-nested-5"
	--assert a + (c - b) = b

	--test-- "math-nested-6"
	--assert (3 - 1) + (3 - 2) = 3

	--test-- "math-nested-7"
	--assert (c - a) + (c - b) = c

	--test-- "math-nested-8"
	--assert ((3 - 1) - (3 - 2)) - ((3 - 1) - (3 - 2)) = 0

	--test-- "math-nested-9"
	--assert ((c - a) - (c - b)) - ((c - a) - (c - b)) = 0

	foo-nested: func [
		/local a b c
	][
		a: 2
		b: 3
		c: 4

		--test-- "loc-math-nested-1"
		--assert 1 + (3 - 2) = 2

		--test-- "loc-math-nested-2"
		--assert a + (3 - 2) = 3

		--test-- "loc-math-nested-3"
		--assert a + (3 - b) = 2

		--test-- "loc-math-nested-4"
		--assert a + (c - 2) = 4

		--test-- "loc-math-nested-5"
		--assert a + (c - b) = b

		--test-- "loc-math-nested-6"
		--assert (3 - 1) + (3 - 2) = 3

		--test-- "loc-math-nested-7"
		--assert (c - a) + (c - b) = b
<commit_msg>TESTS: new math with sub-expressions tests<commit_after>Red/System [
	Title:   "Red/System math mixed tests script"
	Author:  "<NAME>"
	File: 	 %math-mixed-test.reds
	Rights:  "Copyright (C) 2011 <NAME>. All rights reserved."
	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
]

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

~~~start-file~~~ "math-mixed"


===start-group=== "Simple nested expressions"

	ident: func [i [integer!] return: [integer!]][i]
	
	a: 1
	b: 2
	c: 3

	--test-- "math-nested-1"
	--assert 1 + (3 - 2) = 2

	--test-- "math-nested-2"
	--assert a + (3 - 2) = 2

	--test-- "math-nested-3"
	--assert a + (3 - b) = 2

	--test-- "math-nested-4"
	--assert a + (c - 2) = 2

	--test-- "math-nested-5"
	--assert a + (c - b) = b

	--test-- "math-nested-6"
	--assert (3 - 1) + (3 - 2) = 3

	--test-- "math-nested-7"
	--assert (c - a) + (c - b) = c

	--test-- "math-nested-8"
	--assert ((3 - 1) - (3 - 2)) - ((3 - 1) - (3 - 2)) = 0

	--test-- "math-nested-9"
	--assert ((c - a) - (c - b)) - ((c - a) - (c - b)) = 0
	
	--test-- "math-nested-10"
	--assert (3 * 1) + (3 * 2) = 9
	
	--test-- "math-nested-11"
	--assert (3 / 1) + (3 / 2) = 4
	
	--test-- "math-nested-12"
	--assert ((3 * 1) - (3 * 2)) * ((3 * 1) - (3 * 2)) = 9

	--test-- "math-nested-13"
	--assert (c * a) + (c * b) = 9
	
	--test-- "math-nested-14"
	--assert (3 * ident 1) + (3 * ident 2) = 9
	
	--test-- "math-nested-15"
	--assert ((ident 3) * ident 1) + ((ident 3) * ident 2) = 9
	

	foo-nested: func [
		/local a b c
	][
		a: 2
		b: 3
		c: 4

		--test-- "loc-math-nested-1"
		--assert 1 + (3 - 2) = 2

		--test-- "loc-math-nested-2"
		--assert a + (3 - 2) = 3

		--test-- "loc-math-nested-3"
		--assert a + (3 - b) = 2

		--test-- "loc-math-nested-4"
		--assert a + (c - 2) = 4

		--test-- "loc-math-nested-5"
		--assert a + (c - b) = b

		--test-- "loc-math-nested-6"
		--assert (3 - 1) + (3 - 2) = 3

		--test-- "loc-math-nested-7"
		--assert (c - a) + (c - b) = b

{'fraction_non_alphanumeric': 0.2606413994169096, 'fraction_numerical': 0.053061224489795916, 'mean_word_length': 1.7469975980784627, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4886297', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1533, 'n_words': 417}