Skip to content

Commit eebde6a

Browse files
committed
Tests/Infrastructure: Setup language tests
1 parent 72ce2e0 commit eebde6a

18 files changed

Lines changed: 109 additions & 6 deletions

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build-check
1+
name: build-and-test
22

33
on:
44
push:
@@ -8,11 +8,14 @@ env:
88
LIBERICA_URL: https://download.bell-sw.com/java/17.0.3+7/bellsoft-jdk17.0.3+7-linux-amd64-full.tar.gz
99

1010
jobs:
11-
build-check:
11+
build-and-test:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15+
1516
- uses: olafurpg/setup-scala@v10
1617
with:
1718
java-version: liberica@17=tgz+${{ env.LIBERICA_URL }}
19+
1820
- run: sbt -v update compile
21+
- run: sbt -v test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
target/
33
/*.jar
44
/*.zip
5+
.bsp/

Tests.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
Sizes
2+
extensions [ bitmap ]
3+
globals [ image ]
4+
O> set image bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
5+
bitmap:width image => 1024
6+
bitmap:height image => 768
7+
8+
Base64
9+
extensions [ bitmap ]
10+
globals [ base64 image pcolors ]
11+
O> set image bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
12+
O> set image bitmap:scaled image 64 48
13+
O> bitmap:copy-to-pcolors image true
14+
O> set pcolors map [ p -> [pcolor] of p ] (sort patches)
15+
O> set base64 bitmap:to-base64 image
16+
substring base64 0 49 => "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAwCAYAAAChS3wfAAAnc"
17+
O> set image bitmap:from-base64 base64
18+
O> bitmap:copy-to-pcolors image true
19+
pcolors = map [ p -> [pcolor] of p ] (sort patches) => true
20+
21+
AverageColor
22+
extensions [ bitmap ]
23+
globals [ image ]
24+
O> set image bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
25+
bitmap:average-color image => [139.44314320882162 94.44454701741536 88.15065892537434]
26+
27+
FromView
28+
extensions [ bitmap ]
29+
globals [ image1 image2 ]
30+
O> set image1 bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
31+
O> bitmap:copy-to-drawing image1 0 0
32+
O> set image1 bitmap:from-view
33+
O> set image2 bitmap:import "extensions/bitmap/test-images/BitmapTest-view-0x0.png"
34+
bitmap:to-base64 image1 = bitmap:to-base64 image2 => true
35+
O> clear-drawing
36+
O> bitmap:copy-to-drawing image1 50 50
37+
O> set image1 bitmap:from-view
38+
O> set image2 bitmap:import "extensions/bitmap/test-images/BitmapTest-view-50x50.png"
39+
bitmap:to-base64 image1 = bitmap:to-base64 image2 => true
40+
41+
DifferenceRgb
42+
extensions [ bitmap ]
43+
globals [ image1 image2 ]
44+
O> set image1 bitmap:import "extensions/bitmap/test-images/BitmapTest-view-0x0.png"
45+
O> random-seed 12315
46+
O> create-turtles 30 [ set color red pen-down forward 30 ]
47+
O> set image2 bitmap:from-view
48+
O> set image2 bitmap:difference-rgb image1 image2
49+
O> bitmap:export image2 "../huh-rgb.png"
50+
O> set image1 bitmap:import "extensions/bitmap/test-images/BitmapTest-difference-rgb.png"
51+
bitmap:to-base64 image1 = bitmap:to-base64 image2 => true
52+
53+
Channel
54+
extensions [ bitmap ]
55+
globals [ image1 image2 image3 ]
56+
O> set image1 bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
57+
58+
O> set image2 bitmap:channel image1 0
59+
O> set image3 bitmap:import "extensions/bitmap/test-images/BitmapTest-alpha.png"
60+
bitmap:to-base64 image2 = bitmap:to-base64 image3 => true
61+
62+
O> set image2 bitmap:channel image1 1
63+
O> set image3 bitmap:import "extensions/bitmap/test-images/BitmapTest-red.png"
64+
bitmap:to-base64 image2 = bitmap:to-base64 image3 => true
65+
66+
O> set image2 bitmap:channel image1 2
67+
O> set image3 bitmap:import "extensions/bitmap/test-images/BitmapTest-green.png"
68+
bitmap:to-base64 image2 = bitmap:to-base64 image3 => true
69+
70+
O> set image2 bitmap:channel image1 3
71+
O> set image3 bitmap:import "extensions/bitmap/test-images/BitmapTest-blue.png"
72+
bitmap:to-base64 image2 = bitmap:to-base64 image3 => true
73+
74+
ToGrayscale
75+
extensions [ bitmap ]
76+
globals [ image1 image2 image3 ]
77+
O> set image1 bitmap:import "extensions/bitmap/test-images/BitmapTest.jpg"
78+
79+
O> set image2 bitmap:to-grayscale image1
80+
O> set image3 bitmap:import "extensions/bitmap/test-images/BitmapTest-grayscale.png"
81+
bitmap:to-base64 image2 = bitmap:to-base64 image3 => true

build.sbt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ name := "bitmap"
66
version := "1.1.1"
77
isSnapshot := true
88

9-
javaSource in Compile := baseDirectory.value / "src"
9+
Compile / javaSource := baseDirectory.value / "src" / "main"
1010
javacOptions ++= Seq("-g", "-deprecation", "-Xlint:all", "-Xlint:-serial", "-Xlint:-path", "-encoding", "us-ascii", "--release", "11")
1111

12-
netLogoVersion := "6.2.2"
12+
Test / scalaSource := baseDirectory.value / "src" / "test"
13+
Test / scalaVersion := "2.12.17"
14+
15+
netLogoVersion := "6.3.0"
1316
netLogoClassManager := "org.nlogo.extensions.bitmap.BitmapExtension"
17+
netLogoTestExtras += baseDirectory.value / "test-images"

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.13
1+
sbt.version=1.7.2

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ resolvers ++= Seq(
33
, "netlogo-extension-documentation" at "https://dl.cloudsmith.io/public/netlogo/netlogo-extension-documentation/maven/"
44
)
55

6-
addSbtPlugin("org.nlogo" % "netlogo-extension-plugin" % "5.2.2")
6+
addSbtPlugin("org.nlogo" % "netlogo-extension-plugin" % "6.0.0")
77
addSbtPlugin("org.nlogo" % "netlogo-extension-documentation" % "0.8.3")

src/test/Tests.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.nlogo.extensions.simpler
2+
3+
import java.io.File
4+
import org.nlogo.headless.TestLanguage
5+
6+
object Tests {
7+
val testFileNames = Seq("Tests.txt")
8+
val testFiles = testFileNames.map( (f) => (new File(f)).getCanonicalFile )
9+
}
10+
11+
class Tests extends TestLanguage(Tests.testFiles) {
12+
System.setProperty("org.nlogo.preferHeadless", "true")
13+
System.setProperty("java.awt.headless", "true")
14+
}

test-images/BitmapTest-alpha.png

3.92 KB
Loading

0 commit comments

Comments
 (0)