Rename package and address warnings
This commit is contained in:
@@ -1,33 +1,27 @@
|
||||
// swift-tools-version: 5.7
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "SwiftMath",
|
||||
name: "swiftui-math",
|
||||
defaultLocalization: "en",
|
||||
platforms: [.iOS("11.0"), .macOS("12.0")],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "SwiftMath",
|
||||
targets: ["SwiftMath"]),
|
||||
name: "SwiftUIMath",
|
||||
targets: ["SwiftUIMath"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "SwiftMath",
|
||||
name: "SwiftUIMath",
|
||||
dependencies: [],
|
||||
resources: [
|
||||
.copy("mathFonts.bundle")
|
||||
]),
|
||||
.testTarget(
|
||||
name: "SwiftMathTests",
|
||||
dependencies: ["SwiftMath"]),
|
||||
name: "SwiftUIMathTests",
|
||||
dependencies: ["SwiftUIMath"]),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
final class ConcurrencyThreadsafeTests: XCTestCase {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
final class MTFontMathTableV2Tests: XCTestCase {
|
||||
func testMTFontV2Script() throws {
|
||||
@@ -14,14 +14,6 @@ final class MTFontMathTableV2Tests: XCTestCase {
|
||||
MathFont.allCases.forEach {
|
||||
let mTable = $0.mtfont(size: size).mathTable
|
||||
XCTAssertNotNil(mTable)
|
||||
let values = [
|
||||
mTable?.fractionNumeratorDisplayStyleShiftUp,
|
||||
mTable?.fractionNumeratorShiftUp,
|
||||
mTable?.fractionDenominatorDisplayStyleShiftDown,
|
||||
mTable?.fractionDenominatorShiftDown,
|
||||
mTable?.fractionNumeratorDisplayStyleGapMin,
|
||||
mTable?.fractionNumeratorGapMin,
|
||||
].compactMap{$0}
|
||||
}
|
||||
}
|
||||
private let executionQueue = DispatchQueue(label: "com.swiftmath.mathbundle", attributes: .concurrent)
|
||||
@@ -45,35 +37,9 @@ final class MTFontMathTableV2Tests: XCTestCase {
|
||||
func helperConcurrentMTFontMathTableV2(_ count: Int, mtfont: MTFontV2, in group: DispatchGroup, on queue: DispatchQueue) {
|
||||
let workitem = DispatchWorkItem {
|
||||
let mTable = mtfont.mathTable
|
||||
let values = [
|
||||
mTable?.fractionNumeratorDisplayStyleShiftUp,
|
||||
mTable?.fractionNumeratorShiftUp,
|
||||
mTable?.fractionDenominatorDisplayStyleShiftDown,
|
||||
mTable?.fractionDenominatorShiftDown,
|
||||
mTable?.fractionNumeratorDisplayStyleGapMin,
|
||||
mTable?.fractionNumeratorGapMin,
|
||||
].compactMap{$0}
|
||||
// if count % 50 == 0 {
|
||||
// print(values) // accessed these values on global thread.
|
||||
// }
|
||||
XCTAssertNotNil(mTable)
|
||||
}
|
||||
workitem.notify(queue: .main) { [weak self] in
|
||||
// print("\(Thread.isMainThread ? "main" : "global") completed .....")
|
||||
let mTable = mtfont.mathTable
|
||||
if count % 70 == 0 {
|
||||
let values = [
|
||||
mTable?.fractionNumeratorDisplayStyleShiftUp,
|
||||
mTable?.fractionNumeratorShiftUp,
|
||||
mTable?.fractionDenominatorDisplayStyleShiftDown,
|
||||
mTable?.fractionDenominatorShiftDown,
|
||||
mTable?.fractionNumeratorDisplayStyleGapMin,
|
||||
mTable?.fractionNumeratorGapMin,
|
||||
].compactMap{$0}
|
||||
// if count % 50 == 0 {
|
||||
// print(values)
|
||||
// }
|
||||
}
|
||||
self?.testCount += 1
|
||||
}
|
||||
queue.async(group: group, execute: workitem)
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
final class MTFontV2Tests: XCTestCase {
|
||||
func testMTFontV2Script() throws {
|
||||
@@ -1,5 +1,5 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
//
|
||||
// MathRenderSwiftTests.swift
|
||||
@@ -1,5 +1,5 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
//
|
||||
// MathRenderSwiftTests.swift
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
class MTMathUILabelLineWrappingTests: XCTestCase {
|
||||
|
||||
@@ -388,8 +388,6 @@ class MTMathUILabelLineWrappingTests: XCTestCase {
|
||||
label.font = MTFontManager.fontManager.defaultFont
|
||||
label.labelMode = .text
|
||||
|
||||
let unconstrainedSize = label.intrinsicContentSize
|
||||
|
||||
label.preferredMaxLayoutWidth = 200
|
||||
let constrainedSize = label.intrinsicContentSize
|
||||
|
||||
@@ -415,8 +413,6 @@ class MTMathUILabelLineWrappingTests: XCTestCase {
|
||||
label.font = MTFontManager.fontManager.defaultFont
|
||||
label.labelMode = .text
|
||||
|
||||
let unconstrainedSize = label.intrinsicContentSize
|
||||
|
||||
label.preferredMaxLayoutWidth = 250
|
||||
let constrainedSize = label.intrinsicContentSize
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
//
|
||||
// MathTypesetterTests.swift
|
||||
@@ -2306,10 +2306,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .text, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// In text style, large operator should be inline-sized and stay with surrounding content
|
||||
// Should be 1 line if it fits
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints are respected
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2348,9 +2344,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .text, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// In text style with wide constraint, might fit on 1-2 lines
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
XCTAssertGreaterThan(display!.subDisplays.count, 0, "Operators render")
|
||||
|
||||
// Verify width constraints
|
||||
@@ -2372,9 +2365,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should stay on 1 line when it fits
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints are respected
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2433,9 +2423,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should intelligently break between delimiters if needed
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2455,9 +2442,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should stay on 1 line when it fits
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints are respected
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2498,9 +2482,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should intelligently break between colored sections if needed
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2520,9 +2501,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Small 1x2 matrix should stay inline
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints are respected
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.2,
|
||||
@@ -2540,9 +2518,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
let display = MTTypesetter.createLineForMathList(mathList, font: self.font, style: .display, maxWidth: maxWidth)
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should break with narrow width
|
||||
let lineCount = display!.subDisplays.count
|
||||
|
||||
// Verify width constraints (matrices can be slightly wider)
|
||||
for (index, subDisplay) in display!.subDisplays.enumerated() {
|
||||
XCTAssertLessThanOrEqual(subDisplay.width, maxWidth * 1.5,
|
||||
@@ -2632,12 +2607,6 @@ final class MTTypesetterTests: XCTestCase {
|
||||
// Get the subdisplays to check ordering
|
||||
let subDisplays = display!.subDisplays
|
||||
|
||||
// Print positions and types for debugging
|
||||
for (index, subDisplay) in subDisplays.enumerated() {
|
||||
if let lineDisplay = subDisplay as? MTCTLineDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
// The expected order should be: sum (with limits), i, =, fraction
|
||||
// We need to verify that the x positions are monotonically increasing
|
||||
var previousX: CGFloat = -1
|
||||
@@ -2694,17 +2663,8 @@ final class MTTypesetterTests: XCTestCase {
|
||||
// Get the subdisplays to check ordering
|
||||
let subDisplays = display!.subDisplays
|
||||
|
||||
// Print positions and types for debugging
|
||||
for (index, subDisplay) in subDisplays.enumerated() {
|
||||
if let lineDisplay = subDisplay as? MTCTLineDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
// Track what we find and their y positions
|
||||
var sumX: CGFloat?
|
||||
var sumY: CGFloat?
|
||||
var iX: CGFloat?
|
||||
var iY: CGFloat?
|
||||
var equalsX: CGFloat?
|
||||
var equalsY: CGFloat?
|
||||
var fractionX: CGFloat?
|
||||
@@ -2714,12 +2674,10 @@ final class MTTypesetterTests: XCTestCase {
|
||||
if subDisplay is MTLargeOpLimitsDisplay {
|
||||
// Display mode: sum with limits as single display
|
||||
sumX = subDisplay.position.x
|
||||
sumY = subDisplay.position.y
|
||||
} else if subDisplay is MTGlyphDisplay {
|
||||
// Text mode: sum symbol as glyph display (check if it's the sum symbol)
|
||||
if sumX == nil {
|
||||
sumX = subDisplay.position.x
|
||||
sumY = subDisplay.position.y
|
||||
}
|
||||
} else if let lineDisplay = subDisplay as? MTCTLineDisplay,
|
||||
let text = lineDisplay.attributedString?.string {
|
||||
@@ -2728,15 +2686,8 @@ final class MTTypesetterTests: XCTestCase {
|
||||
equalsX = subDisplay.position.x
|
||||
equalsY = subDisplay.position.y
|
||||
} else if text.contains("i") && text.contains("=") {
|
||||
// i and = together (ideal case)
|
||||
iX = subDisplay.position.x
|
||||
iY = subDisplay.position.y
|
||||
equalsX = subDisplay.position.x // They're together
|
||||
equalsY = subDisplay.position.y
|
||||
} else if text.contains("i") {
|
||||
// Just i
|
||||
iX = subDisplay.position.x
|
||||
iY = subDisplay.position.y
|
||||
}
|
||||
} else if subDisplay is MTFractionDisplay {
|
||||
fractionX = subDisplay.position.x
|
||||
@@ -2781,7 +2732,7 @@ final class MTTypesetterTests: XCTestCase {
|
||||
// Check for line breaks (large y position gaps indicate line breaks)
|
||||
// Note: Superscripts/subscripts have different y positions but are on same "line"
|
||||
// Line breaks use fontSize * 1.5 spacing, so look for gaps > fontSize
|
||||
var yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
let yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
var lineBreakCount = 0
|
||||
for i in 1..<yPositions.count {
|
||||
let gap = abs(yPositions[i] - yPositions[i-1])
|
||||
@@ -2921,7 +2872,7 @@ final class MTTypesetterTests: XCTestCase {
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Check for line breaks - should have none without width constraint
|
||||
var yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
let yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
var lineBreakCount = 0
|
||||
for i in 1..<yPositions.count {
|
||||
let gap = abs(yPositions[i] - yPositions[i-1])
|
||||
@@ -3075,7 +3026,7 @@ final class MTTypesetterTests: XCTestCase {
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Count line breaks
|
||||
var yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
let yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
var lineBreakCount = 0
|
||||
for i in 1..<yPositions.count {
|
||||
let gap = abs(yPositions[i] - yPositions[i-1])
|
||||
@@ -3125,7 +3076,7 @@ final class MTTypesetterTests: XCTestCase {
|
||||
XCTAssertNotNil(display)
|
||||
|
||||
// Should have no breaks when content fits
|
||||
var yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
let yPositions = display!.subDisplays.map { $0.position.y }.sorted()
|
||||
var lineBreakCount = 0
|
||||
for i in 1..<yPositions.count {
|
||||
let gap = abs(yPositions[i] - yPositions[i-1])
|
||||
@@ -1,5 +1,5 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
//
|
||||
// MathFontTests.swift
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
@testable import SwiftUIMath
|
||||
|
||||
final class MathImageTests: XCTestCase {
|
||||
func safeImage(fileName: String, pngData: Data) {
|
||||
Reference in New Issue
Block a user