revise iso_conformity_tests.pl in response to new ambiguity check of #1860
This commit is contained in:
@@ -44,6 +44,15 @@ impl DirectedOp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_prefix(&self )-> bool {
|
||||||
|
match self {
|
||||||
|
&DirectedOp::Left(_name, cell) | &DirectedOp::Right(_name, cell) => {
|
||||||
|
is_prefix!(cell.get_spec() as u32)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_negative_sign(&self) -> bool {
|
fn is_negative_sign(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
@@ -604,7 +613,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
self.iter.pop_stack();
|
self.iter.pop_stack();
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(atom!("...")));
|
self.state_stack.push(TokenOrRedirect::Atom(atom!("...")));
|
||||||
self.state_stack.push(TokenOrRedirect::Space);
|
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(name));
|
self.state_stack.push(TokenOrRedirect::Atom(name));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -613,7 +621,13 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
let op = DirectedOp::Left(name, spec);
|
let op = DirectedOp::Left(name, spec);
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::CompositeRedirect(max_depth, op));
|
self.state_stack.push(TokenOrRedirect::CompositeRedirect(max_depth, op));
|
||||||
|
|
||||||
|
/*
|
||||||
|
if fetch_op_spec(name, 2, self.op_dir).is_some() {
|
||||||
self.state_stack.push(TokenOrRedirect::Space);
|
self.state_stack.push(TokenOrRedirect::Space);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(name));
|
self.state_stack.push(TokenOrRedirect::Atom(name));
|
||||||
} else {
|
} else {
|
||||||
match name.as_str() {
|
match name.as_str() {
|
||||||
@@ -938,13 +952,17 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn print_number(&mut self, max_depth: usize, n: NumberFocus, op: &Option<DirectedOp>) {
|
fn print_number(&mut self, max_depth: usize, n: NumberFocus, op: &Option<DirectedOp>) {
|
||||||
let add_brackets = if let Some(op) = op {
|
let (add_brackets, op_is_prefix) = if let Some(op) = op {
|
||||||
op.is_negative_sign() && !n.is_negative()
|
(op.is_negative_sign() && !n.is_negative(), op.is_prefix())
|
||||||
} else {
|
} else {
|
||||||
false
|
(false, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
if add_brackets {
|
if add_brackets {
|
||||||
|
if op_is_prefix && !self.outputter.ends_with(" ") {
|
||||||
|
push_char!(self, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
push_char!(self, '(');
|
push_char!(self, '(');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,13 +1351,15 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
|
|
||||||
if let Some(ref op) = &op {
|
if let Some(ref op) = &op {
|
||||||
if !self.outputter.ends_with(" ") {
|
if !self.outputter.ends_with(" ") {
|
||||||
if op.is_left() && requires_space(op.as_atom().as_str(), "(") {
|
if op.is_left() {
|
||||||
|
if op.is_prefix() || requires_space(op.as_atom().as_str(), "(") {
|
||||||
self.state_stack.push(TokenOrRedirect::Space);
|
self.state_stack.push(TokenOrRedirect::Space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn print_tcp_listener(&mut self, tcp_listener: &TcpListener, max_depth: usize) {
|
fn print_tcp_listener(&mut self, tcp_listener: &TcpListener, max_depth: usize) {
|
||||||
@@ -1457,7 +1477,9 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
|
|
||||||
if let Some(ref op) = op {
|
if let Some(ref op) = op {
|
||||||
if printer.outputter.ends_with(&format!(" {}", op.as_atom().as_str())) {
|
let op_is_prefix = op.is_prefix() && op.is_left();
|
||||||
|
|
||||||
|
if op_is_prefix || printer.outputter.ends_with(&format!(" {}", op.as_atom().as_str())) {
|
||||||
result.push(' ');
|
result.push(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,31 +265,31 @@ test_218 :- writeq_term_to_chars(-(1*2), Chars),
|
|||||||
Chars == "- (1*2)".
|
Chars == "- (1*2)".
|
||||||
|
|
||||||
test_140 :- writeq_term_to_chars(-a, Chars),
|
test_140 :- writeq_term_to_chars(-a, Chars),
|
||||||
Chars == "- a".
|
Chars == "-a".
|
||||||
|
|
||||||
test_184 :- writeq_term_to_chars(-(-), Chars),
|
test_184 :- writeq_term_to_chars(-(-), Chars),
|
||||||
Chars == "- (-)".
|
Chars == "- (-)".
|
||||||
|
|
||||||
test_185 :- writeq_term_to_chars(-[-], Chars),
|
test_185 :- writeq_term_to_chars(-[-], Chars),
|
||||||
Chars == "- [-]".
|
Chars == "-[-]".
|
||||||
|
|
||||||
test_188 :- writeq_term_to_chars(-p(c), Chars),
|
test_188 :- writeq_term_to_chars(-p(c), Chars),
|
||||||
Chars == "- p(c)".
|
Chars == "-p(c)".
|
||||||
|
|
||||||
test_189 :- writeq_term_to_chars(-{}, Chars),
|
test_189 :- writeq_term_to_chars(-{}, Chars),
|
||||||
Chars == "- {}".
|
Chars == "-{}".
|
||||||
|
|
||||||
test_190 :- writeq_term_to_chars(-{a}, Chars),
|
test_190 :- writeq_term_to_chars(-{a}, Chars),
|
||||||
Chars == "- {a}".
|
Chars == "-{a}".
|
||||||
|
|
||||||
test_191 :- writeq_term_to_chars(-(-a), Chars),
|
test_191 :- writeq_term_to_chars(-(-a), Chars),
|
||||||
Chars == "- - a".
|
Chars == "- -a".
|
||||||
|
|
||||||
test_192 :- writeq_term_to_chars(-(-(-a)), Chars),
|
test_192 :- writeq_term_to_chars(-(-(-a)), Chars),
|
||||||
Chars == "- - - a".
|
Chars == "- - -a".
|
||||||
|
|
||||||
test_216 :- writeq_term_to_chars(-(-1), Chars),
|
test_216 :- writeq_term_to_chars(-(-(1)), Chars),
|
||||||
Chars == "- -1".
|
Chars == "- - (1)".
|
||||||
|
|
||||||
test_215_248_249 :-
|
test_215_248_249 :-
|
||||||
setup_call_cleanup(op(100,yfx,~),
|
setup_call_cleanup(op(100,yfx,~),
|
||||||
@@ -307,14 +307,14 @@ test_215_248_249 :-
|
|||||||
|
|
||||||
test_278 :- setup_call_cleanup(op(9,xfy,.),
|
test_278 :- setup_call_cleanup(op(9,xfy,.),
|
||||||
( writeq_term_to_chars(-[1], Chars),
|
( writeq_term_to_chars(-[1], Chars),
|
||||||
Chars == "- [1]"
|
Chars == "-[1]"
|
||||||
),
|
),
|
||||||
op(0,xfy,.)).
|
op(0,xfy,.)).
|
||||||
|
|
||||||
test_279_296 :-
|
test_279_296 :-
|
||||||
setup_call_cleanup(op(9,xf,'$VAR'),
|
setup_call_cleanup(op(9,xf,'$VAR'),
|
||||||
( writeq_term_to_chars(-'$VAR'(0), Chars0),
|
( writeq_term_to_chars(-'$VAR'(0), Chars0),
|
||||||
Chars0 == "- A",
|
Chars0 == "-A",
|
||||||
writeq_term_to_chars('$VAR'(0), Chars1),
|
writeq_term_to_chars('$VAR'(0), Chars1),
|
||||||
Chars1 == "A"
|
Chars1 == "A"
|
||||||
),
|
),
|
||||||
@@ -340,7 +340,7 @@ test_67 :- setup_call_cleanup(( current_op(P,fy,+),
|
|||||||
op(P,fy,+)).
|
op(P,fy,+)).
|
||||||
|
|
||||||
test_257 :- writeq_term_to_chars([+{a},+[]], Chars),
|
test_257 :- writeq_term_to_chars([+{a},+[]], Chars),
|
||||||
Chars == "[+ {a},+ []]".
|
Chars == "[+{a},+[]]".
|
||||||
|
|
||||||
test_68 :- [(:-)|(:-)]=[:-|:-].
|
test_68 :- [(:-)|(:-)]=[:-|:-].
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@ test_131_132_133 :-
|
|||||||
C0 == "' op' '1 '",
|
C0 == "' op' '1 '",
|
||||||
read_from_chars("' op'[].", T1),
|
read_from_chars("' op'[].", T1),
|
||||||
writeq_term_to_chars(T1, C1),
|
writeq_term_to_chars(T1, C1),
|
||||||
C1 == "' op' []"
|
C1 == "' op'[]"
|
||||||
),
|
),
|
||||||
op(0, fx, ' op')
|
op(0, fx, ' op')
|
||||||
).
|
).
|
||||||
@@ -595,7 +595,7 @@ test_142_143_144_221_258 :-
|
|||||||
C1 == "[1]",
|
C1 == "[1]",
|
||||||
read_from_chars("-[1].", T2),
|
read_from_chars("-[1].", T2),
|
||||||
writeq_term_to_chars(T2, C2),
|
writeq_term_to_chars(T2, C2),
|
||||||
C2 == "- [1]",
|
C2 == "-[1]",
|
||||||
read_from_chars("X = 1.e.", T3),
|
read_from_chars("X = 1.e.", T3),
|
||||||
writeq_term_to_chars(T3, C3),
|
writeq_term_to_chars(T3, C3),
|
||||||
C3 == "A=[1|e]",
|
C3 == "A=[1|e]",
|
||||||
@@ -934,7 +934,7 @@ test_274_275 :-
|
|||||||
setup_call_cleanup(op(20,fx,--),
|
setup_call_cleanup(op(20,fx,--),
|
||||||
( read_from_chars("--(a).", T0),
|
( read_from_chars("--(a).", T0),
|
||||||
writeq_term_to_chars(T0, C0),
|
writeq_term_to_chars(T0, C0),
|
||||||
C0 == "-- a",
|
C0 == "--a",
|
||||||
op(0,fx,--),
|
op(0,fx,--),
|
||||||
read_from_chars("--(a).", T1),
|
read_from_chars("--(a).", T1),
|
||||||
writeq_term_to_chars(T1, C1),
|
writeq_term_to_chars(T1, C1),
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ fn handle_residual_goal() {
|
|||||||
true.\n \
|
true.\n \
|
||||||
true.\n \
|
true.\n \
|
||||||
false.\n \
|
false.\n \
|
||||||
X = - X.\n \
|
X = -X.\n \
|
||||||
dif:dif(- X,X).\n \
|
dif:dif(-X,X).\n \
|
||||||
false.\n \
|
false.\n \
|
||||||
Vars = [X], dif:dif(- X,X).\n \
|
Vars = [X], dif:dif(-X,X).\n \
|
||||||
true.\n \
|
true.\n \
|
||||||
true.\n \
|
true.\n \
|
||||||
true.\n\
|
true.\n\
|
||||||
|
|||||||
Reference in New Issue
Block a user