aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/chaining_comparison_spec.yue
blob: f86cf5fc65ffa494de867fff9aff4b6e2049c05a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
describe "chaining comparison", ->
	it "should support simple chaining", ->
		assert.is_true 1 < 2 < 3
		assert.is_true 1 <= 2 <= 3
		assert.is_true 3 > 2 > 1
		assert.is_true 3 >= 2 >= 1

	it "should support complex chaining", ->
		assert.is_true 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 ~= 5

	it "should work with variables", ->
		a = 5
		assert.is_true 1 <= a <= 10
		assert.is_true a >= 3
		assert.is_true a <= 10

	it "should handle mixed comparisons", ->
		x = 5
		assert.is_true 1 < x < 10
		assert.is_true 1 <= x <= 5

	it "should work with string comparisons", ->
		assert.is_true "a" < "b" < "c"
		assert.is_true "a" <= "b" <= "c"

	it "should handle edge cases", ->
		assert.is_true 0 <= 0 <= 0
		assert.is_true -5 < 0 < 5

	it "should work in expressions", ->
		result = if 1 < 2 < 3
			"yes"
		else
			"no"
		assert.same result, "yes"

	it "should support != operator", ->
		assert.is_true 1 != 2 != 3
		assert.is_true 1 ~= 2 ~= 3

	it "should handle boolean results", ->
		assert.is_true 1 < 2 < 3
		assert.is_false 3 < 2 < 1

	it "should work with function calls", ->
		v = (x) -> x
		assert.is_true v(1) < v(2) < v(3)

	it "should handle negation", ->
		assert.is_true -10 < -5 < 0

	it "should support mixed operators", ->
		assert.is_true 1 < 2 <= 2 < 3
		assert.is_true 3 > 2 >= 2 > 1