# Copyright (c) reifydb.com 2025
# This file is licensed under the AGPL-3.0-or-later

# This file includes and modifies code from the toydb project (https://github.com/erikgrinaker/toydb),
# originally licensed under the Apache License, Version 2.0.
# Original copyright:
#   Copyright (c) 2024 Erik Grinaker
#
# The original Apache License can be found at:
#   http://www.apache.org/licenses/LICENSE-2.0

# Write some initial data.
set a=1
set b=2
set ba=21
set bb=22
set c=3
set C=3
---
ok

# Forward and reverse scans.
scan
---
"C" → "3"
"a" → "1"
"b" → "2"
"ba" → "21"
"bb" → "22"
"c" → "3"

scan reverse=true
---
"c" → "3"
"bb" → "22"
"ba" → "21"
"b" → "2"
"a" → "1"
"C" → "3"

# Inclusive and exclusive ranges.
scan b..bb
---
"b" → "2"
"ba" → "21"

scan "b..=bb"
---
"b" → "2"
"ba" → "21"
"bb" → "22"

scan "b..=bb" reverse=true
---
"bb" → "22"
"ba" → "21"
"b" → "2"

# Open ranges.
scan bb..
---
"bb" → "22"
"c" → "3"

scan "..=b"
---
"C" → "3"
"a" → "1"
"b" → "2"
