🚀 Phase 12.7-B: ChatGPT5糖衣構文(基本実装完了) - パイプライン演算子(|>)実装 - セーフアクセス(?.)とデフォルト値(??)実装 - sugar gateによる段階的有効化機能 - 糖衣構文テストスイート追加 🤖 自律型AI開発システム改善 - codex-async-notify.sh: タスク制御指示追加 - "下の箱を積み過ぎないように先に進んでください" - "フェーズが終わったと判断したら止まってください" - プロセス数表示機能の改善(count_running_codex_display) - 自動停止機能が正常動作(Phase 12.7-C前で停止確認) 📚 ドキュメント更新 - Paper 13: 自律型AI協調開発システムの革新性を文書化 - ANCP可逆マッピング仕様追加 - nyfmt PoC(フォーマッター)計画追加 🧱 箱理論の体現 - 74k行のコードベース(Phase 15で20k行を目指す) - ANCP適用で最終的に6k行相当を狙う - 世界最小の実用コンパイラへの道 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
2.3 KiB
Rust
50 lines
2.3 KiB
Rust
use crate::parser::entry_sugar::parse_with_sugar_level;
|
|
use crate::syntax::sugar_config::SugarLevel;
|
|
use crate::ast::ASTNode;
|
|
|
|
#[test]
|
|
fn safe_access_field_and_method() {
|
|
let code = "a = user?.profile\nb = user?.m(1)\n";
|
|
let ast = parse_with_sugar_level(code, SugarLevel::Basic).expect("parse ok");
|
|
|
|
let program = match ast { ASTNode::Program { statements, .. } => statements, other => panic!("expected program, got {:?}", other) };
|
|
assert_eq!(program.len(), 2);
|
|
|
|
// a = user?.profile
|
|
match &program[0] {
|
|
ASTNode::Assignment { value, .. } => match value.as_ref() {
|
|
ASTNode::PeekExpr { scrutinee, else_expr, .. } => {
|
|
match scrutinee.as_ref() { ASTNode::Variable { name, .. } => assert_eq!(name, "user"), _ => panic!("scrutinee not user") }
|
|
match else_expr.as_ref() {
|
|
ASTNode::FieldAccess { object, field, .. } => {
|
|
match object.as_ref() { ASTNode::Variable { name, .. } => assert_eq!(name, "user"), _ => panic!("object not user") }
|
|
assert_eq!(field, "profile");
|
|
}
|
|
other => panic!("else not field access, got {:?}", other),
|
|
}
|
|
}
|
|
other => panic!("expected PeekExpr, got {:?}", other),
|
|
}
|
|
other => panic!("expected assignment, got {:?}", other),
|
|
}
|
|
|
|
// b = user?.m(1)
|
|
match &program[1] {
|
|
ASTNode::Assignment { value, .. } => match value.as_ref() {
|
|
ASTNode::PeekExpr { scrutinee, else_expr, .. } => {
|
|
match scrutinee.as_ref() { ASTNode::Variable { name, .. } => assert_eq!(name, "user"), _ => panic!("scrutinee not user") }
|
|
match else_expr.as_ref() {
|
|
ASTNode::MethodCall { object, method, arguments, .. } => {
|
|
match object.as_ref() { ASTNode::Variable { name, .. } => assert_eq!(name, "user"), _ => panic!("object not user") }
|
|
assert_eq!(method, "m");
|
|
assert_eq!(arguments.len(), 1);
|
|
}
|
|
other => panic!("else not method call, got {:?}", other),
|
|
}
|
|
}
|
|
other => panic!("expected PeekExpr, got {:?}", other),
|
|
}
|
|
other => panic!("expected assignment, got {:?}", other),
|
|
}
|
|
}
|