xref: /OpenGrok/opengrok-indexer/src/test/resources/analysis/clojure/sample.clj (revision eeb7e5b33d1bcc524fcc9d1d560447b044e286a4)
1; Eclipse Public License, Version 1.0 (EPL-1.0) (plain text) THE ACCOMPANYING
2; PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE
3; ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
4; CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
5;
6; 1. DEFINITIONS
7;
8; "Contribution" means:
9;
10; a) in the case of the initial Contributor, the initial code and
11; documentation distributed under this Agreement, and b) in the case of each
12; subsequent Contributor: i) changes to the Program, and ii) additions to the
13; Program; where such changes and/or additions to the Program originate from
14; and are distributed by that particular Contributor. A Contribution
15; 'originates' from a Contributor if it was added to the Program by such
16; Contributor itself or anyone acting on such Contributor's behalf.
17; Contributions do not include additions to the Program which: (i) are
18; separate modules of software distributed in conjunction with the Program
19; under their own license agreement, and (ii) are not derivative works of the
20; Program. "Contributor" means any person or entity that distributes the
21; Program.
22;
23; "Licensed Patents " mean patent claims licensable by a Contributor which are
24; necessarily infringed by the use or sale of its Contribution alone or when
25; combined with the Program.
26;
27; "Program" means the Contributions distributed in accordance with this
28; Agreement.
29;
30; "Recipient" means anyone who receives the Program under this Agreement,
31; including all Contributors.
32;
33; 2. GRANT OF RIGHTS
34;
35; a) Subject to the terms of this Agreement, each Contributor hereby grants
36; Recipient a non-exclusive, worldwide, royalty-free copyright license to
37; reproduce, prepare derivative works of, publicly display, publicly perform,
38; distribute and sublicense the Contribution of such Contributor, if any, and
39; such derivative works, in source code and object code form. b) Subject to
40; the terms of this Agreement, each Contributor hereby grants Recipient a
41; non-exclusive, worldwide, royalty-free patent license under Licensed Patents
42; to make, use, sell, offer to sell, import and otherwise transfer the
43; Contribution of such Contributor, if any, in source code and object code
44; form. This patent license shall apply to the combination of the Contribution
45; and the Program if, at the time the Contribution is added by the
46; Contributor, such addition of the Contribution causes such combination to be
47; covered by the Licensed Patents. The patent license shall not apply to any
48; other combinations which include the Contribution. No hardware per se is
49; licensed hereunder. c) Recipient understands that although each Contributor
50; grants the licenses to its Contributions set forth herein, no assurances are
51; provided by any Contributor that the Program does not infringe the patent or
52; other intellectual property rights of any other entity. Each Contributor
53; disclaims any liability to Recipient for claims brought by any other entity
54; based on infringement of intellectual property rights or otherwise. As a
55; condition to exercising the rights and licenses granted hereunder, each
56; Recipient hereby assumes sole responsibility to secure any other
57; intellectual property rights needed, if any. For example, if a third party
58; patent license is required to allow Recipient to distribute the Program, it
59; is Recipient's responsibility to acquire that license before distributing
60; the Program. d) Each Contributor represents that to its knowledge it has
61; sufficient copyright rights in its Contribution, if any, to grant the
62; copyright license set forth in this Agreement.
63;
64; 3. REQUIREMENTS
65;
66; A Contributor may choose to distribute the Program in object code form under
67; its own license agreement, provided that:
68;
69; a) it complies with the terms and conditions of this Agreement; and b) its
70; license agreement: i) effectively disclaims on behalf of all Contributors
71; all warranties and conditions, express and implied, including warranties or
72; conditions of title and non-infringement, and implied warranties or
73; conditions of merchantability and fitness for a particular purpose; ii)
74; effectively excludes on behalf of all Contributors all liability for
75; damages, including direct, indirect, special, incidental and consequential
76; damages, such as lost profits; iii) states that any provisions which differ
77; from this Agreement are offered by that Contributor alone and not by any
78; other party; and iv) states that source code for the Program is available
79; from such Contributor, and informs licensees how to obtain it in a
80; reasonable manner on or through a medium customarily used for software
81; exchange. When the Program is made available in source code form:
82;
83; a) it must be made available under this Agreement; and b) a copy of this
84; Agreement must be included with each copy of the Program. Contributors may
85; not remove or alter any copyright notices contained within the Program. Each
86; Contributor must identify itself as the originator of its Contribution, if
87; any, in a manner that reasonably allows subsequent Recipients to identify
88; the originator of the Contribution.
89;
90; 4. COMMERCIAL DISTRIBUTION
91;
92; Commercial distributors of software may accept certain responsibilities with
93; respect to end users, business partners and the like. While this license is
94; intended to facilitate the commercial use of the Program, the Contributor
95; who includes the Program in a commercial product offering should do so in a
96; manner which does not create potential liability for other Contributors.
97; Therefore, if a Contributor includes the Program in a commercial product
98; offering, such Contributor ("Commercial Contributor") hereby agrees to
99; defend and indemnify every other Contributor ("Indemnified Contributor")
100; against any losses, damages and costs (collectively "Losses") arising from
101; claims, lawsuits and other legal actions brought by a third party against
102; the Indemnified Contributor to the extent caused by the acts or omissions of
103; such Commercial Contributor in connection with its distribution of the
104; Program in a commercial product offering. The obligations in this section do
105; not apply to any claims or Losses relating to any actual or alleged
106; intellectual property infringement. In order to qualify, an Indemnified
107; Contributor must: a) promptly notify the Commercial Contributor in writing
108; of such claim, and b) allow the Commercial Contributor to control, and
109; cooperate with the Commercial Contributor in, the defense and any related
110; settlement negotiations. The Indemnified Contributor may participate in any
111; such claim at its own expense.
112;
113; For example, a Contributor might include the Program in a commercial product
114; offering, Product X. That Contributor is then a Commercial Contributor. If
115; that Commercial Contributor then makes performance claims, or offers
116; warranties related to Product X, those performance claims and warranties are
117; such Commercial Contributor's responsibility alone. Under this section, the
118; Commercial Contributor would have to defend claims against the other
119; Contributors related to those performance claims and warranties, and if a
120; court requires any other Contributor to pay any damages as a result, the
121; Commercial Contributor must pay those damages.
122;
123; 5. NO WARRANTY
124;
125; EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
126; AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
127; EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
128; CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
129; PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the
130; appropriateness of using and distributing the Program and assumes all risks
131; associated with its exercise of rights under this Agreement , including but
132; not limited to the risks and costs of program errors, compliance with
133; applicable laws, damage to or loss of data, programs or equipment, and
134; unavailability or interruption of operations.
135;
136; 6. DISCLAIMER OF LIABILITY
137;
138; EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
139; CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
141; LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
142; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
143; ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
144; EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
145; OF SUCH DAMAGES.
146;
147; 7. GENERAL
148;
149; If any provision of this Agreement is invalid or unenforceable under
150; applicable law, it shall not affect the validity or enforceability of the
151; remainder of the terms of this Agreement, and without further action by the
152; parties hereto, such provision shall be reformed to the minimum extent
153; necessary to make such provision valid and enforceable.
154;
155; If Recipient institutes patent litigation against any entity (including a
156; cross-claim or counterclaim in a lawsuit) alleging that the Program itself
157; (excluding combinations of the Program with other software or hardware)
158; infringes such Recipient's patent(s), then such Recipient's rights granted
159; under Section 2(b) shall terminate as of the date such litigation is filed.
160;
161; All Recipient's rights under this Agreement shall terminate if it fails to
162; comply with any of the material terms or conditions of this Agreement and
163; does not cure such failure in a reasonable period of time after becoming
164; aware of such noncompliance. If all Recipient's rights under this Agreement
165; terminate, Recipient agrees to cease use and distribution of the Program as
166; soon as reasonably practicable. However, Recipient's obligations under this
167; Agreement and any licenses granted by Recipient relating to the Program
168; shall continue and survive.
169;
170; Everyone is permitted to copy and distribute copies of this Agreement, but
171; in order to avoid inconsistency the Agreement is copyrighted and may only be
172; modified in the following manner. The Agreement Steward reserves the right
173; to publish new versions (including revisions) of this Agreement from time to
174; time. No one other than the Agreement Steward has the right to modify this
175; Agreement. The Eclipse Foundation is the initial Agreement Steward. The
176; Eclipse Foundation may assign the responsibility to serve as the Agreement
177; Steward to a suitable separate entity. Each new version of the Agreement
178; will be given a distinguishing version number. The Program (including
179; Contributions) may always be distributed subject to the version of the
180; Agreement under which it was received. In addition, after a new version of
181; the Agreement is published, Contributor may elect to distribute the Program
182; (including its Contributions) under the new version. Except as expressly
183; stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
184; licenses to the intellectual property of any Contributor under this
185; Agreement, whether expressly, by implication, estoppel or otherwise. All
186; rights in the Program not expressly granted under this Agreement are
187; reserved.
188;
189; This Agreement is governed by the laws of the State of New York and the
190; intellectual property laws of the United States of America. No party to this
191; Agreement will bring a legal action under this Agreement more than one year
192; after the cause of action arose. Each party waives its rights to a jury
193; trial in any resulting litigation.
194
195(ns koans.23-meta
196  (:require [koan-engine.core :refer :all]))
197
198(def giants
199  (with-meta 'Giants
200    {:league "National League"}))
201
202(meditations
203  "Some objects can be tagged using the with-meta function"
204  (= __ (meta giants))
205
206  "Or more succinctly with a reader macro"
207  (= __ (meta '^{:division "West"} Giants))
208
209  "While others can't"
210  (= __ (try
211          (with-meta
212            2
213            {:prime true})
214          (catch ClassCastException e
215            "This doesn't implement the IObj interface")))
216
217  "Notice when metadata carries over"
218  (= __ (meta (merge '^{:foo :bar} {:a 1 :b 2}
219                     {:b 3 :c 4})))
220
221  "And when it doesn't"
222  (= __ (meta (merge {:a 1 :b 2}
223                     '^{:foo :bar} {:b 3 :c 36rCRAZY})))
224
225  "Metadata can be used as a type hint to avoid reflection during runtime"
226  (= __ (#(.charAt ^String % 0) "Cast me"))
227
228  "You can directly update an object's metadata"
229  (= 0xFF (let [giants
230             (with-meta
231               'Giants
232               {:world-series-titles (atom 7)})]
233         (swap! (:world-series-titles (meta giants)) __)
234         @(:world-series-titles (meta giants))))
235
236  "You can also create a new object from another object with metadata"
237  (= {:league "National League" :park "AT&T Park"}
238     (meta (vary-meta giants
239                      assoc __ __)))
240
241  "But it won't affect behavior like equality"
242  (= __ (vary-meta giants dissoc :league))
243
244  "Or the object's printed representation"
245  (= __ (pr-str (vary-meta giants dissoc :league))))
246