llvm(self): compare/branch/jump/ret に self 先頭規約を導入 + 自己受検スモーク追加\n\n- lang/src/llvm_ir/instructions/{compare,branch,jump,ret}.hako self化\n- quick/core/{compare,branch,jump,ret}/self_param_* 追加\n\nsmokes(stage-b): OOB を map missing read まで拡張(寛容に観測)\n- selfhost_stageb_oob_vm.sh 更新
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Verify LLVMBranchInstructionBox.lower_branch requires self and returns JSON
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/result_checker.sh"
|
||||
|
||||
require_env || exit 2
|
||||
preflight_plugins || exit 2
|
||||
|
||||
test_self_param_branch() {
|
||||
local src='
|
||||
using "lang/src/llvm_ir/instructions/branch.hako" as B
|
||||
box Main { static method main() {
|
||||
local s = new B.LLVMBranchInstructionBox().lower_branch(3, 1, 2)
|
||||
if s.contains("\"op\":\"branch\"") && s.contains("\"then\":1") { print(1) } else { print(0) }
|
||||
} }
|
||||
'
|
||||
local out
|
||||
out=$(run_nyash_vm -c "$src" 2>&1)
|
||||
check_exact "1" "$out" "self_param_branch"
|
||||
}
|
||||
|
||||
run_test "self_param_branch" test_self_param_branch
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Verify LLVMCompareInstructionBox.lower_compare requires self and returns JSON
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/result_checker.sh"
|
||||
|
||||
require_env || exit 2
|
||||
preflight_plugins || exit 2
|
||||
|
||||
test_self_param_compare() {
|
||||
local src='
|
||||
using "lang/src/llvm_ir/instructions/compare.hako" as C
|
||||
box Main { static method main() {
|
||||
local s = new C.LLVMCompareInstructionBox().lower_compare("<", 1, 2, 3)
|
||||
if s.contains("\"op\":\"compare\"") && s.contains("\"operation\":\"<\"") { print(1) } else { print(0) }
|
||||
} }
|
||||
'
|
||||
local out
|
||||
out=$(run_nyash_vm -c "$src" 2>&1)
|
||||
check_exact "1" "$out" "self_param_compare"
|
||||
}
|
||||
|
||||
run_test "self_param_compare" test_self_param_compare
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Verify LLVMJumpInstructionBox.lower_jump requires self and returns JSON
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/result_checker.sh"
|
||||
|
||||
require_env || exit 2
|
||||
preflight_plugins || exit 2
|
||||
|
||||
test_self_param_jump() {
|
||||
local src='
|
||||
using "lang/src/llvm_ir/instructions/jump.hako" as J
|
||||
box Main { static method main() {
|
||||
local s = new J.LLVMJumpInstructionBox().lower_jump(5)
|
||||
if s.contains("\"op\":\"jump\"") && s.contains("\"target\":5") { print(1) } else { print(0) }
|
||||
} }
|
||||
'
|
||||
local out
|
||||
out=$(run_nyash_vm -c "$src" 2>&1)
|
||||
check_exact "1" "$out" "self_param_jump"
|
||||
}
|
||||
|
||||
run_test "self_param_jump" test_self_param_jump
|
||||
|
||||
24
tools/smokes/v2/profiles/quick/core/ret/self_param_ret_vm.sh
Normal file
24
tools/smokes/v2/profiles/quick/core/ret/self_param_ret_vm.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Verify LLVMRetInstructionBox.lower_return requires self and returns JSON
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/result_checker.sh"
|
||||
|
||||
require_env || exit 2
|
||||
preflight_plugins || exit 2
|
||||
|
||||
test_self_param_ret() {
|
||||
local src='
|
||||
using "lang/src/llvm_ir/instructions/ret.hako" as R
|
||||
box Main { static method main() {
|
||||
local s = new R.LLVMRetInstructionBox().lower_return(7)
|
||||
if s.contains("\"op\":\"ret\"") && s.contains("\"value\":7") { print(1) } else { print(0) }
|
||||
} }
|
||||
'
|
||||
local out
|
||||
out=$(run_nyash_vm -c "$src" 2>&1)
|
||||
check_exact "1" "$out" "self_param_ret"
|
||||
}
|
||||
|
||||
run_test "self_param_ret" test_self_param_ret
|
||||
|
||||
@ -81,5 +81,31 @@ test_oob_array_write() {
|
||||
run_test "stageb_oob_array_read" test_oob_array_read
|
||||
run_test "stageb_oob_array_write" test_oob_array_write
|
||||
|
||||
exit 0
|
||||
# Map missing key (read) — accept error or 'null' as pass for now
|
||||
test_oob_map_missing_read() {
|
||||
local code='box Main { static method main() { local m={"a":1}; print(m["zzz"]); } }'
|
||||
local json
|
||||
json=$(hako_compile_to_mir_stageb "$code") || return 0
|
||||
if out=$(NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 NYASH_NYRT_SILENT_RESULT=1 \
|
||||
"$ROOT/target/release/nyash" --json-file "$json" 2>&1); then
|
||||
local last
|
||||
last=$(printf '%s\n' "$out" | awk '/^(✅|ResultType|Result:)/{next} NF{last=$0} END{print last}')
|
||||
if [ "$last" = "null" ]; then
|
||||
log_success "map missing read returned null (accepted)"
|
||||
rm -f "$json"
|
||||
return 0
|
||||
else
|
||||
log_warn "map missing read returned '$last' (tolerated for now)"
|
||||
rm -f "$json"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
log_success "map missing read produced error (accepted)"
|
||||
rm -f "$json"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
run_test "stageb_oob_map_missing_read" test_oob_map_missing_read
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user