Skip to content

Commit

Permalink
tests(tup): migrate preexisting test (#74)
Browse files Browse the repository at this point in the history
Migrate the preexisting test for tuples, altering it to reflect that
assignment no longer performs a copy.

From the Con4m language reference [1]:

    Builtin types are either _value types_ or _reference types_. Value 
    types are limited to numeric and boolean types that can be
    represented in 64-bits or less. 

[1] https://github.com/crashappsec/libcon4m/blob/fa231d8f0962/doc/reference.md#builtin-types
  • Loading branch information
ee7 authored Jul 5, 2024
1 parent 332a2ab commit f46f639
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions tests/tup.c4m
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
"""
Basic test of tuples.
"""
"""
$output:
1
foo
3
1
blah
3
4
blah
3
4
blah
3
"""

x = (1, "foo", 3)
#assert x[0] == 1
#assert x[1] == "foo"
#assert x[2] == 3
print(x[0])
print(x[1])
print(x[2])

y = x
y[1] = "blah"

assert x[0] == 1
assert x[1] == "foo"
assert x[2] == 3
print(x[0])
print(x[1])
print(x[2])

x[0] = 4

assert y[0] == 1
assert y[1] == "blah"
assert y[2] == 3
print(y[0])
print(y[1])
print(y[2])

x[1] = y[1]

(a, b, c) = x

assert a == 4
assert b == "blah"
assert c == 3
print(a)
print(b)
print(c)

0 comments on commit f46f639

Please sign in to comment.