How to use setup method of test.EqTest class

Best Mockito-kotlin code snippet using test.EqTest.setup

ExpressionTest.kt

Source:ExpressionTest.kt Github

copy

Full Screen

...31 }32 val layer = symbolLayer("id", "source") {33 textSize(expression)34 }35 setupLayer(layer)36 assertEquals(9.0, layer.textSize)37 }38 /**39 * Logical negation. Returns `true` if the input is `false`, and `false` if the input is `true`.40 */41 @Test42 @UiThreadTest43 fun notTest() {44 val expression = not {45 literal(true)46 }47 val layer = symbolLayer("id", "source") {48 iconAllowOverlap(expression)49 }50 setupLayer(layer)51 assertEquals(false, layer.iconAllowOverlap)52 }53 /**54 * Returns `true` if the input values are not equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.55 */56 @Test57 @UiThreadTest58 fun neqTestEq() {59 val expression = neq {60 literal("abc")61 literal("abc")62 }63 val layer = symbolLayer("id", "source") {64 iconAllowOverlap(expression)65 }66 setupLayer(layer)67 assertEquals(false, layer.iconAllowOverlap)68 }69 @Test70 @UiThreadTest71 fun neqTestNeq() {72 val expression = neq {73 literal("abc")74 literal("def")75 }76 val layer = symbolLayer("id", "source") {77 iconAllowOverlap(expression)78 }79 setupLayer(layer)80 assertEquals(true, layer.iconAllowOverlap)81 }82 /**83 * Returns the product of the inputs.84 */85 @Test86 @UiThreadTest87 fun productTest() {88 val expression = product {89 literal(12)90 literal(3)91 }92 val layer = symbolLayer("id", "source") {93 textSize(expression)94 }95 setupLayer(layer)96 assertEquals(36.0, layer.textSize)97 }98 /**99 * Returns the result of floating point division of the first input by the second.100 */101 @Test102 @UiThreadTest103 fun divisionTest() {104 val expression = division {105 literal(12)106 literal(3)107 }108 val layer = symbolLayer("id", "source") {109 textSize(expression)110 }111 setupLayer(layer)112 assertEquals(4.0, layer.textSize)113 }114 /**115 * Returns the remainder after integer division of the first input by the second.116 */117 @Test118 @UiThreadTest119 fun modTest() {120 val expression = mod {121 literal(4)122 literal(3)123 }124 val layer = symbolLayer("id", "source") {125 textSize(expression)126 }127 setupLayer(layer)128 assertEquals(1.0, layer.textSize)129 }130 /**131 * Returns the result of raising the first input to the power specified by the second.132 */133 @Test134 @UiThreadTest135 fun powTest() {136 val expression = pow {137 literal(2)138 literal(3)139 }140 val layer = symbolLayer("id", "source") {141 textSize(expression)142 }143 setupLayer(layer)144 assertEquals(8.0, layer.textSize)145 }146 /**147 * Returns the sum of the inputs.148 */149 @Test150 @UiThreadTest151 fun sumTest() {152 val expression = sum {153 literal(2)154 literal(3)155 }156 val layer = symbolLayer("id", "source") {157 textSize(expression)158 }159 setupLayer(layer)160 assertEquals(5.0, layer.textSize)161 }162 /**163 * Returns `true` if the first input is strictly less than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.164 */165 @Test166 @UiThreadTest167 fun ltTest() {168 val expression = lt {169 literal(2)170 literal(3)171 }172 val layer = symbolLayer("id", "source") {173 iconAllowOverlap(expression)174 }175 setupLayer(layer)176 assertEquals(true, layer.iconAllowOverlap)177 }178 /**179 * Returns `true` if the first input is less than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.180 */181 @Test182 @UiThreadTest183 fun lteTest() {184 val expression = lte {185 literal(3)186 literal(3)187 }188 val layer = symbolLayer("id", "source") {189 iconAllowOverlap(expression)190 }191 setupLayer(layer)192 assertEquals(true, layer.iconAllowOverlap)193 layer.iconAllowOverlap(194 lte {195 literal(3)196 literal(4)197 }198 )199 assertEquals(true, layer.iconAllowOverlap)200 layer.iconAllowOverlap(201 lte {202 literal(4)203 literal(3)204 }205 )206 assertEquals(false, layer.iconAllowOverlap)207 }208 /**209 * Returns `true` if the input values are equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.210 */211 @Test212 @UiThreadTest213 fun eqTest() {214 val expression = eq {215 literal(3)216 literal(3)217 }218 val layer = symbolLayer("id", "source") {219 iconAllowOverlap(expression)220 }221 setupLayer(layer)222 assertEquals(true, layer.iconAllowOverlap)223 layer.iconAllowOverlap(224 eq {225 literal(4)226 literal(3)227 }228 )229 assertEquals(false, layer.iconAllowOverlap)230 }231 /**232 * Returns `true` if the first input is strictly greater than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.233 */234 @Test235 @UiThreadTest236 fun gtTest() {237 val expression = gt {238 literal(3)239 literal(3)240 }241 val layer = symbolLayer("id", "source") {242 iconAllowOverlap(expression)243 }244 setupLayer(layer)245 assertEquals(false, layer.iconAllowOverlap)246 layer.iconAllowOverlap(247 gt {248 literal(4)249 literal(3)250 }251 )252 assertEquals(true, layer.iconAllowOverlap)253 layer.iconAllowOverlap(254 gt {255 literal(2)256 literal(3)257 }258 )259 assertEquals(false, layer.iconAllowOverlap)260 }261 /**262 * Returns `true` if the first input is greater than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.263 */264 @Test265 @UiThreadTest266 fun gteTest() {267 val expression = gte {268 literal(3)269 literal(3)270 }271 val layer = symbolLayer("id", "source") {272 iconAllowOverlap(expression)273 }274 setupLayer(layer)275 assertEquals(true, layer.iconAllowOverlap)276 layer.iconAllowOverlap(277 gte {278 literal(4)279 literal(3)280 }281 )282 assertEquals(true, layer.iconAllowOverlap)283 layer.iconAllowOverlap(284 gte {285 literal(2)286 literal(3)287 }288 )289 assertEquals(false, layer.iconAllowOverlap)290 }291 /**292 * Returns the absolute value of the input.293 */294 @Test295 @UiThreadTest296 fun absTest() {297 val expression = abs {298 literal(-3)299 }300 val layer = symbolLayer("id", "source") {301 textSize(expression)302 }303 setupLayer(layer)304 assertEquals(3.0, layer.textSize)305 }306 /**307 * Gets the value of a cluster property accumulated so far. Can only be used in the `clusterProperties` option of a clustered GeoJSON source.308 */309 @Test310 @UiThreadTest311 fun accumulatedTest() {312 val source = geoJsonSource("id") {313 url("http://mock.geojson")314 clusterProperty(315 "max",316 max {317 accumulated()318 get {319 literal("max")320 }321 },322 get {323 literal("mag")324 }325 )326 }327 setupSource(source)328 }329 /**330 * Returns the arccosine of the input.331 */332 @Test333 @UiThreadTest334 fun acosTest() {335 val expression = acos {336 literal(1.0)337 }338 val layer = symbolLayer("id", "source") {339 textSize(expression)340 }341 setupLayer(layer)342 assertEquals(0.0, layer.textSize)343 }344 /**345 * Returns `true` if all the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `false`, the result is `false` and no further input expressions are evaluated.346 */347 @Test348 @UiThreadTest349 fun allTest() {350 val expression = all {351 literal(true)352 literal(true)353 literal(false)354 }355 val layer = symbolLayer("id", "source") {356 iconAllowOverlap(expression)357 }358 setupLayer(layer)359 assertEquals(false, layer.iconAllowOverlap)360 }361 /**362 * Returns `true` if any of the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `true`, the result is `true` and no further input expressions are evaluated.363 */364 @Test365 @UiThreadTest366 fun anyTest() {367 val expression = any {368 literal(true)369 literal(true)370 literal(false)371 }372 val layer = symbolLayer("id", "source") {373 iconAllowOverlap(expression)374 }375 setupLayer(layer)376 assertEquals(true, layer.iconAllowOverlap)377 }378 /**379 * Asserts that the input is an array (optionally with a specific item type and length). If, when the input expression is evaluated, it is not of the asserted type, then this assertion will cause the whole expression to be aborted.380 */381 @Test382 @UiThreadTest383 fun arrayTest() {384 val expression = array {385 literal("number")386 literal(2)387 get {388 literal("array_property")389 }390 }391 val layer = symbolLayer("id", "source") {392 iconOffset(expression)393 }394 setupLayer(layer)395 assertEquals(expression.toString(), layer.iconOffsetAsExpression.toString())396 }397 /**398 * Returns the arcsine of the input.399 */400 @Test401 @UiThreadTest402 fun asinTest() {403 val expression = asin {404 literal(0.0)405 }406 val layer = symbolLayer("id", "source") {407 textSize(expression)408 }409 setupLayer(layer)410 assertEquals(0.0, layer.textSize)411 }412 /**413 * Retrieves an item from an array.414 */415 @Test416 @UiThreadTest417 fun atTest() {418 val expression = at {419 literal(2)420 literal(listOf(1.0, 2.0, 3.0, 4.0))421 }422 val layer = symbolLayer("id", "source") {423 symbolSortKey(expression)424 }425 setupLayer(layer)426 assertEquals(3.0, layer.symbolSortKey)427 }428 /**429 * Returns the arctangent of the input.430 */431 @Test432 @UiThreadTest433 fun atanTest() {434 val expression = atan {435 literal(0)436 }437 val layer = symbolLayer("id", "source") {438 textSize(expression)439 }440 setupLayer(layer)441 assertEquals(0.0, layer.textSize)442 }443 /**444 * Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean is obtained. If none of the inputs are booleans, the expression is an error.445 */446 @Test447 @UiThreadTest448 fun booleanTest() {449 val expression = boolean {450 literal(true)451 }452 val layer = symbolLayer("id", "source") {453 iconOptional(expression)454 }455 setupLayer(layer)456 assertEquals(true, layer.iconOptional)457 }458 /**459 * Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.460 */461 @Test462 @UiThreadTest463 fun switchCaseTest() {464 val expression = switchCase {465 eq {466 get {467 literal("count")468 }469 literal(1.0)470 }471 literal(1.0)472 eq {473 get {474 literal("count")475 }476 literal(2.0)477 }478 literal(2.0)479 literal(0.0)480 }481 val layer = symbolLayer("id", "source") {482 textSize(expression)483 }484 setupLayer(layer)485 assertEquals(expression.toString(), layer.textSizeAsExpression.toString())486 }487 /**488 * Returns the smallest integer that is greater than or equal to the input.489 */490 @Test491 @UiThreadTest492 fun ceilTest() {493 val expression = ceil {494 literal(0.5)495 }496 val layer = symbolLayer("id", "source") {497 textSize(expression)498 }499 setupLayer(layer)500 assertEquals(1.0, layer.textSize)501 }502 /**503 * Evaluates each expression in turn until the first non-null value is obtained, and returns that value.504 */505 @Test506 @UiThreadTest507 fun coalesceTest() {508 val expression = toColor {509 coalesce {510 get {511 literal("keyToNullValue")512 }513 get {514 literal("keyToNonNullValue")515 }516 }517 }518 val layer = symbolLayer("id", "source") {519 textColor(expression)520 }521 setupLayer(layer)522 assertEquals(expression.toString(), layer.textColorAsExpression.toString())523 }524 /**525 * Returns a `collator` for use in locale-dependent comparison operations. The `case-sensitive` and `diacritic-sensitive` options default to `false`. The `locale` argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the `collator` will use a system-defined fallback locale. Use `resolved-locale` to test the results of locale fallback behavior.526 */527 @Test528 @UiThreadTest529 fun collatorTest() {530 val expression = switchCase {531 eq {532 literal("Abc")533 literal("abc")534 collator {535 caseSensitive(false)536 locale(Locale("en_US"))537 }538 }539 literal(1.0)540 literal(0.0)541 }542 val layer = symbolLayer("id", "source") {543 textSize(expression)544 }545 setupLayer(layer)546 assertEquals(547 "[case, [==, Abc, abc, [collator, {diacritic-sensitive=false, locale=en_us, case-sensitive=false}]], 1.0, 0.0]",548 layer.textSizeAsExpression.toString()549 )550 }551 /**552 * Returns a `string` consisting of the concatenation of the inputs. Each input is converted to a string as if by `to-string`.553 */554 @Test555 @UiThreadTest556 fun concatTest() {557 val expression = concat {558 literal("this")559 literal("is")560 literal("test")561 }562 val layer = symbolLayer("id", "source") {563 textField(expression)564 }565 setupLayer(layer)566 assertEquals("thisistest", layer.textFieldAsString)567 }568 /**569 * Returns the cosine of the input.570 */571 @Test572 @UiThreadTest573 fun cosTest() {574 val expression = cos {575 pi()576 }577 val layer = symbolLayer("id", "source") {578 symbolSortKey(expression)579 }580 setupLayer(layer)581 assertEquals(-1.0, layer.symbolSortKey)582 }583 /**584 * Returns the input string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.585 */586 @Test587 @UiThreadTest588 fun downcaseTest() {589 val expression = downcase {590 literal("TeSt")591 }592 val layer = symbolLayer("id", "source") {593 textField(expression)594 }595 setupLayer(layer)596 assertEquals("test", layer.textFieldAsString)597 }598 /**599 * Returns the mathematical constant e.600 */601 @Test602 @UiThreadTest603 fun eTest() {604 val expression = e()605 val layer = symbolLayer("id", "source") {606 textSize(expression)607 }608 setupLayer(layer)609 assertEquals(2.7182817459106445, layer.textSize)610 }611 /**612 * Retrieves a property value from the current feature's state. Returns null if the requested property is not present on the feature's state. A feature's state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. Features are identified by their `id` attribute, which must be an integer or a string that can be cast to an integer. Note that ["feature-state"] can only be used with paint properties that support data-driven styling.613 */614 @Test615 @UiThreadTest616 fun featureStateTest() {617 val expression = switchCase {618 boolean {619 featureState {620 literal("hover")621 }622 literal(false)623 }624 literal(1.0)625 literal(0.5)626 }627 val layer = fillLayer("id", "source") {628 fillOpacity(expression)629 }630 setupLayer(layer)631 assertEquals(expression.toString(), layer.fillOpacityAsExpression.toString())632 }633 /**634 * Returns the largest integer that is less than or equal to the input.635 */636 @Test637 @UiThreadTest638 fun floorTest() {639 val expression = floor {640 literal(1.6)641 }642 val layer = symbolLayer("id", "source") {643 textSize(expression)644 }645 setupLayer(layer)646 assertEquals(1.0, layer.textSize)647 }648 /**649 * Returns `formatted` text containing annotations for use in mixed-format `text-field` entries. If set, the `text-font` argument overrides the font specified by the root layout properties. If set, the `font-scale` argument specifies a scaling factor relative to the `text-size` specified in the root layout properties. If set, the `text-color` argument overrides the color specified by the paint properties for this layer.650 */651 @Test652 @UiThreadTest653 fun formatTest() {654 val expression = format {655 formatSection(literal("text")) {656 fontScale(1.0)657 textFont(listOf("font1", "font2"))658 textColor(Color.BLUE)659 }660 formatSection(literal("text2")) {661 fontScale(2.0)662 textFont(listOf("font1", "font2"))663 textColor(Color.RED)664 }665 }666 val layer = symbolLayer("id", "source") {667 textField(expression)668 }669 setupLayer(layer)670 assertEquals(671 "[format, text, {font-scale=1.0, text-font=[literal, [font1, font2]], text-color=[rgba, 0.0, 0.0, 255.0, 1.0]}, text2, {font-scale=2.0, text-font=[literal, [font1, font2]], text-color=[rgba, 255.0, 0.0, 0.0, 1.0]}]",672 layer.textFieldAsExpression.toString()673 )674 }675 /**676 * Gets the feature's geometry type: Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon.677 */678 @Test679 @UiThreadTest680 fun geometryTypeTest() {681 val expression = format {682 formatSection(683 content = concat {684 get {685 literal("key-to-value")686 }687 literal(" ")688 geometryType()689 }690 )691 }692 val layer = symbolLayer("id", "source") {693 textField(expression)694 }695 setupLayer(layer)696 assertEquals(697 "[format, [concat, [get, key-to-value], , [geometry-type]], {}]",698 layer.textFieldAsExpression.toString()699 )700 }701 /**702 * Retrieves a property value from the current feature's properties, or from another object if a second argument is provided. Returns null if the requested property is missing.703 */704 @Test705 @UiThreadTest706 fun getTest() {707 val expression = image {708 string {709 get {710 literal("key-to-value")711 }712 }713 }714 val layer = symbolLayer("id", "source") {715 iconImage(expression)716 }717 setupLayer(layer)718 assertEquals(expression.toString(), layer.iconImageAsExpression.toString())719 }720 /**721 * Tests for the presence of an property value in the current feature's properties, or from another object if a second argument is provided.722 */723 @Test724 @UiThreadTest725 fun hasTest() {726 val expression = has {727 literal("key")728 }729 val layer = fillLayer("id", "source") {730 filter(expression)731 }732 setupLayer(layer)733 assertEquals(expression.toString(), layer.filter.toString())734 }735 /**736 * Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the `heatmap-color` property.737 */738 @Test739 @UiThreadTest740 fun heatmapDensityTest() {741 val expression = interpolate {742 linear()743 heatmapDensity()744 literal(1.0)745 rgba {746 literal(178.0)747 literal(24.0)748 literal(12.0)749 literal(1.0)750 }751 }752 val layer = heatmapLayer("id", "source") {753 heatmapColor(expression)754 }755 setupLayer(layer)756 assertEquals(expression.toString(), layer.heatmapColor.toString())757 }758 /**759 * Gets the feature's id, if it has one.760 */761 @Test762 @UiThreadTest763 fun idTest() {764 val expression = format {765 formatSection(766 id()767 )768 }769 val layer = symbolLayer("id", "source") {770 textField(expression)771 }772 setupLayer(layer)773 assertEquals("[format, [id], {}]", layer.textFieldAsExpression.toString())774 }775 /**776 * Returns an `image` type for use in `icon-image` and `*-pattern` entries. If set, the `image` argument will check that the requested image exists in the style and will return either the resolved image name or `null`, depending on whether or not the image is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in the `image` argument.777 */778 @Test779 @UiThreadTest780 fun imageTest() {781 val expression = image {782 string {783 get {784 literal("key")785 }786 }787 }788 val layer = symbolLayer("id", "source") {789 iconImage(expression)790 }791 setupLayer(layer)792 assertEquals(expression.toString(), layer.iconImageAsExpression.toString())793 }794 /**795 * Determines whether an item exists in an array or a substring exists in a string.796 */797 @Test798 @UiThreadTest799 fun inExpressionTest() {800 val expression = inExpression {801 get {802 literal("key")803 }804 literal(listOf("abc", "def"))805 }806 val layer = symbolLayer("id", "source") {807 filter(expression)808 }809 setupLayer(layer)810 assertEquals(expression.toString(), layer.filter.toString())811 }812 /**813 * Produces continuous, smooth results by interpolating between pairs of input and output values ("stops"). The `input` may be any numeric expression (e.g., `["get", "population"]`). Stop inputs must be numeric literals in strictly ascending order. The output type must be `number`, `array<number>`, or `color`.814 Interpolation types:815 - `["linear"]`: interpolates linearly between the pair of stops just less than and just greater than the input.816 - `["exponential", base]`: interpolates exponentially between the stops just less than and just greater than the input. `base` controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.817 - `["cubic-bezier", x1, y1, x2, y2]`: interpolates using the cubic bezier curve defined by the given control points.818 */819 @Test820 @UiThreadTest821 fun interpolateTest() {822 val expression = interpolate {823 exponential {824 literal(0.5)825 }826 zoom()827 stop {828 literal(1.0)829 rgba {830 literal(0.0)831 literal(0.0)832 literal(0.0)833 literal(0.0)834 }835 }836 stop {837 literal(10.0)838 rgba {839 literal(255.0)840 literal(255.0)841 literal(255.0)842 literal(1.0)843 }844 }845 }846 val layer = fillLayer("id", "source") {847 fillColor(expression)848 }849 setupLayer(layer)850 assertEquals(expression.toString(), layer.fillColorAsExpression.toString())851 }852 /**853 * Returns `true` if the input string is expected to render legibly. Returns `false` if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the the `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS).854 */855 @Test856 @UiThreadTest857 fun isSupportedScriptTest() {858 val expression = isSupportedScript {859 string {860 get {861 literal("script")862 }863 }864 }865 val layer = symbolLayer("id", "source") {866 filter(expression)867 }868 setupLayer(layer)869 assertEquals(expression.toString(), layer.filter.toString())870 }871 /**872 * Gets the length of an array or string.873 */874 @Test875 @UiThreadTest876 fun lengthTest() {877 val expression = length {878 literal(listOf("one", "two", "three"))879 }880 val layer = symbolLayer("id", "source") {881 textSize(expression)882 }883 setupLayer(layer)884 assertEquals(3.0, layer.textSize)885 }886 /**887 * Binds expressions to named variables, which can then be referenced in the result expression using ["var", "variable_name"].888 */889 @Test890 @UiThreadTest891 fun letExpressionTest() {892 val expression = letExpression {893 literal("two")894 literal(2.0)895 sum {896 literal(1.0)897 varExpression {898 literal("two")899 }900 }901 }902 val layer = symbolLayer("id", "source") {903 textSize(expression)904 }905 setupLayer(layer)906 assertEquals(3.0, layer.textSize)907 }908 /**909 * Gets the progress along a gradient line. Can only be used in the `line-gradient` property.910 */911 @Test912 @UiThreadTest913 fun lineProgressTest() {914 val expression = interpolate {915 linear()916 lineProgress()917 stop {918 literal(0.0)919 rgba {920 literal(0.0)921 literal(0.0)922 literal(255.0)923 literal(1.0)924 }925 }926 stop {927 literal(1.0)928 rgba {929 literal(255.0)930 literal(0.0)931 literal(0.0)932 literal(1.0)933 }934 }935 }936 val layer = lineLayer("id", "source") {937 lineGradient(expression)938 }939 setupLayer(layer)940 assertEquals(expression.toString(), layer.lineGradient.toString())941 }942 /**943 * Provides a literal array or object value.944 */945 @Test946 @UiThreadTest947 fun literalDoubleTest() {948 val expression = literal(0.1)949 val layer = symbolLayer("id", "source") {950 textSize(expression)951 }952 setupLayer(layer)953 assertEquals(0.1, layer.textSize!!, 1E-5)954 }955 /**956 * Provides a literal array or object value.957 */958 @Test959 @UiThreadTest960 fun literalLongTest() {961 val expression = literal(12L)962 val layer = symbolLayer("id", "source") {963 textSize(expression)964 }965 setupLayer(layer)966 assertEquals(12.0, layer.textSize)967 }968 /**969 * Provides a literal array or object value.970 */971 @Test972 @UiThreadTest973 fun literalBooleanTest() {974 val expression = literal(true)975 val layer = symbolLayer("id", "source") {976 iconAllowOverlap(expression)977 }978 setupLayer(layer)979 assertEquals(true, layer.iconAllowOverlap)980 }981 /**982 * Provides a literal array or object value.983 */984 @Test985 @UiThreadTest986 fun literalStringTest() {987 val expression = literal("name")988 val layer = symbolLayer("id", "source") {989 textField(expression)990 }991 setupLayer(layer)992 assertEquals("name", layer.textFieldAsString)993 }994 /**995 * Provides a literal array or object value.996 */997 @Test998 @UiThreadTest999 fun literalDoubleArrayTest() {1000 val expression = literal(listOf(1.0, 2.0))1001 val layer = symbolLayer("id", "source") {1002 iconOffset(expression)1003 }1004 setupLayer(layer)1005 assertEquals(listOf(1.0, 2.0), layer.iconOffset!!)1006 }1007 /**1008 * Provides a literal array or object value.1009 */1010 @Test1011 @UiThreadTest1012 fun literalLongArrayTest() {1013 val expression = literal(listOf(11L, 22L))1014 val layer = symbolLayer("id", "source") {1015 iconOffset(expression)1016 }1017 setupLayer(layer)1018 assertEquals(listOf(11.0, 22.0), layer.iconOffset!!)1019 }1020 /**1021 * Provides a literal array or object value.1022 */1023 @Test1024 @UiThreadTest1025 fun literalBooleanArrayTest() {1026 val expression = at {1027 literal(2)1028 literal(listOf(true, true, false, true))1029 }1030 val layer = symbolLayer("id", "source") {1031 iconAllowOverlap(expression)1032 }1033 setupLayer(layer)1034 assertEquals(false, layer.iconAllowOverlap)1035 }1036 /**1037 * Provides a literal array or object value.1038 */1039 @Test1040 @UiThreadTest1041 fun literalStringArrayTest() {1042 val expression = literal(listOf("text font a", "text font b"))1043 val layer = symbolLayer("id", "source") {1044 textFont(expression)1045 }1046 setupLayer(layer)1047 assertEquals(expression.toString(), layer.textFontAsExpression.toString())1048 }1049 /**1050 * Returns the natural logarithm of the input.1051 */1052 @Test1053 @UiThreadTest1054 fun lnTest() {1055 val expression = ln {1056 e()1057 }1058 val layer = symbolLayer("id", "source") {1059 textSize(expression)1060 }1061 setupLayer(layer)1062 assertEquals(1.0, layer.textSize)1063 }1064 /**1065 * Returns mathematical constant ln(2).1066 */1067 @Test1068 @UiThreadTest1069 fun ln2Test() {1070 val expression = ln2()1071 val layer = symbolLayer("id", "source") {1072 textSize(expression)1073 }1074 setupLayer(layer)1075 assertEquals(0.6931471824645996, layer.textSize)1076 }1077 /**1078 * Returns the base-ten logarithm of the input.1079 */1080 @Test1081 @UiThreadTest1082 fun log10Test() {1083 val expression = log10 {1084 literal(100)1085 }1086 val layer = symbolLayer("id", "source") {1087 textSize(expression)1088 }1089 setupLayer(layer)1090 assertEquals(2.0, layer.textSize)1091 }1092 /**1093 * Returns the base-two logarithm of the input.1094 */1095 @Test1096 @UiThreadTest1097 fun log2Test() {1098 val expression = log2 {1099 literal(8)1100 }1101 val layer = symbolLayer("id", "source") {1102 textSize(expression)1103 }1104 setupLayer(layer)1105 assertEquals(3.0, layer.textSize)1106 }1107 /**1108 * Selects the output whose label value matches the input value, or the fallback value if no match is found. The input can be any expression (e.g. `["get", "building_type"]`). Each label must be either:1109 * a single literal value; or1110 * an array of literal values, whose values must be all strings or all numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any of the values in the array matches, similar to the deprecated `"in"` operator.1111 Each label must be unique. If the input type does not match the type of the labels, the result will be the fallback value.1112 */1113 @Test1114 @UiThreadTest1115 fun matchTest() {1116 val expression = match {1117 get {1118 literal("key")1119 }1120 literal(1)1121 literal(1.0)1122 literal(2)1123 literal(2.0)1124 literal(3.0)1125 }1126 val layer = symbolLayer("id", "source") {1127 textSize(expression)1128 }1129 setupLayer(layer)1130 assertEquals(expression.toString(), layer.textSizeAsExpression.toString())1131 }1132 /**1133 * Selects the output whose label value matches the input value, or the fallback value if no match is found. The input can be any expression (e.g. `["get", "building_type"]`). Each label must be either:1134 * a single literal value; or1135 * an array of literal values, whose values must be all strings or all numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any of the values in the array matches, similar to the deprecated `"in"` operator.1136 Each label must be unique. If the input type does not match the type of the labels, the result will be the fallback value.1137 */1138 @Test1139 @UiThreadTest1140 fun matchWithLableListTest() {1141 val expression = match {1142 get {1143 literal("ethnicity")1144 }1145 literal(listOf("Asian", "Black", "Hispanic", "white"))1146 rgba(251.0, 176.0, 59.0, 1.0)1147 literal("Other")1148 rgba(204.0, 204.0, 204.0, 1.0)1149 rgba(0.0, 0.0, 0.0, 1.0)1150 }1151 val layer = symbolLayer("id", "source") {1152 textColor(expression)1153 }1154 setupLayer(layer)1155 assertEquals(expression.toJson(), layer.textColorAsExpression?.toJson())1156 }1157 /**1158 * Returns the maximum value of the inputs.1159 */1160 @Test1161 @UiThreadTest1162 fun maxTest() {1163 val expression = max {1164 literal(8)1165 literal(10)1166 literal(7)1167 }1168 val layer = symbolLayer("id", "source") {1169 textSize(expression)1170 }1171 setupLayer(layer)1172 assertEquals(10.0, layer.textSize)1173 }1174 /**1175 * Returns the minimum value of the inputs.1176 */1177 @Test1178 @UiThreadTest1179 fun minTest() {1180 val expression = min {1181 literal(8)1182 literal(10)1183 literal(7)1184 }1185 val layer = symbolLayer("id", "source") {1186 textSize(expression)1187 }1188 setupLayer(layer)1189 assertEquals(7.0, layer.textSize)1190 }1191 /**1192 * Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number is obtained. If none of the inputs are numbers, the expression is an error.1193 */1194 @Test1195 @UiThreadTest1196 fun numberTest() {1197 val expression = number {1198 literal("string")1199 literal(true)1200 literal(1)1201 }1202 val layer = symbolLayer("id", "source") {1203 textSize(expression)1204 }1205 setupLayer(layer)1206 assertEquals(1.0, layer.textSize)1207 }1208 /**1209 * Converts the input number into a string representation using the providing formatting rules. If set, the `locale` argument specifies the locale to use, as a BCP 47 language tag. If set, the `currency` argument specifies an ISO 4217 code to use for currency-style formatting. If set, the `min-fraction-digits` and `max-fraction-digits` arguments specify the minimum and maximum number of fractional digits to include.1210 */1211 @Test1212 @UiThreadTest1213 fun numberFormatTest() {1214 val expression = numberFormat(literal(123.456789)) {1215 locale {1216 literal("en-US")1217 }1218 minFractionDigits {1219 literal(1)1220 }1221 maxFractionDigits {1222 literal(4)1223 }1224 }1225 val layer = symbolLayer("id", "source") {1226 textField(expression)1227 }1228 setupLayer(layer)1229 assertEquals("123.4568", layer.textFieldAsString)1230 layer.textField(1231 numberFormat(literal(1234567.1234567)) {1232 locale {1233 literal("en-US")1234 }1235 currency {1236 literal("USD")1237 }1238 }1239 )1240 assertEquals("$1,234,567.12", layer.textFieldAsString)1241 }1242 /**1243 * Asserts that the input value is an object. If multiple values are provided, each one is evaluated in order until an object is obtained. If none of the inputs are objects, the expression is an error.1244 */1245 @Test1246 @UiThreadTest1247 fun objectExpressionTest() {1248 val map = HashMap<String, Value>()1249 map["key1"] = literal(1)1250 map["key2"] = literal(2)1251 val expression = toBoolean {1252 objectExpression {1253 literal(map as HashMap<String, Any>)1254 }1255 }1256 val layer = symbolLayer("id", "source") {1257 iconAllowOverlap(expression)1258 }1259 setupLayer(layer)1260 assertEquals(true, layer.iconAllowOverlap)1261 }1262 /**1263 * Returns the mathematical constant pi.1264 */1265 @Test1266 @UiThreadTest1267 fun piTest() {1268 val expression = pi()1269 val layer = symbolLayer("id", "source") {1270 textSize(expression)1271 }1272 setupLayer(layer)1273 assertEquals(3.1415927410125732, layer.textSize)1274 }1275 /**1276 * Gets the feature properties object. Note that in some cases, it may be more efficient to use ["get", "property_name"] directly.1277 */1278 @Test1279 @UiThreadTest1280 fun propertiesTest() {1281 val expression = number {1282 get {1283 literal("key")1284 properties()1285 }1286 }1287 val layer = symbolLayer("id", "source") {1288 textSize(expression)1289 }1290 setupLayer(layer)1291 assertEquals(expression.toString(), layer.textSizeAsExpression.toString())1292 }1293 /**1294 * Returns the IETF language tag of the locale being used by the provided `collator`. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.1295 */1296 @Test1297 @UiThreadTest1298 fun resolvedLocaleTest() {1299 val expression = number {1300 switchCase {1301 eq {1302 literal("it")1303 resolvedLocale {1304 collator {1305 locale(Locale("en-US"))1306 }1307 }1308 }1309 literal(1.0)1310 literal(2.0)1311 }1312 }1313 val layer = symbolLayer("id", "source") {1314 textSize(expression)1315 }1316 setupLayer(layer)1317 assertEquals(1318 "[number, [case, [==, it, [resolved-locale, [collator, {diacritic-sensitive=false, locale=en-us, case-sensitive=false}]]], 1.0, 2.0]]",1319 layer.textSizeAsExpression.toString()1320 )1321 }1322 /**1323 * Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1. If any component is out of range, the expression is an error.1324 */1325 @Test1326 @UiThreadTest1327 fun rgbTest() {1328 val expression = rgb {1329 literal(0.0)1330 literal(1.0)1331 literal(2.0)1332 }1333 val layer = symbolLayer("id", "source") {1334 textColor(expression)1335 }1336 setupLayer(layer)1337 assertEquals(1338 rgba {1339 literal(0.0)1340 literal(1.0)1341 literal(2.0)1342 literal(1.0)1343 }.toString(),1344 layer.textColorAsExpression.toString()1345 )1346 }1347 /**1348 * Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1. If any component is out of range, the expression is an error.1349 */1350 @Test1351 @UiThreadTest1352 fun rgbaTest() {1353 val expression = rgba {1354 literal(0.0)1355 literal(1.0)1356 literal(2.0)1357 literal(0.5)1358 }1359 val layer = symbolLayer("id", "source") {1360 textColor(expression)1361 }1362 setupLayer(layer)1363 assertEquals(expression.toString(), layer.textColorAsExpression.toString())1364 }1365 /**1366 * Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example, `["round", -1.5]` evaluates to -2.1367 */1368 @Test1369 @UiThreadTest1370 fun roundTest() {1371 val expression = round {1372 literal(-1.5)1373 }1374 val layer = symbolLayer("id", "source") {1375 symbolSortKey(expression)1376 }1377 setupLayer(layer)1378 assertEquals(-2.0, layer.symbolSortKey)1379 }1380 /**1381 * Returns the sine of the input.1382 */1383 @Test1384 @UiThreadTest1385 fun sinTest() {1386 val expression = sin {1387 division {1388 pi()1389 literal(2)1390 }1391 }1392 val layer = symbolLayer("id", "source") {1393 textSize(expression)1394 }1395 setupLayer(layer)1396 assertEquals(1.0, layer.textSize)1397 }1398 /**1399 * Returns the square root of the input.1400 */1401 @Test1402 @UiThreadTest1403 fun sqrtTest() {1404 val expression = sqrt {1405 literal(9)1406 }1407 val layer = symbolLayer("id", "source") {1408 textSize(expression)1409 }1410 setupLayer(layer)1411 assertEquals(3.0, layer.textSize)1412 }1413 /**1414 * Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values ("stops"). The `input` may be any numeric expression (e.g., `["get", "population"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first output if the input is less than the first stop.1415 */1416 @Test1417 @UiThreadTest1418 fun stepTest() {1419 val expression = step {1420 zoom()1421 literal(0.0)1422 stop(1.0) { literal(2.5) }1423 stop(10.0) { literal(5.0) }1424 }1425 val layer = circleLayer("id", "source") {1426 circleRadius(expression)1427 }1428 setupLayer(layer)1429 assertEquals(expression.toString(), layer.circleRadiusAsExpression.toString())1430 }1431 /**1432 * Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string is obtained. If none of the inputs are strings, the expression is an error.1433 */1434 @Test1435 @UiThreadTest1436 fun stringTest() {1437 val expression = string {1438 literal(9)1439 literal(true)1440 literal("string")1441 }1442 val layer = symbolLayer("id", "source") {1443 textField(expression)1444 }1445 setupLayer(layer)1446 assertEquals("string", layer.textFieldAsString)1447 }1448 /**1449 * Returns the tangent of the input.1450 */1451 @Test1452 @UiThreadTest1453 fun tanTest() {1454 val expression = tan {1455 division {1456 pi()1457 literal(4)1458 }1459 }1460 val layer = symbolLayer("id", "source") {1461 textSize(expression)1462 }1463 setupLayer(layer)1464 assertEquals(1.0, layer.textSize)1465 }1466 /**1467 * Converts the input value to a boolean. The result is `false` when then input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it is `true`.1468 */1469 @Test1470 @UiThreadTest1471 fun toBooleanTest() {1472 val expression = toBoolean {1473 literal("abc")1474 }1475 val layer = symbolLayer("id", "source") {1476 iconAllowOverlap(expression)1477 }1478 setupLayer(layer)1479 assertEquals(true, layer.iconAllowOverlap)1480 layer.iconAllowOverlap(1481 toBoolean {1482 literal("")1483 }1484 )1485 assertEquals(false, layer.iconAllowOverlap)1486 }1487 /**1488 * Converts the input value to a color. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.1489 */1490 @Test1491 @UiThreadTest1492 fun toColorTest() {1493 val expression = toColor {1494 literal("abc")1495 literal("def")1496 literal("blue")1497 }1498 val layer = symbolLayer("id", "source") {1499 iconColor(expression)1500 }1501 setupLayer(layer)1502 assertEquals(Color.BLUE, layer.iconColorAsColorInt)1503 }1504 /**1505 * Converts the input value to a number, if possible. If the input is `null` or `false`, the result is 0. If the input is `true`, the result is 1. If the input is a string, it is converted to a number as specified by the ["ToNumber Applied to the String Type" algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) of the ECMAScript Language Specification. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.1506 */1507 @Test1508 @UiThreadTest1509 fun toNumberTest() {1510 val expression = toNumber {1511 literal("2.0")1512 }1513 val layer = symbolLayer("id", "source") {1514 textSize(expression)1515 }1516 setupLayer(layer)1517 assertEquals(2.0, layer.textSize)1518 // TODO this should work, created ticket to track it.1519 // layer.textSize(toNumber {1520 // literal(true)1521 // })1522 // assertEquals(1.0, layer.textSize)1523 }1524 /**1525 * Returns a four-element array containing the input color's red, green, blue, and alpha components, in that order.1526 */1527 @Test1528 @UiThreadTest1529 fun toRgbaTest() {1530 val expression = toRgba {1531 literal("blue")1532 }1533 val layer = symbolLayer("id", "source") {1534 iconTextFitPadding(expression)1535 }1536 setupLayer(layer)1537 assertEquals(listOf(0.0, 0.0, 255.0, 1.0), layer.iconTextFitPadding!!)1538 }1539 /**1540 * Converts the input value to a string. If the input is `null`, the result is `""`. If the input is a boolean, the result is `"true"` or `"false"`. If the input is a number, it is converted to a string as specified by the ["NumberToString" algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) of the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) function of the ECMAScript Language Specification.1541 */1542 @Test1543 @UiThreadTest1544 fun toStringTest() {1545 val expression = toString {1546 literal(true)1547 }1548 val layer = symbolLayer("id", "source") {1549 textField(expression)1550 }1551 setupLayer(layer)1552 assertEquals("true", layer.textFieldAsString)1553 layer.textField(1554 toString {1555 literal(10)1556 }1557 )1558 assertEquals("10", layer.textFieldAsString)1559 layer.textField(1560 toString {1561 rgba {1562 literal(0.0)1563 literal(0.0)1564 literal(0.0)1565 literal(0.0)1566 }1567 }1568 )1569 assertEquals("rgba(0,0,0,0)", layer.textFieldAsString)1570 }1571 /**1572 * Returns a string describing the type of the given value.1573 */1574 @Test1575 @UiThreadTest1576 fun typeofExpressionTest() {1577 val expression = typeofExpression {1578 literal(true)1579 }1580 val layer = symbolLayer("id", "source") {1581 textField(expression)1582 }1583 setupLayer(layer)1584 assertEquals("boolean", layer.textFieldAsString)1585 layer.textField(1586 typeofExpression {1587 literal(10)1588 }1589 )1590 assertEquals("number", layer.textFieldAsString)1591 layer.textField(1592 typeofExpression {1593 rgba {1594 literal(0.0)1595 literal(0.0)1596 literal(0.0)1597 literal(0.0)1598 }1599 }1600 )1601 assertEquals("color", layer.textFieldAsString)1602 layer.textField(1603 typeofExpression {1604 literal(listOf("abc", "def"))1605 }1606 )1607 assertEquals("array<string, 2>", layer.textFieldAsString)1608 }1609 /**1610 * Returns the input string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.1611 */1612 @Test1613 @UiThreadTest1614 fun upcaseTest() {1615 val expression = upcase {1616 literal("small")1617 }1618 val layer = symbolLayer("id", "source") {1619 textField(expression)1620 }1621 setupLayer(layer)1622 assertEquals("SMALL", layer.textFieldAsString)1623 }1624 /**1625 * References variable bound using "let".1626 */1627 @Test1628 @UiThreadTest1629 fun varExpressionTest() {1630 val expression = number {1631 letExpression {1632 literal("two")1633 literal(2.0)1634 sum {1635 literal(1.0)1636 varExpression {1637 literal("two")1638 }1639 }1640 }1641 }1642 val layer = symbolLayer("id", "source") {1643 textSize(expression)1644 }1645 setupLayer(layer)1646 assertEquals(3.0, layer.textSize)1647 }1648 /**1649 * Returns `true` if the feature being evaluated is inside the pre-defined geometry boundary, `false` otherwise. The expression has one argument which must be a valid GeoJSON Polygon/Multi-Polygon object. The expression only evaluates on `Point` or `LineString` feature. For `Point` feature, The expression will return false if any point of the feature is on the boundary or outside the boundary. For `LineString` feature, the expression will return false if the line is fully outside the boundary, or the line is partially intersecting the boundary, which means either part of the line is outside of the boundary, or end point of the line lies on the boundary.1650 */1651 @Test1652 @UiThreadTest1653 fun withinTest() {1654 val polygon = Polygon.fromJson(1655 """1656 {1657 "type": "Polygon",1658 "coordinates": [1659 [[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]1660 ]1661 }1662 """.trimIndent()1663 )1664 val expression = within(polygon)1665 val layer = symbolLayer("id", "source") {1666 filter(expression)1667 }1668 setupLayer(layer)1669 assertEquals(1670 "[within, {coordinates=[[[30.0, 10.0], [40.0, 40.0], [20.0, 40.0], [10.0, 20.0], [30.0, 10.0]]], type=Polygon}]",1671 layer.filter.toString()1672 )1673 }1674 /**1675 * Gets the current zoom level. Note that in style layout and paint properties, ["zoom"] may only appear as the input to a top-level "step" or "interpolate" expression.1676 */1677 @Test1678 @UiThreadTest1679 fun zoomTest() {1680 val expression = interpolate {1681 exponential {1682 literal(0.5)1683 }1684 zoom()1685 stop {1686 literal(1.0)1687 rgba {1688 literal(0.0)1689 literal(0.0)1690 literal(0.0)1691 literal(0.0)1692 }1693 }1694 stop {1695 literal(10.0)1696 rgba {1697 literal(255.0)1698 literal(255.0)1699 literal(255.0)1700 literal(1.0)1701 }1702 }1703 }1704 val layer = fillLayer("id", "source") {1705 fillColor(expression)1706 }1707 setupLayer(layer)1708 assertEquals(expression.toString(), layer.fillColorAsExpression.toString())1709 }1710 /**1711 * Convert a color int to the rgba expression.1712 */1713 @Test1714 @UiThreadTest1715 fun colorTest() {1716 val expression = color(Color.RED)1717 val layer = symbolLayer("id", "source") {1718 textColor(expression)1719 }1720 setupLayer(layer)1721 assertEquals(1722 rgba {1723 literal(255.0)1724 literal(0.0)1725 literal(0.0)1726 literal(1.0)1727 }.toString(),1728 layer.textColorAsExpression.toString()1729 )1730 }1731 /**1732 * Test constructing an Expression from raw string.1733 */1734 @Test1735 @UiThreadTest1736 fun rawExpressionTest() {1737 val expression = color(Color.RED)1738 val layer = symbolLayer("id", "source") {1739 textColor(Expression.fromRaw("[\"rgba\", 255.0, 0.0, 0.0, 1.0]"))1740 }1741 setupLayer(layer)1742 assertEquals(expression.toString(), layer.textColorAsExpression.toString())1743 }1744 /**1745 * Returns the shortest distance in meters between the evaluated feature and the input geometry. The input value can be a valid GeoJSON of type Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, Feature, or FeatureCollection. Distance values returned may vary in precision due to loss in precision from encoding geometries, particularly below zoom level 13.1746 */1747 @Test1748 @UiThreadTest1749 fun distanceTest() {1750 val polygon = Polygon.fromJson(1751 """1752 {1753 "type": "Polygon",1754 "coordinates": [1755 [[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]1756 ]1757 }1758 """.trimIndent()1759 )1760 val expression = lt {1761 distance(polygon)1762 literal(150)1763 }1764 val layer = symbolLayer("id", "source") {1765 filter(expression)1766 }1767 setupLayer(layer)1768 assertEquals(1769 "[<, [distance, {coordinates=[[[30.0, 10.0], [40.0, 40.0], [20.0, 40.0], [10.0, 20.0], [30.0, 10.0]]], type=Polygon}], 150.0]",1770 layer.filter.toString()1771 )1772 }1773}...

Full Screen

Full Screen

EqTest.kt

Source:EqTest.kt Github

copy

Full Screen

...33 private val openClassInstance: MyClass = MyClass()34 private val closedClassInstance: ClosedClass = ClosedClass()35 private lateinit var doAnswer: Open36 @Before37 fun setup() {38 /* Create a proper Mockito state */39 doAnswer = Mockito.doAnswer { }.`when`(mock())40 }41 @After42 override fun tearDown() {43 super.tearDown()44 /* Close `any` Mockito state */45 doAnswer.go(0)46 }47 @Test48 fun eqInterfaceInstance() {49 /* When */50 val result = eq(interfaceInstance)51 /* Then */...

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1public void testSetup() {2EqTest test = new EqTest();3test.setup();4}5public void testTeardown() {6EqTest test = new EqTest();7test.teardown();8}9public void testTestAdd() {10EqTest test = new EqTest();11test.testAdd();12}13public void testTestAdd2() {14EqTest test = new EqTest();15test.testAdd2();16}17public void testTestAdd3() {18EqTest test = new EqTest();19test.testAdd3();20}21public void testTestAdd4() {22EqTest test = new EqTest();23test.testTestAdd4();24}25public void testTestAdd5() {26EqTest test = new EqTest();27test.testAdd5();28}29public void testTestAdd6() {30EqTest test = new EqTest();31test.testAdd6();32}33public void testTestAdd7() {34EqTest test = new EqTest();35test.testAdd7();36}37public void testTestAdd8() {38EqTest test = new EqTest();39test.testAdd8();40}41public void testTestAdd9() {42EqTest test = new EqTest();43test.testAdd9();44}45public void testTestAdd10() {46EqTest test = new EqTest();47test.testAdd10();48}49public void testTestAdd11() {50EqTest test = new EqTest();51test.testAdd11();52}

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1public class TestEq {2public static void main(String[] args) {3EqTest test = new EqTest();4test.setup();5}6}7public class TestEq {8public static void main(String[] args) {9EqTest test = new EqTest();10test.setup();11}12}13public class TestEq {14public static void main(String[] args) {15EqTest test = new EqTest();16test.setup();17}18}19public class TestEq {20public static void main(String[] args) {21EqTest test = new EqTest();22test.setup();23}24}25public class TestEq {26public static void main(String[] args) {27EqTest test = new EqTest();28test.setup();29}30}31public class TestEq {32public static void main(String[] args) {33EqTest test = new EqTest();34test.setup();35}36}37public class TestEq {38public static void main(String[] args) {39EqTest test = new EqTest();40test.setup();41}42}43public class TestEq {44public static void main(String[] args) {45EqTest test = new EqTest();46test.setup();47}48}49public class TestEq {50public static void main(String[] args) {51EqTest test = new EqTest();52test.setup();53}54}55public class TestEq {56public static void main(String[] args) {57EqTest test = new EqTest();58test.setup();59}60}61public class TestEq {62public static void main(String[] args) {63EqTest test = new EqTest();64test.setup();65}66}67public class TestEq {68public static void main(String[] args) {69EqTest test = new EqTest();70test.setup();71}72}73public class TestEq {74public static void main(String[] args) {

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1public void testSetup() {2EqTest eqTest = new EqTest();3eqTest.setup();4}5}6public class EqTest {7private String eq;8private String eq1;9public void setup() {10eq = "2+2=4";11eq1 = "2+2=5";12}13public void testEq() {14Assert.assertEquals(eq, eq1);15}16}17at org.junit.Assert.assertEquals(Assert.java:115)18at org.junit.Assert.assertEquals(Assert.java:144)19at test.EqTest.testEq(EqTest.java:16)20at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)21at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)22at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)23at java.lang.reflect.Method.invoke(Method.java:597)24at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)25at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)26at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)27at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)28at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)29at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)30at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)31at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)32at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)33at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)34at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)35at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)36at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)37at org.junit.runners.ParentRunner.run(ParentRunner.java:236)38at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)39at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockito-kotlin automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful