From 96b219dccf51364137960efa74ae8d0623f74a39 Mon Sep 17 00:00:00 2001 From: jclausen Date: Fri, 10 May 2024 12:45:52 -0400 Subject: [PATCH] remove StopWatch as it is an alias in the core --- .../compat/components/debug/StopWatch.java | 33 ------- .../modules/compat/components/.gitkeep | 0 .../components/debug/StopWatchTest.java | 93 ------------------- 3 files changed, 126 deletions(-) delete mode 100644 src/main/java/ortus/boxlang/modules/compat/components/debug/StopWatch.java create mode 100644 src/test/java/ortus/boxlang/modules/compat/components/.gitkeep delete mode 100644 src/test/java/ortus/boxlang/modules/compat/components/debug/StopWatchTest.java diff --git a/src/main/java/ortus/boxlang/modules/compat/components/debug/StopWatch.java b/src/main/java/ortus/boxlang/modules/compat/components/debug/StopWatch.java deleted file mode 100644 index 8a8594b..0000000 --- a/src/main/java/ortus/boxlang/modules/compat/components/debug/StopWatch.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * [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.components.debug; - -import ortus.boxlang.runtime.components.BoxComponent; -import ortus.boxlang.runtime.components.debug.Timer; - -@BoxComponent( name = "StopWatch", allowsBody = true, requiresBody = true ) -public class StopWatch extends Timer { - - /** - * Pass through to the Timer constructor - all functionality is in the Timer component - */ - public StopWatch() { - super(); - } - -} diff --git a/src/test/java/ortus/boxlang/modules/compat/components/.gitkeep b/src/test/java/ortus/boxlang/modules/compat/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/test/java/ortus/boxlang/modules/compat/components/debug/StopWatchTest.java b/src/test/java/ortus/boxlang/modules/compat/components/debug/StopWatchTest.java deleted file mode 100644 index d024f05..0000000 --- a/src/test/java/ortus/boxlang/modules/compat/components/debug/StopWatchTest.java +++ /dev/null @@ -1,93 +0,0 @@ - -/** - * [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.components.debug; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import ortus.boxlang.compiler.parser.BoxSourceType; -import ortus.boxlang.runtime.BoxRuntime; -import ortus.boxlang.runtime.context.IBoxContext; -import ortus.boxlang.runtime.context.ScriptingRequestBoxContext; -import ortus.boxlang.runtime.scopes.IScope; -import ortus.boxlang.runtime.scopes.Key; -import ortus.boxlang.runtime.scopes.VariablesScope; - -public class StopWatchTest { - - static BoxRuntime instance; - IBoxContext context; - IScope variables; - static Key result = new Key( "result" ); - - @BeforeAll - public static void setUp() { - instance = BoxRuntime.getInstance( true ); - } - - @AfterAll - public static void teardown() { - } - - @BeforeEach - public void setupEach() { - context = new ScriptingRequestBoxContext( instance.getRuntimeContext() ); - variables = context.getScopeNearby( VariablesScope.name ); - } - - @DisplayName( "It tests the Component StopWatch as a variable" ) - @Test - public void testComponentVariable() { - instance.executeSource( - """ - stopwatch variable="result"{ - sleep(1); - } - """, - context, BoxSourceType.BOXSCRIPT ); - - assertTrue( variables.get( result ) instanceof Long ); - assertTrue( variables.getAsLong( result ) >= 1 ); - } - - @DisplayName( "It tests the Component StopWatch with only a label" ) - @Test - public void testComponentLabelOnly() { - instance.executeSource( - """ - stopwatch label="TimeIt"{ - sleep(1); - } - result = getBoxContext().getBuffer().toString() - """, - context, BoxSourceType.BOXSCRIPT ); - - assertTrue( variables.get( result ) instanceof String ); - assertTrue( variables.getAsString( result ).length() > 0 ); - assertTrue( variables.getAsString( result ).trim().contains( "TimeIt" ) ); - assertTrue( variables.getAsString( result ).trim().contains( "ms" ) ); - } - -}