Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test/spec] Failing spec tests for rvalue dynamic var name in arith #670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions spec/arith.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,53 @@ xbar[5]=42
## END
## N-I dash status: 2
## N-I dash stdout-json: ""

#### ble.sh (dynamic var name with prefix): assign
vec2_set () {
local this=$1 x=$2 y=$3
: $(( ${this}_x = $2 ))
: $(( ${this}_y = y ))
}
vec2_set a 3 4
vec2_set b 5 12
echo a_x=$a_x a_y=$a_y
echo b_x=$b_x b_y=$b_y
## STDOUT:
a_x=3 a_y=4
b_x=5 b_y=12
## END

#### ble.sh (dynamic var name with prefix): read
vec2_load() {
local this=$1
x=$(( ${this}_x ))
: $(( y = ${this}_y ))
}
a_x=12 a_y=34
vec2_load a
echo x=$x y=$y
## STDOUT:
x=12 y=34
## END

#### ble.sh (dynamic var name with prefix): copy/add
vec2_copy () {
local this=$1 rhs=$2
: $(( ${this}_x = $(( ${rhs}_x )) ))
: $(( ${this}_y = ${rhs}_y ))
}
vec2_add () {
local this=$1 rhs=$2
: $(( ${this}_x += $(( ${rhs}_x )) ))
: $(( ${this}_y += ${rhs}_y ))
}
a_x=3 a_y=4
b_x=4 b_y=20
vec2_copy c a
echo c_x=$c_x c_y=$c_y
vec2_add c b
echo c_x=$c_x c_y=$c_y
## STDOUT:
c_x=3 c_y=4
c_x=7 c_y=24
## END
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ glob() {
}

arith() {
sh-spec spec/arith.test.sh --osh-failures-allowed 4 \
sh-spec spec/arith.test.sh --osh-failures-allowed 7 \
${REF_SHELLS[@]} $ZSH $OSH_LIST "$@"
}

Expand Down