-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
190 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#Tue Dec 10 21:54:51 UTC 2024 | ||
#Tue Dec 17 18:03:19 UTC 2024 | ||
boxlangVersion=1.0.0-snapshot | ||
jdkVersion=21 | ||
version=1.15.0 | ||
version=1.16.0 | ||
group=ortus.boxlang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/java/ortus/boxlang/modules/compat/BooleansAreNumbersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ortus.boxlang.modules.compat; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ortus.boxlang.runtime.dynamic.casters.NumberCaster; | ||
import ortus.boxlang.runtime.operators.Negate; | ||
|
||
/** | ||
* This loads the module and runs an integration test on the module. | ||
*/ | ||
public class BooleansAreNumbersTest extends BaseIntegrationTest { | ||
|
||
@DisplayName( "It can cast a boolean to a Number" ) | ||
@Test | ||
void testItCanCastABoolean() { | ||
Number result = NumberCaster.cast( true ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 1 ); | ||
|
||
result = NumberCaster.cast( false ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 0 ); | ||
|
||
result = NumberCaster.cast( "true" ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 1 ); | ||
|
||
result = NumberCaster.cast( "false" ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 0 ); | ||
|
||
result = NumberCaster.cast( "yes" ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 1 ); | ||
|
||
result = NumberCaster.cast( "no" ); | ||
assertThat( result ).isInstanceOf( Integer.class ); | ||
assertThat( result.doubleValue() ).isEqualTo( 0 ); | ||
} | ||
|
||
@DisplayName( "It can mathematically negate a boolean" ) | ||
@Test | ||
void testItCanNegateBoolean() { | ||
assertThat( Negate.invoke( true ) ).isEqualTo( -1 ); | ||
assertThat( Negate.invoke( false ) ).isEqualTo( 0 ); | ||
assertThat( Negate.invoke( "true" ) ).isEqualTo( -1 ); | ||
assertThat( Negate.invoke( "false" ) ).isEqualTo( 0 ); | ||
assertThat( Negate.invoke( "yes" ) ).isEqualTo( -1 ); | ||
assertThat( Negate.invoke( "no" ) ).isEqualTo( 0 ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/ortus/boxlang/modules/compat/bifs/format/NumberFormatTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* [BoxLang] | ||
* | ||
* Copyright [2023] [Ortus Solutions, Corp] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" | ||
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
package ortus.boxlang.modules.compat.bifs.format; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ortus.boxlang.modules.compat.BaseIntegrationTest; | ||
|
||
public class NumberFormatTest extends BaseIntegrationTest { | ||
|
||
// https://ortussolutions.atlassian.net/browse/BL-890 | ||
@DisplayName( "It formats a boolean as a number" ) | ||
@Test | ||
void testFormatBooleanAsNumber() { | ||
runtime.executeSource( | ||
""" | ||
result = numberFormat(0 IS 0); | ||
""", | ||
context ); | ||
assertThat( variables.get( result ) ).isEqualTo( "1" ); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.