From 2c2fbea94f86f35604327bd4ff171d37ebc2b0c8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 20 Aug 2023 19:15:08 +0200 Subject: [PATCH] Some useful aliases for RBA as in-place operators do not really do what they are supposed to in Ruby. --- src/db/db/gsiDeclDbEdgePairs.cc | 14 ++-- src/db/db/gsiDeclDbEdges.cc | 114 ++++++++++++++++++++++--------- src/db/db/gsiDeclDbRegion.cc | 51 ++++++++++---- src/db/db/gsiDeclDbTexts.cc | 15 ++-- testdata/ruby/dbEdgePairsTest.rb | 9 ++- testdata/ruby/dbEdgesTest.rb | 25 +++++++ testdata/ruby/dbRegionTest.rb | 20 ++++++ testdata/ruby/dbTextsTest.rb | 7 +- 8 files changed, 198 insertions(+), 57 deletions(-) diff --git a/src/db/db/gsiDeclDbEdgePairs.cc b/src/db/db/gsiDeclDbEdgePairs.cc index 3f4c64032..0c44c95b1 100644 --- a/src/db/db/gsiDeclDbEdgePairs.cc +++ b/src/db/db/gsiDeclDbEdgePairs.cc @@ -425,7 +425,7 @@ Class decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs", "\n" "This method has been added in version 0.26." ) + - method ("+", &db::EdgePairs::operator+, gsi::arg ("other"), + method ("+|join", &db::EdgePairs::operator+, gsi::arg ("other"), "@brief Returns the combined edge pair collection of self and the other one\n" "\n" "@return The resulting edge pair collection\n" @@ -433,8 +433,9 @@ Class decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs", "This operator adds the edge pairs of the other collection to self and returns a new combined set.\n" "\n" "This method has been introduced in version 0.24.\n" - ) + - method ("+=", &db::EdgePairs::operator+=, gsi::arg ("other"), + "The 'join' alias has been introduced in version 0.28.12." + ) + + method ("+=|join_with", &db::EdgePairs::operator+=, gsi::arg ("other"), "@brief Adds the edge pairs of the other edge pair collection to self\n" "\n" "@return The edge pair collection after modification (self)\n" @@ -442,7 +443,12 @@ Class decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs", "This operator adds the edge pairs of the other collection to self.\n" "\n" "This method has been introduced in version 0.24.\n" - ) + + "\n" + "Note that in Ruby, the '+=' operator actually does not exist, but is emulated by '+' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'join_with' instead.\n" + "\n" + "The 'join_with' alias has been introduced in version 0.28.12." + ) + method_ext ("move", &move_p, gsi::arg ("p"), "@brief Moves the edge pair collection\n" "\n" diff --git a/src/db/db/gsiDeclDbEdges.cc b/src/db/db/gsiDeclDbEdges.cc index 9f68150f6..2994880b9 100644 --- a/src/db/db/gsiDeclDbEdges.cc +++ b/src/db/db/gsiDeclDbEdges.cc @@ -769,7 +769,7 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "Crossing edges are not merged.\n" "In contrast to \\merge, this method does not modify the edge collection but returns a merged copy.\n" ) + - method ("&", (db::Edges (db::Edges::*)(const db::Edges &) const) &db::Edges::operator&, gsi::arg ("other"), + method ("&|and", (db::Edges (db::Edges::*)(const db::Edges &) const) &db::Edges::operator&, gsi::arg ("other"), "@brief Returns the boolean AND between self and the other edge collection\n" "\n" "@return The result of the boolean AND operation\n" @@ -777,17 +777,24 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "The boolean AND operation will return all parts of the edges in this collection which " "are coincident with parts of the edges in the other collection." "The result will be a merged edge collection.\n" - ) + - method ("&=", (db::Edges &(db::Edges::*)(const db::Edges &)) &db::Edges::operator&=, gsi::arg ("other"), - "@brief Performs the boolean AND between self and the other edge collection\n" + "\n" + "The 'and' alias has been introduced in version 0.28.12." + ) + + method ("&=|and_with", (db::Edges &(db::Edges::*)(const db::Edges &)) &db::Edges::operator&=, gsi::arg ("other"), + "@brief Performs the boolean AND between self and the other edge collection in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" "The boolean AND operation will return all parts of the edges in this collection which " "are coincident with parts of the edges in the other collection." "The result will be a merged edge collection.\n" - ) + - method ("&", (db::Edges (db::Edges::*)(const db::Region &) const) &db::Edges::operator&, gsi::arg ("other"), + "\n" + "Note that in Ruby, the '&=' operator actually does not exist, but is emulated by '&' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'and_with' instead.\n" + "\n" + "The 'and_with' alias has been introduced in version 0.28.12." + ) + + method ("&|and", (db::Edges (db::Edges::*)(const db::Region &) const) &db::Edges::operator&, gsi::arg ("other"), "@brief Returns the parts of the edges inside the given region\n" "\n" "@return The edges inside the given region\n" @@ -798,9 +805,10 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "edges intersect.\n" "\n" "This method has been introduced in version 0.24." - ) + - method ("&=", (db::Edges &(db::Edges::*)(const db::Region &)) &db::Edges::operator&=, gsi::arg ("other"), - "@brief Selects the parts of the edges inside the given region\n" + "The 'and' alias has been introduced in version 0.28.12." + ) + + method ("&=|and_with", (db::Edges &(db::Edges::*)(const db::Region &)) &db::Edges::operator&=, gsi::arg ("other"), + "@brief Selects the parts of the edges inside the given region in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" @@ -810,8 +818,13 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "edges intersect.\n" "\n" "This method has been introduced in version 0.24." - ) + - method ("-", (db::Edges (db::Edges::*)(const db::Edges &) const) &db::Edges::operator-, gsi::arg ("other"), + "\n" + "Note that in Ruby, the '&=' operator actually does not exist, but is emulated by '&' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'and_with' instead.\n" + "\n" + "The 'and_with' alias has been introduced in version 0.28.12." + ) + + method ("-|not", (db::Edges (db::Edges::*)(const db::Edges &) const) &db::Edges::operator-, gsi::arg ("other"), "@brief Returns the boolean NOT between self and the other edge collection\n" "\n" "@return The result of the boolean NOT operation\n" @@ -819,17 +832,24 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "The boolean NOT operation will return all parts of the edges in this collection which " "are not coincident with parts of the edges in the other collection." "The result will be a merged edge collection.\n" - ) + - method ("-=", (db::Edges &(db::Edges::*)(const db::Edges &)) &db::Edges::operator-=, gsi::arg ("other"), - "@brief Performs the boolean NOT between self and the other edge collection\n" + "\n" + "The 'not' alias has been introduced in version 0.28.12." + ) + + method ("-=|not_with", (db::Edges &(db::Edges::*)(const db::Edges &)) &db::Edges::operator-=, gsi::arg ("other"), + "@brief Performs the boolean NOT between self and the other edge collection in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" "The boolean NOT operation will return all parts of the edges in this collection which " "are not coincident with parts of the edges in the other collection." "The result will be a merged edge collection.\n" - ) + - method ("-", (db::Edges (db::Edges::*)(const db::Region &) const) &db::Edges::operator-, gsi::arg ("other"), + "\n" + "Note that in Ruby, the '-=' operator actually does not exist, but is emulated by '-' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'not_with' instead.\n" + "\n" + "The 'not_with' alias has been introduced in version 0.28.12." + ) + + method ("-|not", (db::Edges (db::Edges::*)(const db::Region &) const) &db::Edges::operator-, gsi::arg ("other"), "@brief Returns the parts of the edges outside the given region\n" "\n" "@return The edges outside the given region\n" @@ -840,9 +860,10 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "edges intersect.\n" "\n" "This method has been introduced in version 0.24." - ) + - method ("-=", (db::Edges &(db::Edges::*)(const db::Region &)) &db::Edges::operator-=, gsi::arg ("other"), - "@brief Selects the parts of the edges outside the given region\n" + "The 'not' alias has been introduced in version 0.28.12." + ) + + method ("-=|not_with", (db::Edges &(db::Edges::*)(const db::Region &)) &db::Edges::operator-=, gsi::arg ("other"), + "@brief Selects the parts of the edges outside the given region in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" @@ -851,8 +872,12 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "As a side effect, the edges are made non-intersecting by introducing cut points where\n" "edges intersect.\n" "\n" + "Note that in Ruby, the '-=' operator actually does not exist, but is emulated by '-' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'not_with' instead.\n" + "\n" "This method has been introduced in version 0.24." - ) + + "The 'not_with' alias has been introduced in version 0.28.12." + ) + method_ext ("andnot", &andnot_with_edges, gsi::arg ("other"), "@brief Returns the boolean AND and NOT between self and the other edge set\n" "\n" @@ -873,7 +898,7 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "\n" "This method has been added in version 0.28.\n" ) + - method ("^", &db::Edges::operator^, gsi::arg ("other"), + method ("^|xor", &db::Edges::operator^, gsi::arg ("other"), "@brief Returns the boolean XOR between self and the other edge collection\n" "\n" "@return The result of the boolean XOR operation\n" @@ -881,48 +906,69 @@ Class decl_Edges (decl_dbShapeCollection, "db", "Edges", "The boolean XOR operation will return all parts of the edges in this and the other collection except " "the parts where both are coincident.\n" "The result will be a merged edge collection.\n" - ) + - method ("^=", &db::Edges::operator^=, gsi::arg ("other"), - "@brief Performs the boolean XOR between self and the other edge collection\n" + "\n" + "The 'xor' alias has been introduced in version 0.28.12." + ) + + method ("^=|xor_with", &db::Edges::operator^=, gsi::arg ("other"), + "@brief Performs the boolean XOR between self and the other edge collection in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" "The boolean XOR operation will return all parts of the edges in this and the other collection except " "the parts where both are coincident.\n" "The result will be a merged edge collection.\n" - ) + - method ("\\|", &db::Edges::operator|, gsi::arg ("other"), + "\n" + "Note that in Ruby, the '^=' operator actually does not exist, but is emulated by '^' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'xor_with' instead.\n" + "\n" + "The 'xor_with' alias has been introduced in version 0.28.12." + ) + + method ("\\||or", &db::Edges::operator|, gsi::arg ("other"), "@brief Returns the boolean OR between self and the other edge set\n" "\n" "@return The resulting edge collection\n" "\n" "The boolean OR is implemented by merging the edges of both edge sets. To simply join the edge collections " "without merging, the + operator is more efficient." - ) + - method ("\\|=", &db::Edges::operator|=, gsi::arg ("other"), - "@brief Performs the boolean OR between self and the other edge set\n" + "\n" + "The 'or' alias has been introduced in version 0.28.12." + ) + + method ("\\|=|or_with", &db::Edges::operator|=, gsi::arg ("other"), + "@brief Performs the boolean OR between self and the other edge set in-place (modifying self)\n" "\n" "@return The edge collection after modification (self)\n" "\n" "The boolean OR is implemented by merging the edges of both edge sets. To simply join the edge collections " "without merging, the + operator is more efficient." - ) + - method ("+", &db::Edges::operator+, gsi::arg ("other"), + "\n" + "Note that in Ruby, the '|=' operator actually does not exist, but is emulated by '|' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'or_with' instead.\n" + "\n" + "The 'or_with' alias has been introduced in version 0.28.12." + ) + + method ("+|join", &db::Edges::operator+, gsi::arg ("other"), "@brief Returns the combined edge set of self and the other one\n" "\n" "@return The resulting edge set\n" "\n" "This operator adds the edges of the other edge set to self and returns a new combined edge set. " "This usually creates unmerged edge sets and edges may overlap. Use \\merge if you want to ensure the result edge set is merged.\n" - ) + - method ("+=", &db::Edges::operator+=, gsi::arg ("other"), + "\n" + "The 'join' alias has been introduced in version 0.28.12." + ) + + method ("+=|join_with", &db::Edges::operator+=, gsi::arg ("other"), "@brief Adds the edges of the other edge collection to self\n" "\n" "@return The edge set after modification (self)\n" "\n" "This operator adds the edges of the other edge set to self. " "This usually creates unmerged edge sets and edges may overlap. Use \\merge if you want to ensure the result edge set is merged.\n" - ) + + "\n" + "Note that in Ruby, the '+=' operator actually does not exist, but is emulated by '+' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'join_with' instead.\n" + "\n" + "The 'join_with' alias has been introduced in version 0.28.12." + ) + method ("interacting", (db::Edges (db::Edges::*) (const db::Edges &) const) &db::Edges::selected_interacting, gsi::arg ("other"), "@brief Returns the edges of this edge collection which overlap or touch edges from the other edge collection\n" "\n" diff --git a/src/db/db/gsiDeclDbRegion.cc b/src/db/db/gsiDeclDbRegion.cc index b8c2813ea..f75f5ab5a 100644 --- a/src/db/db/gsiDeclDbRegion.cc +++ b/src/db/db/gsiDeclDbRegion.cc @@ -1647,15 +1647,18 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", "This variant has been introduced in version 0.28.4." ) + method ("&=", &db::Region::operator&=, gsi::arg ("other"), - "@brief Performs the boolean AND between self and the other region\n" + "@brief Performs the boolean AND between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" "This method will compute the boolean AND (intersection) between two regions. " "The result is often but not necessarily always merged.\n" + "\n" + "Note that in Ruby, the '&=' operator actually does not exist, but is emulated by '&' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'and_with' instead." ) + method ("and_with", &db::Region::bool_and_with, gsi::arg ("other"), gsi::arg ("property_constraint", db::IgnoreProperties, "IgnoreProperties"), - "@brief Performs the boolean AND between self and the other region\n" + "@brief Performs the boolean AND between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" @@ -1687,15 +1690,18 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", "This variant has been introduced in version 0.28.4." ) + method ("-=", &db::Region::operator-=, gsi::arg ("other"), - "@brief Performs the boolean NOT between self and the other region\n" + "@brief Performs the boolean NOT between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" "This method will compute the boolean NOT (intersection) between two regions. " "The result is often but not necessarily always merged.\n" + "\n" + "Note that in Ruby, the '-=' operator actually does not exist, but is emulated by '-' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'not_with' instead." ) + method ("not_with", &db::Region::bool_not_with, gsi::arg ("other"), gsi::arg ("property_constraint", db::IgnoreProperties, "IgnoreProperties"), - "@brief Performs the boolean NOT between self and the other region\n" + "@brief Performs the boolean NOT between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" @@ -1706,53 +1712,74 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", "\n" "This variant has been introduced in version 0.28.4." ) + - method ("^", &db::Region::operator^, gsi::arg ("other"), + method ("^|xor", &db::Region::operator^, gsi::arg ("other"), "@brief Returns the boolean XOR between self and the other region\n" "\n" "@return The result of the boolean XOR operation\n" "\n" "This method will compute the boolean XOR (intersection) between two regions. " "The result is often but not necessarily always merged.\n" + "\n" + "The 'xor' alias has been introduced in version 0.28.12." ) + - method ("^=", &db::Region::operator^=, gsi::arg ("other"), - "@brief Performs the boolean XOR between self and the other region\n" + method ("^=|xor_with", &db::Region::operator^=, gsi::arg ("other"), + "@brief Performs the boolean XOR between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" "This method will compute the boolean XOR (intersection) between two regions. " "The result is often but not necessarily always merged.\n" + "\n" + "Note that in Ruby, the '^=' operator actually does not exist, but is emulated by '^' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'xor_with' instead.\n" + "\n" + "The 'xor_with' alias has been introduced in version 0.28.12." ) + - method ("\\|", &db::Region::operator|, gsi::arg ("other"), + method ("\\||or", &db::Region::operator|, gsi::arg ("other"), "@brief Returns the boolean OR between self and the other region\n" "\n" "@return The resulting region\n" "\n" "The boolean OR is implemented by merging the polygons of both regions. To simply join the regions " "without merging, the + operator is more efficient." + "\n" + "The 'or' alias has been introduced in version 0.28.12." ) + - method ("\\|=", &db::Region::operator|=, gsi::arg ("other"), - "@brief Performs the boolean OR between self and the other region\n" + method ("\\|=|or_with", &db::Region::operator|=, gsi::arg ("other"), + "@brief Performs the boolean OR between self and the other region in-place (modifying self)\n" "\n" "@return The region after modification (self)\n" "\n" "The boolean OR is implemented by merging the polygons of both regions. To simply join the regions " "without merging, the + operator is more efficient." + "\n" + "Note that in Ruby, the '|=' operator actually does not exist, but is emulated by '|' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'or_with' instead.\n" + "\n" + "The 'or_with' alias has been introduced in version 0.28.12." ) + - method ("+", &db::Region::operator+, gsi::arg ("other"), + method ("+|join", &db::Region::operator+, gsi::arg ("other"), "@brief Returns the combined region of self and the other region\n" "\n" "@return The resulting region\n" "\n" "This operator adds the polygons of the other region to self and returns a new combined region. " "This usually creates unmerged regions and polygons may overlap. Use \\merge if you want to ensure the result region is merged.\n" + "\n" + "The 'join' alias has been introduced in version 0.28.12." ) + - method ("+=", &db::Region::operator+=, gsi::arg ("other"), + method ("+=|join_with", &db::Region::operator+=, gsi::arg ("other"), "@brief Adds the polygons of the other region to self\n" "\n" "@return The region after modification (self)\n" "\n" "This operator adds the polygons of the other region to self. " "This usually creates unmerged regions and polygons may overlap. Use \\merge if you want to ensure the result region is merged.\n" + "\n" + "Note that in Ruby, the '+=' operator actually does not exist, but is emulated by '+' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'join_with' instead.\n" + "\n" + "The 'join_with' alias has been introduced in version 0.28.12." ) + method ("covering", &db::Region::selected_enclosing, gsi::arg ("other"), gsi::arg ("min_count", size_t (1)), gsi::arg ("max_count", size_t (std::numeric_limits::max ()), "unlimited"), "@brief Returns the polygons of this region which are completely covering polygons from the other region\n" diff --git a/src/db/db/gsiDeclDbTexts.cc b/src/db/db/gsiDeclDbTexts.cc index 7a4801bf2..c3cf07812 100644 --- a/src/db/db/gsiDeclDbTexts.cc +++ b/src/db/db/gsiDeclDbTexts.cc @@ -276,20 +276,27 @@ Class decl_Texts (decl_dbShapeCollection, "db", "Texts", method_ext ("data_id", &id, "@brief Returns the data ID (a unique identifier for the underlying data storage)\n" ) + - method ("+", &db::Texts::operator+, gsi::arg ("other"), + method ("+|join", &db::Texts::operator+, gsi::arg ("other"), "@brief Returns the combined text collection of self and the other one\n" "\n" "@return The resulting text collection\n" "\n" "This operator adds the texts of the other collection to self and returns a new combined set.\n" - ) + - method ("+=", &db::Texts::operator+=, gsi::arg ("other"), + "\n" + "The 'join' alias has been introduced in version 0.28.12." + ) + + method ("+=|join_with", &db::Texts::operator+=, gsi::arg ("other"), "@brief Adds the texts of the other text collection to self\n" "\n" "@return The text collection after modification (self)\n" "\n" "This operator adds the texts of the other collection to self.\n" - ) + + "\n" + "Note that in Ruby, the '+=' operator actually does not exist, but is emulated by '+' followed by an assignment. " + "This is less efficient than the in-place operation, so it is recommended to use 'join_with' instead.\n" + "\n" + "The 'join_with' alias has been introduced in version 0.28.12." + ) + method_ext ("move", &move_p, gsi::arg ("p"), "@brief Moves the text collection\n" "\n" diff --git a/testdata/ruby/dbEdgePairsTest.rb b/testdata/ruby/dbEdgePairsTest.rb index bb8af461d..a2097bfc0 100644 --- a/testdata/ruby/dbEdgePairsTest.rb +++ b/testdata/ruby/dbEdgePairsTest.rb @@ -113,8 +113,13 @@ class DBEdgePairs_TestClass < TestBase r2.insert(RBA::Edge::new(1, 1, 1, 101), RBA::Edge::new(-11, 1, -21, 51)) assert_equal(csort((r1 + r2).to_s), csort("(0,0;0,100)/(-10,0;-20,50);(0,1;0,101)/(-10,1;-20,51);(1,0;1,100)/(-11,0;-21,50);(1,1;1,101)/(-11,1;-21,51)")) - r1 += r2 - assert_equal(csort(r1.to_s), csort("(0,0;0,100)/(-10,0;-20,50);(0,1;0,101)/(-10,1;-20,51);(1,0;1,100)/(-11,0;-21,50);(1,1;1,101)/(-11,1;-21,51)")) + assert_equal(csort((r1.join(r2)).to_s), csort("(0,0;0,100)/(-10,0;-20,50);(0,1;0,101)/(-10,1;-20,51);(1,0;1,100)/(-11,0;-21,50);(1,1;1,101)/(-11,1;-21,51)")) + rr1 = r1.dup + rr1 += r2 + assert_equal(csort(rr1.to_s), csort("(0,0;0,100)/(-10,0;-20,50);(0,1;0,101)/(-10,1;-20,51);(1,0;1,100)/(-11,0;-21,50);(1,1;1,101)/(-11,1;-21,51)")) + rr1 = r1.dup + rr1.join_with(r2) + assert_equal(csort(rr1.to_s), csort("(0,0;0,100)/(-10,0;-20,50);(0,1;0,101)/(-10,1;-20,51);(1,0;1,100)/(-11,0;-21,50);(1,1;1,101)/(-11,1;-21,51)")) end diff --git a/testdata/ruby/dbEdgesTest.rb b/testdata/ruby/dbEdgesTest.rb index 68126edb3..bd4817fa9 100644 --- a/testdata/ruby/dbEdgesTest.rb +++ b/testdata/ruby/dbEdgesTest.rb @@ -315,6 +315,8 @@ class DBEdges_TestClass < TestBase r = r1 + r2 assert_equal(csort(r.to_s), csort("(0,0;100,0);(50,0;200,0)")) + r = r1.join(r2) + assert_equal(csort(r.to_s), csort("(0,0;100,0);(50,0;200,0)")) assert_equal(r.merged.to_s, "(0,0;200,0)") r.merge assert_equal(r.is_merged?, true) @@ -322,9 +324,14 @@ class DBEdges_TestClass < TestBase r = r1.dup r += r2 assert_equal(csort(r.to_s), csort("(0,0;100,0);(50,0;200,0)")) + r = r1.dup + r.join_with(r2) + assert_equal(csort(r.to_s), csort("(0,0;100,0);(50,0;200,0)")) r = r1 | r2 assert_equal(r.to_s, "(0,0;200,0)") + r = r1.or(r2) + assert_equal(r.to_s, "(0,0;200,0)") assert_equal(r.merged.to_s, "(0,0;200,0)") r.merge assert_equal(r.is_merged?, true) @@ -332,9 +339,14 @@ class DBEdges_TestClass < TestBase r = r1.dup r |= r2 assert_equal(r.to_s, "(0,0;200,0)") + r = r1.dup + r.or_with(r2) + assert_equal(r.to_s, "(0,0;200,0)") r = r1 & r2 assert_equal(r.to_s, "(50,0;100,0)") + r = r1.and(r2) + assert_equal(r.to_s, "(50,0;100,0)") assert_equal(r.is_merged?, true) r = r1.andnot(r2)[0] assert_equal(r.to_s, "(50,0;100,0)") @@ -342,9 +354,14 @@ class DBEdges_TestClass < TestBase r = r1.dup r &= r2 assert_equal(r.to_s, "(50,0;100,0)") + r = r1.dup + r.and_with(r2) + assert_equal(r.to_s, "(50,0;100,0)") r = r1 - r2 assert_equal(r.to_s, "(0,0;50,0)") + r = r1.not(r2) + assert_equal(r.to_s, "(0,0;50,0)") assert_equal(r.is_merged?, true) r = r1.andnot(r2)[1] assert_equal(r.to_s, "(0,0;50,0)") @@ -352,13 +369,21 @@ class DBEdges_TestClass < TestBase r = r1.dup r -= r2 assert_equal(r.to_s, "(0,0;50,0)") + r = r1.dup + r.not_with(r2) + assert_equal(r.to_s, "(0,0;50,0)") r = r1 ^ r2 assert_equal(csort(r.to_s), csort("(0,0;50,0);(100,0;200,0)")) + r = r1.xor(r2) + assert_equal(csort(r.to_s), csort("(0,0;50,0);(100,0;200,0)")) assert_equal(r.is_merged?, true) r = r1.dup r ^= r2 assert_equal(csort(r.to_s), csort("(0,0;50,0);(100,0;200,0)")) + r = r1.dup + r.xor_with(r2) + assert_equal(csort(r.to_s), csort("(0,0;50,0);(100,0;200,0)")) end diff --git a/testdata/ruby/dbRegionTest.rb b/testdata/ruby/dbRegionTest.rb index 71c0df2cd..173abc683 100644 --- a/testdata/ruby/dbRegionTest.rb +++ b/testdata/ruby/dbRegionTest.rb @@ -274,34 +274,54 @@ class DBRegion_TestClass < TestBase r2 = RBA::Region::new(RBA::Box::new(-10, -20, 80, 160)) assert_equal((r1 & r2).to_s, "(10,20;10,160;80,160;80,20)") + assert_equal((r1.and(r2)).to_s, "(10,20;10,160;80,160;80,20)") assert_equal(r1.andnot(r2).count, 2) assert_equal(r1.andnot(r2)[0].to_s, "(10,20;10,160;80,160;80,20)") rr = r1.dup rr &= r2 assert_equal(rr.to_s, "(10,20;10,160;80,160;80,20)") + rr = r1.dup + rr.and_with(r2) + assert_equal(rr.to_s, "(10,20;10,160;80,160;80,20)") assert_equal((r1 - r2).to_s, "(80,20;80,160;10,160;10,200;100,200;100,20)") + assert_equal((r1.not(r2)).to_s, "(80,20;80,160;10,160;10,200;100,200;100,20)") assert_equal(r1.andnot(r2)[1].to_s, "(80,20;80,160;10,160;10,200;100,200;100,20)") rr = r1.dup rr -= r2 assert_equal(rr.to_s, "(80,20;80,160;10,160;10,200;100,200;100,20)") + rr = r1.dup + rr.not_with(r2) + assert_equal(rr.to_s, "(80,20;80,160;10,160;10,200;100,200;100,20)") assert_equal((r1 ^ r2).to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20/10,20;80,20;80,160;10,160)") + assert_equal((r1.xor(r2)).to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20/10,20;80,20;80,160;10,160)") r1.min_coherence = true assert_equal(csort((r1 ^ r2).to_s), csort("(-10,-20;-10,160;10,160;10,20;80,20;80,-20);(80,20;80,160;10,160;10,200;100,200;100,20)")) rr = r1.dup rr ^= r2 assert_equal(csort(rr.to_s), csort("(-10,-20;-10,160;10,160;10,20;80,20;80,-20);(80,20;80,160;10,160;10,200;100,200;100,20)")) + rr = r1.dup + rr.xor_with(r2) + assert_equal(csort(rr.to_s), csort("(-10,-20;-10,160;10,160;10,20;80,20;80,-20);(80,20;80,160;10,160;10,200;100,200;100,20)")) assert_equal(csort((r1 + r2).to_s), csort("(10,20;10,200;100,200;100,20);(-10,-20;-10,160;80,160;80,-20)")) + assert_equal(csort((r1.join(r2)).to_s), csort("(10,20;10,200;100,200;100,20);(-10,-20;-10,160;80,160;80,-20)")) rr = r1.dup rr += r2 assert_equal(csort(rr.to_s), csort("(10,20;10,200;100,200;100,20);(-10,-20;-10,160;80,160;80,-20)")) + rr = r1.dup + rr.join_with(r2) + assert_equal(csort(rr.to_s), csort("(10,20;10,200;100,200;100,20);(-10,-20;-10,160;80,160;80,-20)")) assert_equal((r1 | r2).to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20)") + assert_equal((r1.or(r2)).to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20)") rr = r1.dup rr |= r2 assert_equal(rr.to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20)") + rr = r1.dup + rr.or_with(r2) + assert_equal(rr.to_s, "(-10,-20;-10,160;10,160;10,200;100,200;100,20;80,20;80,-20)") assert_equal((r1 + r2).sized(10).to_s, "(-20,-30;-20,170;0,170;0,210;110,210;110,10;90,10;90,-30)") rr = (r1 | r2).dup diff --git a/testdata/ruby/dbTextsTest.rb b/testdata/ruby/dbTextsTest.rb index 6df06a71a..c313c8223 100644 --- a/testdata/ruby/dbTextsTest.rb +++ b/testdata/ruby/dbTextsTest.rb @@ -114,7 +114,12 @@ class DBTexts_TestClass < TestBase r1.insert(RBA::Text::new("uvm", RBA::Trans::new(RBA::Vector::new(111, 211)))) assert_equal(csort((r1 + r2).to_s), csort("('abc',r0 100,-200);('uvm',r0 110,210);('abc',r0 101,-201);('uvm',r0 111,211)")) - r1 += r2 + assert_equal(csort((r1.join(r2)).to_s), csort("('abc',r0 100,-200);('uvm',r0 110,210);('abc',r0 101,-201);('uvm',r0 111,211)")) + rr1 = r1.dup + rr1 += r2 + assert_equal(csort(r1.to_s), csort("('abc',r0 100,-200);('uvm',r0 110,210);('abc',r0 101,-201);('uvm',r0 111,211)")) + rr1 = r1.dup + rr1.join_with(r2) assert_equal(csort(r1.to_s), csort("('abc',r0 100,-200);('uvm',r0 110,210);('abc',r0 101,-201);('uvm',r0 111,211)")) end