@@ -1490,10 +1490,7 @@ function test_parse_term()
1490
1490
term = LP. _parse_term (state, cache, - 1.0 )
1491
1491
@test term == MOI. ScalarAffineTerm (- coef, x)
1492
1492
end
1493
- for (input, reason) in [
1494
- " subject to" => " Got a keyword defining a new section with value `CONSTRAINTS`." ,
1495
- " >= 1" => " Got the symbol `>=`." ,
1496
- ]
1493
+ for (input, reason) in [" >= 1" => " Got the symbol `>=`." ]
1497
1494
io = IOBuffer (input)
1498
1495
state = LP. _LexerState (io)
1499
1496
@test_parse_error (
@@ -1545,14 +1542,14 @@ function test_parse_set_prefix()
1545
1542
state = LP. _LexerState (io)
1546
1543
@test LP. _parse_set_prefix (state, cache) == set
1547
1544
end
1548
- io = IOBuffer (" ->" )
1545
+ io = IOBuffer (" 1.0 ->" )
1549
1546
state = LP. _LexerState (io)
1550
1547
@test_parse_error (
1551
1548
"""
1552
1549
Error parsing LP file on line 1:
1553
- ->
1554
- ^
1555
- Got the symbol `->`. We expected this token to be a number .""" ,
1550
+ 1.0 ->
1551
+ ^
1552
+ Got the symbol `->`. We expected this to be an inequality like `>=`, `<=`, or `==` .""" ,
1556
1553
LP. _parse_set_prefix (state, cache),
1557
1554
)
1558
1555
return
@@ -1642,7 +1639,7 @@ function test_new_line_edge_cases_sos()
1642
1639
return
1643
1640
end
1644
1641
1645
- function test_new_line_edge_case_fails ()
1642
+ function test_missing_new_line_edge_cases ()
1646
1643
for input in [
1647
1644
# No newline between objective sense and objective
1648
1645
" minimize x" ,
@@ -1655,7 +1652,8 @@ function test_new_line_edge_case_fails()
1655
1652
]
1656
1653
io = IOBuffer (input)
1657
1654
model = LP. Model ()
1658
- @test_throws LP. ParseError MOI. read! (io, model)
1655
+ MOI. read! (io, model)
1656
+ @test MOI. get (model, MOI. VariableIndex, " x" ) isa MOI. VariableIndex
1659
1657
end
1660
1658
return
1661
1659
end
@@ -1680,7 +1678,7 @@ function test_parse_keyword_edge_cases_identifier_is_keyword()
1680
1678
end
1681
1679
1682
1680
function test_parse_keyword_subject_to_errors ()
1683
- for line in [" subject" , " subject too" , " subject to a: " ]
1681
+ for line in [" subject" , " subject too" ]
1684
1682
io = IOBuffer ("""
1685
1683
maximize
1686
1684
obj: x
@@ -1755,17 +1753,18 @@ function test_parse_quadratic_expr_eof()
1755
1753
end
1756
1754
1757
1755
function test_ambiguous_case_1 ()
1758
- # Xpress allows this. We currently don't.
1759
- io = IOBuffer (" maximize obj: x subject to c: x <= 1 end" )
1760
- model = LP. Model ()
1761
- @test_parse_error (
1762
- """
1763
- Error parsing LP file on line 1:
1764
- maximize obj: x subject to c: x <= 1 end
1765
- ^
1766
- Got an identifier with value `maximize`. We expected this token to be a keyword defining a new section.""" ,
1767
- MOI. read! (io, model),
1768
- )
1756
+ # Xpress allows this. We currently do too.
1757
+ for kw in (" subject to" , " such that" , " st" )
1758
+ io = IOBuffer (" maximize obj: x $kw c: x <= 1\n end" )
1759
+ model = LP. Model ()
1760
+ MOI. read! (io, model)
1761
+ @test MOI. get (model, MOI. ObjectiveSense ()) == MOI. MAX_SENSE
1762
+ F, S = MOI. ScalarAffineFunction{Float64}, MOI. LessThan{Float64}
1763
+ @test isa (
1764
+ MOI. get (model, MOI. ConstraintIndex, " c" ),
1765
+ MOI. ConstraintIndex{F,S},
1766
+ )
1767
+ end
1769
1768
return
1770
1769
end
1771
1770
0 commit comments