@@ -1491,7 +1491,6 @@ function test_parse_term()
14911491 @test term == MOI. ScalarAffineTerm (- coef, x)
14921492 end
14931493 for (input, reason) in [
1494- " subject to" => " Got a keyword defining a new section with value `CONSTRAINTS`." ,
14951494 " >= 1" => " Got the symbol `>=`." ,
14961495 ]
14971496 io = IOBuffer (input)
@@ -1545,14 +1544,14 @@ function test_parse_set_prefix()
15451544 state = LP. _LexerState (io)
15461545 @test LP. _parse_set_prefix (state, cache) == set
15471546 end
1548- io = IOBuffer (" ->" )
1547+ io = IOBuffer (" 1.0 ->" )
15491548 state = LP. _LexerState (io)
15501549 @test_parse_error (
15511550 """
15521551 Error parsing LP file on line 1:
1553- ->
1554- ^
1555- Got the symbol `->`. We expected this token to be a number .""" ,
1552+ 1.0 ->
1553+ ^
1554+ Got the symbol `->`. We expected this to be an inequality like `>=`, `<=`, or `==` .""" ,
15561555 LP. _parse_set_prefix (state, cache),
15571556 )
15581557 return
@@ -1642,7 +1641,7 @@ function test_new_line_edge_cases_sos()
16421641 return
16431642end
16441643
1645- function test_new_line_edge_case_fails ()
1644+ function test_missing_new_line_edge_cases ()
16461645 for input in [
16471646 # No newline between objective sense and objective
16481647 " minimize x" ,
@@ -1655,7 +1654,8 @@ function test_new_line_edge_case_fails()
16551654 ]
16561655 io = IOBuffer (input)
16571656 model = LP. Model ()
1658- @test_throws LP. ParseError MOI. read! (io, model)
1657+ MOI. read! (io, model)
1658+ @test MOI. get (model, MOI. VariableIndex, " x" ) isa MOI. VariableIndex
16591659 end
16601660 return
16611661end
@@ -1680,7 +1680,7 @@ function test_parse_keyword_edge_cases_identifier_is_keyword()
16801680end
16811681
16821682function test_parse_keyword_subject_to_errors ()
1683- for line in [" subject" , " subject too" , " subject to a: " ]
1683+ for line in [" subject" , " subject too" ]
16841684 io = IOBuffer ("""
16851685 maximize
16861686 obj: x
@@ -1755,17 +1755,18 @@ function test_parse_quadratic_expr_eof()
17551755end
17561756
17571757function 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- )
1758+ # Xpress allows this. We currently do too.
1759+ for kw in (" subject to" , " such that" , " st" )
1760+ io = IOBuffer (" maximize obj: x $kw c: x <= 1\n end" )
1761+ model = LP. Model ()
1762+ MOI. read! (io, model)
1763+ @test MOI. get (model, MOI. ObjectiveSense ()) == MOI. MAX_SENSE
1764+ F, S = MOI. ScalarAffineFunction{Float64}, MOI. LessThan{Float64}
1765+ @test isa (
1766+ MOI. get (model, MOI. ConstraintIndex, " c" ),
1767+ MOI. ConstraintIndex{F,S},
1768+ )
1769+ end
17691770 return
17701771end
17711772
0 commit comments