Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import Distributed
import SwiftJava

public distributed actor DistributedHi {
public typealias ActorSystem = LocalTestingDistributedActorSystem

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that’s right! Sorry I didn’t send a complete snippet earlier

public distributed func hi() -> String {
"hi"
}
}

public func makeDistributedHi() -> DistributedHi {
DistributedHi(actorSystem: LocalTestingDistributedActorSystem())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

package com.example.swift;

import org.junit.jupiter.api.Test;
import org.swift.swiftkit.core.SwiftArena;

import java.util.concurrent.Future;

import static org.junit.jupiter.api.Assertions.*;

public class DistributedTest {

@Test
void distributedMethodReturnsFuture() throws Exception {
try (var arena = SwiftArena.ofConfined()) {
DistributedHi greeter = MySwiftLibrary.makeDistributedHi(arena);

Future<String> greeting = greeter.hi();
assertEquals("hi", greeting.get());
}
}
}
Loading